Class: RemLint::Rules::UnknownSpecialType

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

Overview

SPECIAL types no shipped back-end understands.

Remind passes a SPECIAL through untouched and the back-end is required to ignore anything it cannot parse. That contract is what makes SPECIAL extensible, and it is also why a typo is invisible: SPECIAL SHDE 255 255 204 produces no error, no warning and no shading. The reminder triggers, the back-end shrugs, and the day is simply not coloured in.

The shipped set is what the back-ends actually test passthru against -- including PostScript and PSFile, which rem2ps reads and which are easy to forget because they look like reminder types rather than SPECIAL ones. A project with its own back-end adds to the set with AllowedTypes, which is the whole point of the passthrough.

Constant Summary collapse

KNOWN =

Every value the shipped back-ends compare passthru against: the calendar ones from src/calendar.c and src/rem2ps.c, and the HTML and Pango ones from rem2html and Remind::PDF.

%w[
  SHADE MOON WEEK COLOR COLOUR
  POSTSCRIPT PSFILE PS
  PANGO HTML HTMLCLASS
].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



30
31
32
# File 'lib/remlint/rules/unknown_special_type.rb', line 30

def self.default_severity
  "warning"
end

.descriptionObject



34
35
36
# File 'lib/remlint/rules/unknown_special_type.rb', line 34

def self.description
  "A SPECIAL type no shipped back-end parses."
end

Instance Method Details

#checkObject



38
39
40
41
42
43
44
# File 'lib/remlint/rules/unknown_special_type.rb', line 38

def check
  allowed = KNOWN + option("AllowedTypes", []).map(&:upcase)

  document.code_commands.each do |command|
    check_special(command, allowed)
  end
end