Class: Yamlint::Rules::Braces

Inherits:
LineRule show all
Defined in:
lib/yamlint/rules/braces.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



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/yamlint/rules/braces.rb', line 17

def check_line(line, line_number, _context)
  return if line.strip.empty?
  return if line.strip.start_with?('#')

  problems = []

  if @config[:forbid] && line.include?('{')
    problems << problem(
      line: line_number,
      column: line.index('{') + 1,
      message: 'flow mapping (braces) forbidden',
      fixable: false
    )
    return problems
  end

  problems.concat(check_opening_brace(line, line_number))
  problems.concat(check_closing_brace(line, line_number))
  problems
end

#fixable?Boolean

Returns:

  • (Boolean)


38
39
40
# File 'lib/yamlint/rules/braces.rb', line 38

def fixable?
  true
end