Class: RubyLsp::Requests::Support::RuboCopRunner
- Inherits:
-
RuboCop::Runner
- Object
- RuboCop::Runner
- RubyLsp::Requests::Support::RuboCopRunner
- Extended by:
- T::Sig
- Defined in:
- lib/ruby_lsp/requests/support/rubocop_runner.rb
Overview
:nodoc:
Defined Under Namespace
Classes: ConfigurationError
Constant Summary collapse
- DEFAULT_ARGS =
T.let( [ "--stderr", # Print any output to stderr so that our stdout does not get polluted "--force-exclusion", "--format", "RuboCop::Formatter::BaseFormatter", # Suppress any output by using the base formatter ], T::Array[String], )
Instance Attribute Summary collapse
-
#offenses ⇒ Object
readonly
Returns the value of attribute offenses.
Instance Method Summary collapse
- #formatted_source ⇒ Object
-
#initialize(*args) ⇒ RuboCopRunner
constructor
A new instance of RuboCopRunner.
- #run(path, contents) ⇒ Object
Constructor Details
#initialize(*args) ⇒ RuboCopRunner
Returns a new instance of RuboCopRunner.
63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/ruby_lsp/requests/support/rubocop_runner.rb', line 63 def initialize(*args) @options = T.let({}, T::Hash[Symbol, T.untyped]) @offenses = T.let([], T::Array[RuboCop::Cop::Offense]) @errors = T.let([], T::Array[String]) @warnings = T.let([], T::Array[String]) args += DEFAULT_ARGS = ::RuboCop::Options.new.parse(args).first config_store = ::RuboCop::ConfigStore.new super(, config_store) end |
Instance Attribute Details
#offenses ⇒ Object (readonly)
Returns the value of attribute offenses.
42 43 44 |
# File 'lib/ruby_lsp/requests/support/rubocop_runner.rb', line 42 def offenses @offenses end |
Instance Method Details
#formatted_source ⇒ Object
95 96 97 |
# File 'lib/ruby_lsp/requests/support/rubocop_runner.rb', line 95 def formatted_source @options[:stdin] end |
#run(path, contents) ⇒ Object
77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 |
# File 'lib/ruby_lsp/requests/support/rubocop_runner.rb', line 77 def run(path, contents) # Clear Runner state between runs since we get a single instance of this class # on every use site. @errors = [] @warnings = [] @offenses = [] @options[:stdin] = contents super([path]) rescue RuboCop::Runner::InfiniteCorrectionLoop => error raise Formatting::Error, error. rescue RuboCop::ValidationError => error raise ConfigurationError, error. rescue RuboCop::ErrorWithAnalyzedFileLocation => error raise InternalRuboCopError, error end |