Class: RuboCop::Cop::Sane::DisallowMethods
- Inherits:
-
Base
- Object
- Base
- RuboCop::Cop::Sane::DisallowMethods
- Extended by:
- AutoCorrector
- Defined in:
- lib/rubocop/cop/sane/disallow_methods.rb
Overview
Enforces method replacements and prohibitions.
This cop checks for usage of specified methods and either suggests replacements (with auto-correction) or prohibits usage entirely.
Constant Summary collapse
- REPLACEABLE_METHOD_MSG =
"You should use `%<with>s` instead of `%<method_name>s` because %<reason>s"- PROHIBITED_METHOD_MSG =
"You should not use `%<method_name>s` because %<reason>s"
Instance Method Summary collapse
Instance Method Details
#on_send(node) ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/rubocop/cop/sane/disallow_methods.rb', line 41 def on_send(node) method_name = node.method_name replaceable = replace_methods[method_name] prohibited = prohibited_methods[method_name] if replaceable handle_replaceable_method(node, method_name, replaceable) elsif prohibited handle_prohibited_method(node, method_name, prohibited) end end |