Skip to content

Commit

Permalink
Merge pull request #6364 from koic/use_cop_base_api
Browse files Browse the repository at this point in the history
Make custom cop inherit `RuboCop::Cop::Base`
  • Loading branch information
deivid-rodriguez committed Feb 10, 2023
2 parents 584ac4c + a7e4119 commit b9331b8
Showing 1 changed file with 5 additions and 12 deletions.
17 changes: 5 additions & 12 deletions util/cops/deprecations.rb
Expand Up @@ -14,19 +14,12 @@ module Rubygems
# # good
# # the `deprecate` call is fully removed
#
class Deprecations < Cop
def on_send(node)
_receiver, method_name, *args = *node
return unless method_name == :rubygems_deprecate || method_name == :rubygems_deprecate_command

add_offense(node)
end
class Deprecations < Base
MSG = "Remove `%<method_name>s` calls for the next major release."
RESTRICT_ON_SEND = %i[rubygems_deprecate rubygems_deprecate_command].freeze

private

def message(node)
msg = "Remove `#{node.method_name}` calls for the next major release "
format(msg, method: node.method_name)
def on_send(node)
add_offense(node, message: format(MSG, method_name: node.method_name))
end
end
end
Expand Down

0 comments on commit b9331b8

Please sign in to comment.