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

Make custom cop inherit RuboCop::Cop::Base #6364

Merged
merged 1 commit into from Feb 10, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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