Class: Solargraph::Diagnostics::Rubocop
- Includes:
- RubocopHelpers
- Defined in:
- lib/solargraph/diagnostics/rubocop.rb
Overview
This reporter provides linting through RuboCop.
Constant Summary collapse
- SEVERITIES =
Conversion of RuboCop severity names to LSP constants
{ 'info' => Severities::HINT, 'refactor' => Severities::HINT, 'convention' => Severities::INFORMATION, 'warning' => Severities::WARNING, 'error' => Severities::ERROR, 'fatal' => Severities::ERROR }
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
Methods included from RubocopHelpers
fix_drive_letter, generate_options, redirect_stdout, require_rubocop
Methods inherited from Base
Constructor Details
This class inherits a constructor from Solargraph::Diagnostics::Base
Instance Method Details
#diagnose(source, _api_map) ⇒ Array<Hash>
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/solargraph/diagnostics/rubocop.rb', line 25 def diagnose source, _api_map @source = source require_rubocop(rubocop_version) , paths = (source.filename, source.code) store = RuboCop::ConfigStore.new runner = RuboCop::Runner.new(, store) result = redirect_stdout{ runner.run(paths) } return [] if result.empty? make_array JSON.parse(result) rescue RuboCop::ValidationError, RuboCop::ConfigNotFoundError => e raise DiagnosticsError, "Error in RuboCop configuration: #{e.}" rescue JSON::ParserError => e raise DiagnosticsError, "RuboCop returned invalid data: #{e.}" end |