Class: RemLint::Rules::UnknownSystemVariable

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

Overview

$Names Remind does not have.

Remind's system-variable namespace is closed: FindSysVar binary-searches a fixed table and anything missing is E_NOSUCH_VAR (src/var.c). So a typo here is never a variable that happens to be empty -- it is an error, and one that fires only when the line runs, which for a reminder can be months away.

The one exception the rule has to know about is -i on the command line: remind -i$Latitude="..." initialises a variable that is not in the table, and examples/astro does exactly that in all four of its heredocs. Those come in as ordinary user variables without the sigil, so they do not reach this rule -- but a file that names its own $-prefixed variables can list them under AllowedNames.

Constant Summary

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



23
24
25
# File 'lib/remlint/rules/unknown_system_variable.rb', line 23

def self.default_severity
  "error"
end

.descriptionObject



27
28
29
# File 'lib/remlint/rules/unknown_system_variable.rb', line 27

def self.description
  "A $SystemVariable that is not one of Remind's."
end

Instance Method Details

#checkObject



31
32
33
34
35
36
37
38
39
# File 'lib/remlint/rules/unknown_system_variable.rb', line 31

def check
  allowed = option("AllowedNames", []).map(&:downcase)

  document.logical_lines.each_with_index do |logical_line, index|
    if document.commands[index].code?
      check_line(logical_line, allowed)
    end
  end
end