Closed
Description
RelativeDateConstant looks for constants in a particular format like CONST = <offset>.ago
but doesn't consider other forms, such as
START_DATE = 2.weeks.ago.to_date
RECENT_DATE = Date.yesterday
FUTURE_DATE = Time.zone.tomorrow
I looked briefly at the matchers, but I wasn't sure if using `
(as described here) would be appropriate to match the relative methods like ago
or since
with arbitrary levels of nesting.
Expected behavior
RelativeDateConstant adds offenses for a wider variety of relative date constants.
Actual behavior
None of the examples above produce offenses.
Steps to reproduce the problem
# date.rb
START_DATE = 2.weeks.ago.to_date
RECENT_DATE = Date.yesterday
FUTURE_DATE = Time.zone.tomorrow
$ rubocop date.rb
RuboCop version
$ bundle exec rubocop -V
0.93.1 (using Parser 2.7.2.0, rubocop-ast 1.1.1, running on ruby 2.7.1 x86_64-darwin19)
rubocop-rails version is 2.6.0, the logic for this particular cop doesn't seem to have changed since then.
Activity