Class: RemLint::Rules::EasterdateFromToday

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

Overview

easterdate(today()) in a trigger that adds an offset.

easterdate(date) returns the next Easter on or after that date. So on Easter Sunday it returns today, and on Easter Monday it returns Easter of the following year. A reminder written

REM [easterdate(today())+1] MSG Easter Monday

therefore never triggers: on Easter Monday the expression has already jumped a year ahead, and the day it names is 364 days away.

easterdate(year) -- the integer form -- returns Easter of that year and does not move, which is why the fix is easterdate(year(today())).

The same reasoning applies to orthodoxeaster, which has the same two forms.

Constant Summary collapse

FUNCTIONS =
%w[easterdate orthodoxeaster].freeze
TODAY =
%w[today now realtoday].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



28
29
30
# File 'lib/remlint/rules/easterdate_from_today.rb', line 28

def self.default_severity
  "warning"
end

.descriptionObject



32
33
34
# File 'lib/remlint/rules/easterdate_from_today.rb', line 32

def self.description
  "easterdate(today()) in a trigger with an offset, which skips a year on the day."
end

Instance Method Details

#checkObject



36
37
38
39
40
41
42
# File 'lib/remlint/rules/easterdate_from_today.rb', line 36

def check
  document.code_commands.each do |command|
    if offset_trigger?(command)
      check_calls(command)
    end
  end
end