Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace Time.zone.now with Time.current #2636

Merged
merged 1 commit into from
Jan 9, 2024

Conversation

chrislo
Copy link
Contributor

@chrislo chrislo commented Jan 9, 2024

Trello: https://trello.com/c/wSKG73MP
Arises from: #2599

rubocop-govuk enables the "strict" style of the Rails/TimeZone cop[1]. This cop doesn't have a preference[2] for either of the equivalent methods Time.zone.now or Time.current. Since the latter is shorter and we're currently using a mixture of both I've gone with Time.current. I don't think we can enforce this without deviating from rubocop-govuk but hopefully being consistent now will help keep things that way.

[1]
https://github.com/alphagov/rubocop-govuk/blob/97fcbc866aa10a75c7c1c89fc3c2c562cc04fc26/config/rails.yml#L89 [2] https://github.com/rubocop/rubocop-rails/blob/cb01e4d6a33b0e4285b2972f9c64fc45e5776429/lib/rubocop/cop/rails/time_zone.rb#L26

rubocop-govuk enables the "strict" style of the Rails/TimeZone
cop[1]. This cop doesn't have a preference[2] for either of the equivalent
methods `Time.zone.now` or `Time.current`. Since the latter is shorter
and we're currently using a mixture of both I've gone with
`Time.current`. I don't think we can enforce this without deviating
from rubocop-govuk but hopefully being consistent now will help keep
things that way.

[1]
https://github.com/alphagov/rubocop-govuk/blob/97fcbc866aa10a75c7c1c89fc3c2c562cc04fc26/config/rails.yml#L89
[2] https://github.com/rubocop/rubocop-rails/blob/cb01e4d6a33b0e4285b2972f9c64fc45e5776429/lib/rubocop/cop/rails/time_zone.rb#L26
@chrislo chrislo marked this pull request as ready for review January 9, 2024 16:53
Copy link
Contributor

@floehopper floehopper left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😍

@chrislo chrislo merged commit e1a1605 into main Jan 9, 2024
17 checks passed
@chrislo chrislo deleted the replace-time-zone-now-with-time-current branch January 9, 2024 17:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants