rubocop-rails
rubocop-rails copied to clipboard
Migrate `TargetRailsVersion` to the new `requires_gem` RuboCop API
This PR updates the TargetRailsVersion to conditionally use the requires_gem API when available (depending on the version of the base RuboCop gem). This has several advantages:
- It resolves a circular dependancy.
rubocop-railsdepends onrubocop(e.g. forRuboCop::Cop::Base), and that's fine, but there's also a hidden reverse dependency, whererubocopimplicitly depends onrubocop-rails.- Now it's just one-way.
rubocop-railsregisters its minimum version requirements, andrubocopknows how to understand those without needing to call back intorubcop-rails.
- It removes a "snowflake" case that's treated specially. For now we need to support both for backwards compatibility, but eventually when old versions are drop, it can just standardize on
requires_gem. - It adds rails requirements to a Cop's
gem_requirementslist, just like any other.
Before submitting the PR make sure the following are checked:
- [x] The PR relates to only one subject with a clear title and description in grammatically correct, complete sentences.
- [x] Wrote good commit messages.
- [x] Commit message starts with
[Fix #issue-number](if the related issue exists). - [x] Feature branch is up-to-date with
master(if not - rebase it). - [x] Squashed related commits together.
- [x] Added tests.
- [x] Ran
bundle exec rake default. It executes all tests and runs RuboCop on its own code. - [x] Added an entry (file) to the changelog folder named
{change_type}_{change_description}.mdif 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.~