Class: RuboCounsel::Runner
- Inherits:
-
RuboCop::Runner
- Object
- RuboCop::Runner
- RuboCounsel::Runner
- Defined in:
- lib/rubocounsel/runner.rb
Overview
Subclass of RuboCop::Runner that tracks which cops fired offenses.
Responsibilities:
- Run RuboCop normally
- Hook file_finished to track offending cop names
- Provide the list of offending cops to the Counselor
The runner separates the concern of "run RuboCop and collect offenses" from the interactive CLI experience (handled by Counselor).
Instance Attribute Summary collapse
-
#offending_cops ⇒ Object
readonly
Returns the value of attribute offending_cops.
Instance Method Summary collapse
- #file_finished(_file, offenses) ⇒ Object
-
#initialize(rubocop_options: {}) ⇒ Runner
constructor
A new instance of Runner.
Constructor Details
#initialize(rubocop_options: {}) ⇒ Runner
Returns a new instance of Runner.
18 19 20 21 22 23 24 25 26 27 |
# File 'lib/rubocounsel/runner.rb', line 18 def initialize(rubocop_options: {}) @offending_cops = Set.new = .merge(formatters: []) config_store = RuboCop::ConfigStore.new config_store. = [:config] if [:config] super(, config_store) end |
Instance Attribute Details
#offending_cops ⇒ Object (readonly)
Returns the value of attribute offending_cops.
16 17 18 |
# File 'lib/rubocounsel/runner.rb', line 16 def offending_cops @offending_cops end |
Instance Method Details
#file_finished(_file, offenses) ⇒ Object
29 30 31 32 |
# File 'lib/rubocounsel/runner.rb', line 29 def file_finished(_file, offenses) @offending_cops.merge(offenses.map(&:cop_name)) unless offenses.empty? super end |