Class: RubomaticHtml::Cop::Layout::MultipleLineBreaks

Inherits:
Base
  • Object
show all
Defined in:
lib/rubomatic-html/cop/layout/multiple_line_breaks.rb

Instance Attribute Summary collapse

Attributes inherited from Base

#config, #file

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

department

Methods inherited from Base

allowed_config_transform

Constructor Details

#initializeMultipleLineBreaks

:nodoc:



23
24
25
26
27
# File 'lib/rubomatic-html/cop/layout/multiple_line_breaks.rb', line 23

def initialize(...)
  super(...)

  @prev_break = false
end

Instance Attribute Details

#prev_breakBoolean

Returns tracks multiple consecutive line breaks.

Returns:

  • (Boolean)

    tracks multiple consecutive line breaks



8
9
10
# File 'lib/rubomatic-html/cop/layout/multiple_line_breaks.rb', line 8

def prev_break
  @prev_break
end

Class Method Details

.abstract_cop?Boolean

Returns:

  • (Boolean)

See Also:

  • super


12
13
14
# File 'lib/rubomatic-html/cop/layout/multiple_line_breaks.rb', line 12

def abstract_cop?
  false
end

.nameObject

See Also:

  • super


17
18
19
# File 'lib/rubomatic-html/cop/layout/multiple_line_breaks.rb', line 17

def name
  [department, 'MultipleLineBreaks'].join('/')
end

Instance Method Details

#run_for_line(line, index) ⇒ Object

See Also:

  • super


30
31
32
33
34
35
36
37
38
# File 'lib/rubomatic-html/cop/layout/multiple_line_breaks.rb', line 30

def run_for_line(line, index)
  if prev_break && line.empty?
    puts("#{file}:#{index}: has multiple line breaks")
  elsif line.empty?
    @prev_break = true
  else
    @prev_break = false
  end
end