-
-
Notifications
You must be signed in to change notification settings - Fork 266
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
Incorrect auto-correction: Time.new -> Time.zone.new #86
Labels
bug
Something isn't working
Comments
koic
added a commit
to koic/rubocop-rails
that referenced
this issue
Jul 12, 2019
Fixes rubocop#86. This PR fixes an incorrect auto-correct for `Rails/TimeZone` when using `Time.new`. ### Before ```diff - Time.new + Time.zone.new #=> NoMethodError: undefined method `new' - Time.new(2019, 7, 7, 10, 15, 25) + Time.zone.new(2019, 7, 7, 10, 15, 25) #=> NoMethodError: undefined method `new' ``` ### After ```diff - Time.new + Time.zone.now - Time.new(2019, 7, 7, 10, 15, 25) + Time.zone.local(2019, 7, 7, 10, 15, 25) ```
8 tasks
koic
added a commit
to koic/rubocop-rails
that referenced
this issue
Jul 12, 2019
Fixes rubocop#86. This PR fixes an incorrect auto-correct for `Rails/TimeZone` when using `Time.new`. ### Before ```diff - Time.new + Time.zone.new #=> NoMethodError: undefined method `new' - Time.new(2019, 7, 7, 10, 15, 25) + Time.zone.new(2019, 7, 7, 10, 15, 25) #=> NoMethodError: undefined method `new' ``` ### After ```diff - Time.new + Time.zone.now - Time.new(2019, 7, 7, 10, 15, 25) + Time.zone.local(2019, 7, 7, 10, 15, 25) ```
koic
added a commit
that referenced
this issue
Jul 13, 2019
…me_zone [#86] Fix an incorrect auto-correct for `Rails/TimeZone`
RuboCop Rails 2.2.1 has been released with a fix for this issue. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Rails/TimeZone
will substituteTime.new
toTime.zone.new
with--auto-correct
option.However,
Time.zone.new
is not a constructor ofTimeWithZone
.It should be
Time.zone.local
.Expected behavior
Substitutes
Time.new
withTime.zone.local
.Actual behavior
Substitutes
Time.new
withTime.zone.new
.Steps to reproduce the problem
RuboCop version
The text was updated successfully, but these errors were encountered: