49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
|
# File 'lib/ruby_lsp/requests/support/rubocop_diagnostic.rb', line 49
def to_lsp_diagnostic
if @offense.correctable?
severity = RUBOCOP_TO_LSP_SEVERITY[@offense.severity.name]
message = @offense.message
else
severity = Constant::DiagnosticSeverity::WARNING
message = "#{@offense.message}\n\nThis offense is not auto-correctable.\n"
end
Interface::Diagnostic.new(
message: message,
source: "RuboCop",
code: @offense.cop_name,
severity: severity,
range: Interface::Range.new(
start: Interface::Position.new(
line: @offense.line - 1,
character: @offense.column,
),
end: Interface::Position.new(
line: @offense.last_line - 1,
character: @offense.last_column,
),
),
data: {
correctable: @offense.correctable?,
code_action: to_lsp_code_action,
},
)
end
|