Class: Rubocop::Cop::InternalAffairs::DeprecateCopHelper
- Inherits:
-
RuboCop::Cop::Base
- Object
- RuboCop::Cop::Base
- Rubocop::Cop::InternalAffairs::DeprecateCopHelper
- Defined in:
- lib/rubocop/cop/internal_affairs/deprecate_cop_helper.rb
Overview
Cop that denies the use of CopHelper.
Constant Summary collapse
- MSG =
'Do not use `CopHelper` or methods from it, use improved patterns described in https://www.rubydoc.info/gems/rubocop/RuboCop/RSpec/ExpectOffense'
Instance Method Summary collapse
- #cop_helper(node) ⇒ Object
- #cop_helper_method(node) ⇒ Object
- #cop_helper_method_on_instance(node) ⇒ Object
- #on_send(node) ⇒ Object
Instance Method Details
#cop_helper(node) ⇒ Object
11 12 13 14 |
# File 'lib/rubocop/cop/internal_affairs/deprecate_cop_helper.rb', line 11 def_node_matcher :cop_helper, <<~PATTERN (send nil? ${:include :extend :prepend} (const _ {:CopHelper})) PATTERN |
#cop_helper_method(node) ⇒ Object
17 18 19 |
# File 'lib/rubocop/cop/internal_affairs/deprecate_cop_helper.rb', line 17 def_node_search :cop_helper_method, <<~PATTERN (send nil? {:inspect_source :inspect_source_file :parse_source :autocorrect_source_file :autocorrect_source :_investigate} ...) PATTERN |
#cop_helper_method_on_instance(node) ⇒ Object
22 23 24 |
# File 'lib/rubocop/cop/internal_affairs/deprecate_cop_helper.rb', line 22 def_node_search :cop_helper_method_on_instance, <<~PATTERN (send (send nil? _) {:messages :highlights :offenses} ...) PATTERN |
#on_send(node) ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/rubocop/cop/internal_affairs/deprecate_cop_helper.rb', line 26 def on_send(node) cop_helper(node) do add_offense(node) end cop_helper_method(node) do add_offense(node) end cop_helper_method_on_instance(node) do add_offense(node) end end |