Class: RemLint::Rules::UntilBeforeFrom

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

Overview

A reminder whose window closes before it opens.

FROM and SCANFROM set the date Remind starts scanning from; UNTIL (and its synonym THROUGH) sets the date the reminder expires. An UNTIL strictly before the start describes an empty window, and the reminder can never fire.

Unusually for this linter, Remind is not silent here: it warns at parse time, with a different message for each start keyword --

Warning: UNTIL/THROUGH date earlier than FROM date
Warning: UNTIL/THROUGH date earlier than SCANFROM date

-- so the value on offer is smaller than usual: saying it in the editor and in CI rather than only when someone runs the file and reads stderr. Remind's own tests/test.rem marks both forms "Diagnosed".

Strictly before, not on or before. FROM 1992-01-06 UNTIL 1992-01-06 is a legal one-day window and fires on the day; Remind's own warning says "earlier than" for the same reason.

Both dates have to be fully spelled out for this to be decidable, which is no restriction: GetFullDate requires exactly that of both keywords.

Constant Summary collapse

EXPIRY =

UNTIL and THROUGH are the same clause -- ParseUntil takes both and writes the same field.

%w[UNTIL THROUGH].freeze
START =

FROM and SCANFROM are different clauses that both set where the scan begins, and Remind checks the expiry against either.

%w[FROM SCANFROM].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



40
41
42
# File 'lib/remlint/rules/until_before_from.rb', line 40

def self.default_severity
  "error"
end

.descriptionObject



44
45
46
# File 'lib/remlint/rules/until_before_from.rb', line 44

def self.description
  "An UNTIL or THROUGH date earlier than the reminder's FROM or SCANFROM."
end

Instance Method Details

#checkObject



48
49
50
51
52
# File 'lib/remlint/rules/until_before_from.rb', line 48

def check
  document.code_commands.each do |command|
    check_window(command)
  end
end