Skip to content

Conversation

@evgeny-matveev
Copy link

@evgeny-matveev evgeny-matveev commented Jan 6, 2026

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.rb and uniqueness_of.rb: Changed parent class from RuboCop::Cop::Cop to RuboCop::Cop::Base β€” the new base class introduced in RuboCop 1.x

Added RESTRICT_ON_SEND Constant

Both cops now define RESTRICT_ON_SEND to explicitly declare which methods they should trigger on:

  • BelongsTo: [:belongs_to]
  • UniquenessOf: [:validates, :validates_uniqueness_of]

This replaces the old pattern of using def_node_matcher to filter methods in on_send, and provides better performance by having RuboCop pre-filter calls.

Removed Redundant Matcher

  • BelongsTo: Removed def_node_matcher :belongs_to? since RESTRICT_ON_SEND handles the filtering

Updated Offense Reporting API

Changed from add_offense(node, location: :selector) to add_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 just Use 'db_belongs_to'.).

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.

Inheriting from RuboCop::Cop::Cop is deprecated. Use RuboCop::Cop::Base instead

1 participant