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

AllowToTime attribute may be no longer needed #715

Open
nekonenene opened this issue Jun 15, 2022 · 0 comments
Open

AllowToTime attribute may be no longer needed #715

nekonenene opened this issue Jun 15, 2022 · 0 comments

Comments

@nekonenene
Copy link

Currently, the Rails/Date cop has the AllowToTime attribute, and its default is true.

https://docs.rubocop.org/rubocop-rails/cops_rails.html#railsdate

This was because DateTime already has the application time zone, therefore using DateTime#to_time method was not a problem.

#288

However, DateTime class has been deprecated since September 2020.

ruby/date@58ca6e6

I think the default of AllowToTime could be false, or we could omit the AllowToTime attribute and always complain to_time to prevent using the system time zone. How about it?


Expected behavior

rubocop-rails complains to_time with default settings.

Actual behavior

rubocop-rails complains to_time only if the AllowToTime attribute is set to false.

Steps to reproduce the problem

time = "2020-01-01".to_time

RuboCop version

1.23.0 (using Parser 3.0.3.1, rubocop-ast 1.14.0, running on ruby 3.0.3 x86_64-linux)
  - rubocop-rails 2.12.4
  - rubocop-rspec 2.6.0
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

No branches or pull requests

1 participant