Class: HamlLint::Linter::RuboCop::Runner

Inherits:
RuboCop::Runner
  • Object
show all
Defined in:
lib/haml_lint/linter/rubocop.rb

Overview

Processes a ruby file and reports RuboCop offenses

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#offensesObject (readonly)

Returns the value of attribute offenses.



21
22
23
# File 'lib/haml_lint/linter/rubocop.rb', line 21

def offenses
  @offenses
end

Instance Method Details

#corrected_codeObject



33
34
35
# File 'lib/haml_lint/linter/rubocop.rb', line 33

def corrected_code
  @options[:stdin]
end

#file_finished(_file, offenses) ⇒ Object

Executed when a file has been scanned by RuboCop, adding the reported offenses to our collection.

Parameters:

  • _file (String)
  • offenses (Array<RuboCop::Cop::Offense>)


42
43
44
# File 'lib/haml_lint/linter/rubocop.rb', line 42

def file_finished(_file, offenses)
  @offenses = offenses
end

#run(haml_path, ruby_code, config:) ⇒ Object



23
24
25
26
27
28
29
30
31
# File 'lib/haml_lint/linter/rubocop.rb', line 23

def run(haml_path, ruby_code, config:)
  @offenses = []
  @config_store.instance_variable_set(:@options_config, config)
  # Using stdin also disables RuboCop's result cache, which is intentional:
  # it reconstructs offense positions from the on-disk HAML, not the Ruby we
  # inspected, so reusing it misreports lines (sds/haml-lint#593).
  @options[:stdin] = ruby_code
  super([haml_path])
end