Class: RemLint::Rules::ClauseValueRange
- Inherits:
-
RemLint::Rule
- Object
- RemLint::Rule
- RemLint::Rules::ClauseValueRange
- Defined in:
- lib/remlint/rules/clause_value_range.rb
Overview
Numeric clause arguments outside the range Remind accepts.
Four clauses take a bounded number and all four bounds are in the C:
AT hh:mm 0-23 and 0-59
DURATION hh:mm minutes 0-59; the hour is unbounded
PRIORITY n 0-9999 (`ParsePriority`, src/dorem.c)
MAX-OVERDUE n days past due, so a positive count
Remind rejects each of them, but only when the line is reached. For a reminder that is the day it triggers, which for an annual one is up to a year after the typo was made.
DURATION deliberately has no hour ceiling. A duration is a length,
not a time of day: Remind's own tests/test3.rem writes
DURATION 24:45 and DURATION 48:45 for events running over more than
one day, and Remind accepts them. Only the minutes are bounded.
PRIORITY -1 is worth a word: ParsePriority starts with isdigit, so
a minus sign is Expecting number rather than an out-of-range value, and
the message says so rather than talking about the range.
Constant Summary collapse
- MAX_HOUR =
23- MAX_MINUTE =
59- MAX_PRIORITY =
9999- BOUNDED_HOUR =
Only
ATis a time of day, so onlyAThas an hour ceiling. %w[AT].freeze
- TIME_CLAUSES =
%w[AT DURATION].freeze
- TIME =
15:00,15.00-- Remind takes either separator. /\A(?<hour>\d{1,2})[:.](?<minute>\d{1,2})\z/i- AM_PM =
/\A(?<hour>\d{1,2})([:.](?<minute>\d{1,2}))?\s*(?<half>am|pm)\z/i
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
43 44 45 |
# File 'lib/remlint/rules/clause_value_range.rb', line 43 def self.default_severity "error" end |
.description ⇒ Object
47 48 49 |
# File 'lib/remlint/rules/clause_value_range.rb', line 47 def self.description "An AT, DURATION, PRIORITY or MAX-OVERDUE value outside its range." end |
Instance Method Details
#check ⇒ Object
51 52 53 54 55 56 57 58 59 |
# File 'lib/remlint/rules/clause_value_range.rb', line 51 def check document.code_commands.each do |command| trigger = document.trigger_for(command) TIME_CLAUSES.each { |name| check_time(command, trigger.find(name)) } check_priority(command, trigger.find("PRIORITY")) check_max_overdue(command, trigger.find("MAX-OVERDUE")) end end |