Class: Mdlint::Linter::Rules::SingleTrailingNewline
- Inherits:
-
Mdlint::Linter::Rule
- Object
- Mdlint::Linter::Rule
- Mdlint::Linter::Rules::SingleTrailingNewline
- Defined in:
- lib/mdlint/linter/rules/source_style.rb,
sig/internal.rbs
Instance Attribute Summary
Attributes inherited from Mdlint::Linter::Rule
Instance Method Summary collapse
Methods inherited from Mdlint::Linter::Rule
#add_violation, inherited, #initialize
Constructor Details
This class inherits a constructor from Mdlint::Linter::Rule
Instance Method Details
#check(_tokens, source) ⇒ Object
266 267 268 269 270 271 |
# File 'lib/mdlint/linter/rules/source_style.rb', line 266 def check(_tokens, source) return @violations if source.empty? || source.end_with?("\n") && !source.end_with?("\n\n") add_violation(message: "File should end with a single newline", line: source.lines.length, fixable: true) @violations end |
#fix(_tokens, source) ⇒ Object
273 274 275 |
# File 'lib/mdlint/linter/rules/source_style.rb', line 273 def fix(_tokens, source) source.rstrip + "\n" end |