Class: Rubocop::Language::Server::Model::Diagnostic
- Inherits:
-
Object
- Object
- Rubocop::Language::Server::Model::Diagnostic
- Defined in:
- lib/rubocop/language/server/model/diagnostic.rb
Constant Summary collapse
- DOCS_URLS =
{ Bundler: 'https://docs.rubocop.org/rubocop/cops_bundler.html#%{anchor}', Gemspec: 'https://docs.rubocop.org/rubocop/cops_gemspec.html#%{anchor}', Layout: 'https://docs.rubocop.org/rubocop/cops_layout.html#%{anchor}', Lint: 'https://docs.rubocop.org/rubocop/cops_lint.html#%{anchor}', Metrics: 'https://docs.rubocop.org/rubocop/cops_metrics.html#%{anchor}', Migration: 'https://docs.rubocop.org/rubocop/cops_migration.html#%{anchor}', Naming: 'https://docs.rubocop.org/rubocop/cops_naming.html#%{anchor}', Security: 'https://docs.rubocop.org/rubocop/cops_security.html#%{anchor}', Style: 'https://docs.rubocop.org/rubocop/cops_style.html#%{anchor}', Minitest: 'https://docs.rubocop.org/rubocop-minitest/cops_minitest.html#%{anchor}', Performance: 'https://docs.rubocop.org/rubocop-performance/cops_performance.html#%{anchor}', Rails: 'https://docs.rubocop.org/rubocop-rails/cops_rails.html#%{anchor}', RSpec: 'https://docs.rubocop.org/rubocop-rspec/cops_rspec.html#%{anchor}', 'RSpec/Capybara': 'https://docs.rubocop.org/rubocop-rspec/cops_rspec/capybara.html#%{anchor}', 'RSpec/FactoryBot': 'https://docs.rubocop.org/rubocop-rspec/cops_rspec/factorybot.html#%{anchor}', 'RSpec/Rails': 'https://docs.rubocop.org/rubocop-rspec/cops_rspec/rails.html#%{anchor}', Sorbet: 'https://github.com/Shopify/rubocop-sorbet/blob/master/manual/cops_sorbet.md#%{anchor}' }.freeze
Instance Attribute Summary collapse
-
#badge ⇒ Object
readonly
Returns the value of attribute badge.
-
#end ⇒ Object
readonly
Returns the value of attribute end.
-
#message ⇒ Object
readonly
Returns the value of attribute message.
-
#replacements ⇒ Object
readonly
Returns the value of attribute replacements.
-
#start ⇒ Object
readonly
Returns the value of attribute start.
Instance Method Summary collapse
- #cop_name ⇒ Object
- #correctable? ⇒ Boolean
- #diagnostic_response ⇒ Object
-
#initialize(offense) ⇒ Diagnostic
constructor
A new instance of Diagnostic.
Constructor Details
#initialize(offense) ⇒ Diagnostic
Returns a new instance of Diagnostic.
28 29 30 31 32 33 34 |
# File 'lib/rubocop/language/server/model/diagnostic.rb', line 28 def initialize(offense) @badge = RuboCop::Cop::Badge.parse(offense.cop_name) @message = offense. @start = Interface::Position.new(line: offense.line - 1, character: offense.column) @end = Interface::Position.new(line: offense.last_line - 1, character: offense.last_column) @replacements = replacements_from_offense(offense) end |
Instance Attribute Details
#badge ⇒ Object (readonly)
Returns the value of attribute badge.
6 7 8 |
# File 'lib/rubocop/language/server/model/diagnostic.rb', line 6 def badge @badge end |
#end ⇒ Object (readonly)
Returns the value of attribute end.
6 7 8 |
# File 'lib/rubocop/language/server/model/diagnostic.rb', line 6 def end @end end |
#message ⇒ Object (readonly)
Returns the value of attribute message.
6 7 8 |
# File 'lib/rubocop/language/server/model/diagnostic.rb', line 6 def @message end |
#replacements ⇒ Object (readonly)
Returns the value of attribute replacements.
6 7 8 |
# File 'lib/rubocop/language/server/model/diagnostic.rb', line 6 def replacements @replacements end |
#start ⇒ Object (readonly)
Returns the value of attribute start.
6 7 8 |
# File 'lib/rubocop/language/server/model/diagnostic.rb', line 6 def start @start end |
Instance Method Details
#cop_name ⇒ Object
40 41 42 |
# File 'lib/rubocop/language/server/model/diagnostic.rb', line 40 def cop_name @cop_name ||= badge.to_s end |
#correctable? ⇒ Boolean
36 37 38 |
# File 'lib/rubocop/language/server/model/diagnostic.rb', line 36 def correctable? !!@replacements end |
#diagnostic_response ⇒ Object
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/rubocop/language/server/model/diagnostic.rb', line 44 def diagnostic_response @diagnostic_response ||= Interface::Diagnostic.new( message: , source: 'RuboCop', code: cop_name, code_description: Interface::CodeDescription.new( href: doc_url ), severity: Constant::DiagnosticSeverity::INFORMATION, range: Interface::Range.new( start: start, end: self.end ) ) end |