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

Don't use FreezeTime cop in Rails <5.2 #918

Merged

Conversation

DRBragg
Copy link
Contributor

@DRBragg DRBragg commented Jan 20, 2023

freeze_time wasn't added until Rails 5.2, so running this cop against a Rails <= 5.1 app returns inaccurate offenses.

I have:

  • Added specs and confirmed failures.
  • Set minimum_target_rails_version to 5.2 in the Rails/FreezeTime Cop.
  • Reran specs and confirmed no failures.
  • Added a changelog entry

Before submitting the PR make sure the following are checked:

  • The PR relates to only one subject with a clear title and description in grammatically correct, complete sentences.
  • Wrote good commit messages.
  • Commit message starts with [Fix #issue-number] (if the related issue exists).
  • Feature branch is up-to-date with master (if not - rebase it).
  • Squashed related commits together.
  • Added tests.
  • Ran bundle exec rake default. It executes all tests and runs RuboCop on its own code.
  • Added an entry (file) to the changelog folder named {change_type}_{change_description}.md if the new code introduces user-observable changes. See changelog entry format for details.
  • If this is a new cop, consider making a corresponding update to the Rails Style Guide.

@@ -0,0 +1 @@
* Fix `Rails/FreezeTime` running against Rails < 5.2 apps. ([@DRBragg][])
Copy link
Member

Choose a reason for hiding this comment

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

Can you add the PR address?

Suggested change
* Fix `Rails/FreezeTime` running against Rails < 5.2 apps. ([@DRBragg][])
* [#918](https://github.com/rubocop/rubocop-rails/pull/918): Fix `Rails/FreezeTime` running against Rails < 5.2 apps. ([@DRBragg][])

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, absolutely! I apologize that I didn't have it in there originally. When I read the Contributing guide section on the changelog I assumed it only applied to issue links

@DRBragg DRBragg force-pushed the set_minimum_target_rails_version_for_freeze_time branch from 0a96ee6 to 9b45334 Compare January 20, 2023 16:08
@andyw8
Copy link
Contributor

andyw8 commented Jan 20, 2023

@koic Is there a policy on which Rails versions rubocop-rails should support?

@koic
Copy link
Member

koic commented Jan 21, 2023

@andyw8 Rails 4.2 and above now:
https://github.com/rubocop/rubocop-rails#compatibility

But honestly strongly conservative about supporting older versions. This patch is acceptable because it is a minor fix to existing feature and is not difficult to maintain.

I haven't decided yet, but in the future the following may hint at maintenance policy:
https://guides.rubyonrails.org/maintenance_policy.html

@koic
Copy link
Member

koic commented Jan 21, 2023

@DRBragg CI is failing. Can you take a look?

`freeze_time` wasn't added until Rails 5.2.
@DRBragg DRBragg force-pushed the set_minimum_target_rails_version_for_freeze_time branch from 9b45334 to 186e6b4 Compare January 21, 2023 05:58
@DRBragg
Copy link
Contributor Author

DRBragg commented Jan 21, 2023

I'm sorry @koic, I missed a linter error. Please forgive the oversight...

@koic
Copy link
Member

koic commented Jan 21, 2023

Never mind! Thank you for the fixing!

@koic koic merged commit 73fe04a into rubocop:master Jan 21, 2023
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.

3 participants