Class: ERBLint::Corrector

Inherits:
Object
  • Object
show all
Defined in:
lib/erb_lint/corrector.rb

Constant Summary collapse

BASE =
::RuboCop::Cop::Corrector

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(processed_source, offenses) ⇒ Corrector

Returns a new instance of Corrector.



7
8
9
10
11
# File 'lib/erb_lint/corrector.rb', line 7

def initialize(processed_source, offenses)
  @processed_source = processed_source
  @offenses = offenses
  @corrected_content = corrector.rewrite
end

Instance Attribute Details

#corrected_contentObject (readonly)

Returns the value of attribute corrected_content.



5
6
7
# File 'lib/erb_lint/corrector.rb', line 5

def corrected_content
  @corrected_content
end

#offensesObject (readonly)

Returns the value of attribute offenses.



5
6
7
# File 'lib/erb_lint/corrector.rb', line 5

def offenses
  @offenses
end

#processed_sourceObject (readonly)

Returns the value of attribute processed_source.



5
6
7
# File 'lib/erb_lint/corrector.rb', line 5

def processed_source
  @processed_source
end

Instance Method Details

#correctionsObject



13
14
15
16
17
# File 'lib/erb_lint/corrector.rb', line 13

def corrections
  @corrections ||= @offenses.map do |offense|
    offense.linter.autocorrect(@processed_source, offense) if offense.linter.class.support_autocorrect?
  end.compact
end

#correctorObject



19
20
21
# File 'lib/erb_lint/corrector.rb', line 19

def corrector
  BASE.new(@processed_source.source_buffer, corrections)
end

#diagnosticsObject



27
28
29
# File 'lib/erb_lint/corrector.rb', line 27

def diagnostics
  []
end