Class: RuboCop::Lsp::StdinRunner Private
- Defined in:
- lib/rubocop/lsp/stdin_runner.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Originally lifted from: github.com/Shopify/ruby-lsp/blob/8d4c17efce4e8ecc8e7c557ab2981db6b22c0b6d/lib/ruby_lsp/requests/support/rubocop_runner.rb#L20
Defined Under Namespace
Classes: ConfigurationError
Constant Summary collapse
- DEFAULT_RUBOCOP_OPTIONS =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
{ stderr: true, force_exclusion: true, formatters: ['RuboCop::Formatter::BaseFormatter'], raise_cop_error: true, todo_file: nil, todo_ignore_files: [] }.freeze
Constants inherited from Runner
Runner::MAX_ITERATIONS, Runner::REDUNDANT_COP_DISABLE_DIRECTIVE_RULES
Instance Attribute Summary collapse
- #config_for_working_directory ⇒ Object readonly private
- #offenses ⇒ Object readonly private
Attributes inherited from Runner
Instance Method Summary collapse
-
#formatted_source ⇒ Object
private
rubocop:enable Metrics/MethodLength.
-
#initialize(config_store) ⇒ StdinRunner
constructor
private
A new instance of StdinRunner.
-
#run(path, contents, options) ⇒ Object
private
rubocop:disable Metrics/MethodLength.
Methods inherited from Runner
Constructor Details
#initialize(config_store) ⇒ StdinRunner
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of StdinRunner.
31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/rubocop/lsp/stdin_runner.rb', line 31 def initialize(config_store) @options = {} @offenses = [] @warnings = [] @errors = [] @config_for_working_directory = config_store.for_pwd super(@options, config_store) end |
Instance Attribute Details
#config_for_working_directory ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
20 21 22 |
# File 'lib/rubocop/lsp/stdin_runner.rb', line 20 def config_for_working_directory @config_for_working_directory end |
#offenses ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
20 21 22 |
# File 'lib/rubocop/lsp/stdin_runner.rb', line 20 def offenses @offenses end |
Instance Method Details
#formatted_source ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
rubocop:enable Metrics/MethodLength
72 73 74 |
# File 'lib/rubocop/lsp/stdin_runner.rb', line 72 def formatted_source @options[:stdin] end |
#run(path, contents, options) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
rubocop:disable Metrics/MethodLength
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/rubocop/lsp/stdin_runner.rb', line 44 def run(path, contents, ) @options = .merge(DEFAULT_RUBOCOP_OPTIONS) @options[:stdin] = contents @offenses = [] @warnings = [] @errors = [] super([path]) raise Interrupt if aborting? rescue RuboCop::Runner::InfiniteCorrectionLoop => e if defined?(::RubyLsp::Requests::Formatting::Error) raise ::RubyLsp::Requests::Formatting::Error, e. end raise e rescue RuboCop::ValidationError => e raise ConfigurationError, e. rescue StandardError => e if defined?(::RubyLsp::Requests::Formatting::Error) raise ::RubyLsp::Requests::Support::InternalRuboCopError, e end raise e end |