Class: Yamlint::Rules::DocumentEnd
- Defined in:
- lib/yamlint/rules/document_end.rb
Instance Attribute Summary
Attributes inherited from Base
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
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/yamlint/rules/document_end.rb', line 12 def check(context) return [] if context.empty? has_end = context.lines.any? { |line| line.strip == '...' } required = @config[:present] if required && !has_end [problem( line: context.line_count, column: 1, message: 'missing document end "..."', fixable: true )] elsif !required && has_end line_number = context.lines.index { |line| line.strip == '...' } + 1 [problem( line: line_number, column: 1, message: 'found forbidden document end "..."', fixable: true )] else [] end end |
#fixable? ⇒ Boolean
38 39 40 |
# File 'lib/yamlint/rules/document_end.rb', line 38 def fixable? true end |