Class: RemLint::Rules::AdvanceWarningBody

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

Overview

Reminders that arrive early without saying so.

A delta makes a reminder start appearing before the day it is about, and a time makes it arrive before the hour. Neither changes the body. So

REM 16 July ++10 MSG Jane's birthday.

prints Jane's birthday. on the 8th of July, with nothing to say the birthday is eight days off, and reads exactly like a birthday today. %b is the idiomatic fix -- "in 8 days' time" -- and %2 or %3 is its equivalent for a time.

Off by default, and it will fire on plenty of correct files: an advance warning whose body already reads naturally in both places is fine, and only the author can say. Turning it on is worth it for a file being written rather than one being inherited.

The paired rule is CalendarTextLimited, which asks you to fence the relative phrase in %"…%" so it does not follow the reminder into a calendar box.

Constant Summary collapse

RELATIVE =

%a to %l and friends all say something about when; these are the ones that say how far away it is.

/%\*?[abcefghijkluv]/i
TIME_SUBSTITUTION =
/%\*?[0-9@#]/
DELTA =
/(?<!\S)[+-]{1,2}\d+(?!\S)/

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, 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/advance_warning_body.rb', line 40

def self.default_severity
  "info"
end

.descriptionObject



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

def self.description
  "A reminder with a delta or a time whose body never says when the event is."
end

.enabled_by_default?Boolean

Returns:

  • (Boolean)


36
37
38
# File 'lib/remlint/rules/advance_warning_body.rb', line 36

def self.enabled_by_default?
  false
end

Instance Method Details

#checkObject



48
49
50
51
52
53
54
55
56
# File 'lib/remlint/rules/advance_warning_body.rb', line 48

def check
  document.code_commands.each do |command|
    trigger = document.trigger_for(command)

    if trigger.text_body?
      check_body(command, trigger)
    end
  end
end