Class: Standard::Lsp::StdinRubocopRunner
- Inherits:
-
RuboCop::Runner
- Object
- RuboCop::Runner
- Standard::Lsp::StdinRubocopRunner
- Defined in:
- lib/standard/lsp/stdin_rubocop_runner.rb
Overview
Defined Under Namespace
Classes: ConfigurationError
Constant Summary collapse
- DEFAULT_RUBOCOP_OPTIONS =
{ stderr: true, force_exclusion: true, formatters: ["RuboCop::Formatter::BaseFormatter"], raise_cop_error: true, todo_file: nil, todo_ignore_files: [] }.freeze
Instance Attribute Summary collapse
-
#config_for_working_directory ⇒ Object
readonly
Returns the value of attribute config_for_working_directory.
-
#offenses ⇒ Object
readonly
Returns the value of attribute offenses.
Instance Method Summary collapse
- #formatted_source ⇒ Object
-
#initialize(config) ⇒ StdinRubocopRunner
constructor
A new instance of StdinRubocopRunner.
- #run(path, contents) ⇒ Object
Constructor Details
#initialize(config) ⇒ StdinRubocopRunner
Returns a new instance of StdinRubocopRunner.
21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/standard/lsp/stdin_rubocop_runner.rb', line 21 def initialize(config) @options = {} @offenses = [] @errors = [] @warnings = [] @config_for_working_directory = config.rubocop_config_store.for_pwd super( config..merge(DEFAULT_RUBOCOP_OPTIONS), config.rubocop_config_store ) end |
Instance Attribute Details
#config_for_working_directory ⇒ Object (readonly)
Returns the value of attribute config_for_working_directory.
10 11 12 |
# File 'lib/standard/lsp/stdin_rubocop_runner.rb', line 10 def config_for_working_directory @config_for_working_directory end |
#offenses ⇒ Object (readonly)
Returns the value of attribute offenses.
8 9 10 |
# File 'lib/standard/lsp/stdin_rubocop_runner.rb', line 8 def offenses @offenses end |
Instance Method Details
#formatted_source ⇒ Object
60 61 62 |
# File 'lib/standard/lsp/stdin_rubocop_runner.rb', line 60 def formatted_source @options[:stdin] end |
#run(path, contents) ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/standard/lsp/stdin_rubocop_runner.rb', line 35 def run(path, contents) @errors = [] @warnings = [] @offenses = [] @options[:stdin] = contents super([path]) raise Interrupt if aborting? rescue ::RuboCop::Runner::InfiniteCorrectionLoop => error if defined?(::RubyLsp::Requests::Formatting::Error) raise ::RubyLsp::Requests::Formatting::Error, error. else raise error end rescue ::RuboCop::ValidationError => error raise ConfigurationError, error. rescue => error if defined?(::RubyLsp::Requests::Formatting::Error) raise ::RubyLsp::Requests::Support::InternalRuboCopError, error else raise error end end |