Migrate RuboCop cops to Base API #72
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hi everyone,
This PR closes #71
The main goal was pretty simple β those deprecation warnings were starting to drive me a bit crazy, so I decided to clean them up once and for all π I tried to keep the changes as small and straightforward as possible β didn't want to overcomplicate things or touch unrelated parts of the codebase.
Let me know if I missed something or if there's a better way to handle any of these.
Thanks for taking a look! π
Summary
Updated custom RuboCop cops to use the new RuboCop 1.x API.
Changes
Cop Base Class Migration
belongs_to.rbanduniqueness_of.rb: Changed parent class fromRuboCop::Cop::CoptoRuboCop::Cop::Baseβ the new base class introduced in RuboCop 1.xAdded
RESTRICT_ON_SENDConstantBoth cops now define
RESTRICT_ON_SENDto explicitly declare which methods they should trigger on:[:belongs_to][:validates, :validates_uniqueness_of]This replaces the old pattern of using
def_node_matcherto filter methods inon_send, and provides better performance by having RuboCop pre-filter calls.Removed Redundant Matcher
def_node_matcher :belongs_to?sinceRESTRICT_ON_SENDhandles the filteringUpdated Offense Reporting API
Changed from
add_offense(node, location: :selector)toadd_offense(node.loc.selector)β the new preferred API for specifying offense location.Updated Test Expectations
Test files now expect the new offense message format that includes the cop name prefix (e.g.,
DatabaseValidations/BelongsTo: Use 'db_belongs_to'.instead of justUse 'db_belongs_to'.).