Class: Yamlint::Rules::NewLineAtEndOfFile

Inherits:
Base
  • Object
show all
Defined in:
lib/yamlint/rules/new_line_at_end_of_file.rb

Instance Attribute Summary

Attributes inherited from Base

#config, #level

Instance Method Summary collapse

Methods inherited from Base

defaults, desc, inherited, #initialize, rule_id

Constructor Details

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

Instance Method Details

#check(context) ⇒ Object



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

def check(context)
  return [] if context.empty?

  last_char = context.content[-1]
  return [] if last_char == "\n"

  [problem(
    line: context.line_count,
    column: (context.lines.last&.length || 0) + 1,
    message: 'no new line character at the end of file',
    fixable: true
  )]
end

#fixable?Boolean

Returns:

  • (Boolean)


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

def fixable?
  true
end