Class: Mdlint::Linter::Rules::NoSpaceAfterHash
- Inherits:
-
Mdlint::Linter::Rule
- Object
- Mdlint::Linter::Rule
- Mdlint::Linter::Rules::NoSpaceAfterHash
- 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
69 70 71 72 73 74 75 76 |
# File 'lib/mdlint/linter/rules/source_style.rb', line 69 def check(_tokens, source) source.each_line.with_index(1) do |line, line_number| next unless line.chomp.match?(/\A {0,3}\#{1,6}(?!\#)\S/) add_violation(message: "Add a space after the heading marker", line: line_number, fixable: true) end @violations end |
#fix(_tokens, source) ⇒ Object
78 79 80 |
# File 'lib/mdlint/linter/rules/source_style.rb', line 78 def fix(_tokens, source) source.each_line.map { |line| line.sub(/\A( {0,3}\#{1,6})(?!\#)(\S)/, '\\1 \\2') }.join end |