Class: Yamlint::Rules::TrailingSpaces

Inherits:
LineRule show all
Defined in:
lib/yamlint/rules/trailing_spaces.rb

Instance Attribute Summary

Attributes inherited from Base

#config, #level

Instance Method Summary collapse

Methods inherited from LineRule

#check

Methods inherited from Base

#check, defaults, desc, inherited, #initialize, rule_id

Constructor Details

This class inherits a constructor from Yamlint::Rules::Base

Instance Method Details

#check_line(line, line_number, _context) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/yamlint/rules/trailing_spaces.rb', line 10

def check_line(line, line_number, _context)
  return if line.chomp.empty?

  trailing = line[/[ \t]+$/]
  return unless trailing

  problem(
    line: line_number,
    column: line.rstrip.length + 1,
    message: 'trailing spaces',
    fixable: true
  )
end

#fixable?Boolean

Returns:

  • (Boolean)


24
25
26
# File 'lib/yamlint/rules/trailing_spaces.rb', line 24

def fixable?
  true
end