Class: RemLint::Rules::TagSyntax

Inherits:
RemLint::Rule show all
Defined in:
lib/remlint/rules/tag_syntax.rb

Overview

TAG values that will not survive the trip to a back-end.

Tags are handed to the machine-readable back-ends as a comma-separated list. A comma inside one tag therefore splits it into two tags nobody wrote, and whitespace inside one ends it early. Neither is an error -- the reminder triggers, the tag is simply not the tag that was written, and the mistake surfaces in whatever consumes the export.

Constant Summary collapse

FORBIDDEN =
{
  ","  => "separates tags in the list back-ends receive",
  " "  => "ends the tag",
  "\t" => "ends the tag",
}.freeze

Constants inherited from RemLint::Rule

RemLint::Rule::REGISTRY

Instance Attribute Summary

Attributes inherited from RemLint::Rule

#config, #document, #offenses

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from RemLint::Rule

all, enabled_by_default?, find, inherited, #initialize, rule_name, #rule_name, #run

Constructor Details

This class inherits a constructor from RemLint::Rule

Class Method Details

.default_severityObject



21
22
23
# File 'lib/remlint/rules/tag_syntax.rb', line 21

def self.default_severity
  "warning"
end

.descriptionObject



25
26
27
# File 'lib/remlint/rules/tag_syntax.rb', line 25

def self.description
  "A TAG value containing a comma or whitespace."
end

Instance Method Details

#checkObject



29
30
31
32
33
34
35
36
37
# File 'lib/remlint/rules/tag_syntax.rb', line 29

def check
  document.code_commands.each do |command|
    document.trigger_for(command).clauses.each do |clause|
      if clause.name == "TAG"
        check_tag(command, clause)
      end
    end
  end
end