Class: Yamlint::Rules::LineLength

Inherits:
LineRule show all
Defined in:
lib/yamlint/rules/line_length.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, #fixable?, 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



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/yamlint/rules/line_length.rb', line 14

def check_line(line, line_number, _context)
  max_length = @config[:max]
  actual_length = line.chomp.length

  return if actual_length <= max_length
  return if allow_non_breakable_words? && non_breakable_word?(line)
  return if allow_non_breakable_inline_mappings? && inline_mapping?(line)

  problem(
    line: line_number,
    column: max_length + 1,
    message: "line too long (#{actual_length} > #{max_length} characters)",
    fixable: false
  )
end