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

Time.current is getting autocorrected to Time.zone.current #70

Closed
LandonSchropp opened this issue Mar 18, 2019 · 7 comments · Fixed by #485
Closed

Time.current is getting autocorrected to Time.zone.current #70

LandonSchropp opened this issue Mar 18, 2019 · 7 comments · Fixed by #485

Comments

@LandonSchropp
Copy link

Expected behavior

I believe Time.current should get updated to Time.zone.now.

Actual behavior

I believe Time.current gets updated to Time.zone.current, which doesn't exist.

Steps to reproduce the problem

  • Create a Rails repo
  • Add Rubocop
  • Set Rails/TimeZone to EnforcedStyle: strict.
  • Add Time.current

Is this potentially related to #6346?

RuboCop version

0.66.0 (using Parser 2.6.0.0, running on ruby 2.5.3 x86_64-linux)
@mikegee
Copy link
Contributor

mikegee commented Mar 19, 2019

I believe Time.current should get updated to Time.zone.now.

I don't think Time.current needs corrected. Its implementation is Time.zone.now.

@LandonSchropp
Copy link
Author

The current behavior of EnforcedStyle: strict seems to change it. I know there's a lot of confusion around the correct time zone syntax. My team prefers to set a rule to avoid ambiguity.

@stale
Copy link

stale bot commented May 8, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contribution and understanding!

@tejasbubane
Copy link
Contributor

@tejasbubane
Copy link
Contributor

Please move this issue to rubocop-rails repo.

@koic koic transferred this issue from rubocop/rubocop Jun 6, 2019
@vfonic
Copy link
Contributor

vfonic commented Jun 6, 2019

We should probably rewrite the TimeZone cop and have it always follow the strict mode.

I also agree that Time.current should be allowed. This was an oversight on my side when I wrote that test.

koic added a commit to koic/rubocop-rails that referenced this issue May 12, 2021
Fixes rubocop#70.

This PR fixes a false positive for `Rails/TimeZone` when setting
`EnforcedStyle: strict` and using `Time.current`.
@koic koic closed this as completed in #485 May 14, 2021
koic added a commit that referenced this issue May 14, 2021
[Fix #70] Fix a false positive for `Rails/TimeZone`
koic added a commit to koic/rubocop-rails that referenced this issue May 17, 2021
Fixes rubocop#70.

This PR fixes a false positive for `Rails/TimeZone` when setting
`EnforcedStyle: strict` and using `Time.current`.
@LandonSchropp
Copy link
Author

Thanks!

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 a pull request may close this issue.

4 participants