Class: RemLint::Rules::AddomitWithoutScanfrom
- Inherits:
-
RemLint::Rule
- Object
- RemLint::Rule
- RemLint::Rules::AddomitWithoutScanfrom
- Defined in:
- lib/remlint/rules/addomit_without_scanfrom.rb
Overview
ADDOMIT with no SCANFROM, which adds the wrong year's holiday.
ADDOMIT puts a movable holiday's computed date into the omit context.
But Remind computes a reminder's trigger by scanning forward from today,
so the day after the holiday the trigger has already moved to next
year's occurrence -- and it is next year's date that gets added.
Reminders that SKIP, BEFORE or AFTER around the holiday then work
perfectly until the day after it, and are quietly wrong from then on.
SCANFROM fixes it by making the scan start far enough back that the
current year's date stays the trigger. Remind warns about a missing one
itself, and names the same figure:
Warning: Consider using SCANFROM -28 with recurring ADDOMIT
This rule says it before the file is ever run, and keeps to Remind's
scope: a trigger built from a bracketed expression is opaque to both of
us, so neither reports it. include/holidays/cl.rem has one
(REM [datepart(soleq(1, $U-28))] ADDOMIT ...) and Remind is quiet
about it, so this is too.
The width of the window is a judgement rather than a fact, and so is
off by default. Chapter 4 works through 28 days, and
include/holidays/us.rem uses exactly that -- but examples/defs.rem
uses SCANFROM -7 twenty-seven times, and that is not a bug: it is a
smaller guarantee, adequate for holidays whose dependent reminders are
all within a week. Set MinimumWindow to 28 to ask for the wider one.
Constant Summary collapse
- RECOMMENDED =
The figure chapter 4 works through, used only in the message and as the suggestion for a missing SCANFROM.
28
Constants inherited from RemLint::Rule
Instance Attribute Summary
Attributes inherited from RemLint::Rule
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_severity ⇒ Object
39 40 41 |
# File 'lib/remlint/rules/addomit_without_scanfrom.rb', line 39 def self.default_severity "warning" end |
.description ⇒ Object
43 44 45 |
# File 'lib/remlint/rules/addomit_without_scanfrom.rb', line 43 def self.description "ADDOMIT with no SCANFROM, which adds next year's date the day after the holiday." end |
Instance Method Details
#check ⇒ Object
47 48 49 50 51 52 53 54 55 |
# File 'lib/remlint/rules/addomit_without_scanfrom.rb', line 47 def check document.code_commands.each do |command| trigger = document.trigger_for(command) if trigger.include?("ADDOMIT") && !computed?(command, trigger) check_scanfrom(command, trigger) end end end |