Class: Mdlint::Linter::Rules::FencedCodeStyle

Inherits:
Mdlint::Linter::Rule show all
Includes:
SourceStyleSupport
Defined in:
lib/mdlint/linter/rules/source_style.rb,
sig/internal.rbs

Constant Summary

Constants included from SourceStyleSupport

SourceStyleSupport::FENCE_REGEXP, SourceStyleSupport::LIST_MARKER_REGEXP

Instance Attribute Summary

Attributes inherited from Mdlint::Linter::Rule

#violations

Instance Method Summary collapse

Methods included from SourceStyleSupport

#fenced_lines, #inline_tokens, #line_is_blank?, #lines, #outside_fence?

Methods inherited from Mdlint::Linter::Rule

#add_violation, #fix, inherited, #initialize

Constructor Details

This class inherits a constructor from Mdlint::Linter::Rule

Instance Method Details

#check(_tokens, source) ⇒ Object



251
252
253
254
255
256
257
258
# File 'lib/mdlint/linter/rules/source_style.rb', line 251

def check(_tokens, source)
  source.each_line.with_index(1) do |line, line_number|
    next unless line.match?(/\A {4}\S/)

    add_violation(message: "Use a fenced code block", line: line_number, fixable: false)
  end
  @violations
end