Class: RemLint::Rules::Syntax
- Inherits:
-
RemLint::Rule
- Object
- RemLint::Rule
- RemLint::Rules::Syntax
- Defined in:
- lib/remlint/rules/syntax.rb
Overview
Remind's own diagnostics, folded into the linter's output.
puppet-lint draws the line here and it is the right line: a linter validates style, and for "is this even valid" you run the real parser. Remind has no parse-only mode, so the real parser is Remind, and running it means running the file.
THIS RULE IS OFF BY DEFAULT, and stays off unless someone turns it on, because of what running the file means:
INCLUDE and INCLUDECMD read -- and INCLUDECMD executes -- other things
RUN reminders shell out
-r is passed to disable RUN directives, -q to keep timed reminders
out of the queue, and -n to ask only for next occurrences. That covers
the RUN half. It does not cover INCLUDECMD, so turn this on for files you
trust and leave it off for files you do not.
When remind is not on PATH the rule reports nothing rather than
failing: a linter that cannot run on a machine without Remind installed
is a linter that cannot run in CI. It does say so once, through
Runner, because silently not syntax-checking is worse than not
syntax-checking -- a build can otherwise believe it is covered when it
is not.
Constant Summary collapse
- DEFAULT_COMMAND =
"remind"- DIAGNOSTIC =
file(12): Some messageandfile(12:14): Some message, the two forms src/main.c prints depending on whether the command spanned lines. /\A(?<file>[^(]+)\((?<line>\d+)(?::(?<end_line>\d+))?\):\s*(?<message>.*)\z/- WARNING =
Remind labels its own non-fatal diagnostics -- "Warning: Missing ENDIF" and friends -- so they are relayed as warnings rather than promoted to errors by this rule's configured severity.
/\Awarning\b/i
Constants inherited from RemLint::Rule
Instance Attribute Summary collapse
-
#unavailable ⇒ Object
readonly
Set once per run when the configured command is missing, so
Runnercan say so a single time rather than per file.
Attributes inherited from RemLint::Rule
Class Method Summary collapse
Instance Method Summary collapse
Methods inherited from RemLint::Rule
all, find, inherited, #initialize, rule_name, #rule_name, #run
Constructor Details
This class inherits a constructor from RemLint::Rule
Instance Attribute Details
#unavailable ⇒ Object (readonly)
Set once per run when the configured command is missing, so Runner
can say so a single time rather than per file.
60 61 62 |
# File 'lib/remlint/rules/syntax.rb', line 60 def unavailable @unavailable end |
Class Method Details
.default_severity ⇒ Object
50 51 52 |
# File 'lib/remlint/rules/syntax.rb', line 50 def self.default_severity "error" end |
.description ⇒ Object
54 55 56 |
# File 'lib/remlint/rules/syntax.rb', line 54 def self.description "Diagnostics from running the file through Remind itself (off by default)." end |
.enabled_by_default? ⇒ Boolean
46 47 48 |
# File 'lib/remlint/rules/syntax.rb', line 46 def self.enabled_by_default? false end |
Instance Method Details
#check ⇒ Object
62 63 64 65 66 67 68 69 70 71 |
# File 'lib/remlint/rules/syntax.rb', line 62 def check command = option("Command", DEFAULT_COMMAND) @unavailable = nil if executable?(command) run_remind(command) else @unavailable = command end end |