Class: RuboCop::Cop::GreppableRails::NoHelperInController
- Inherits:
-
Base
- Object
- Base
- RuboCop::Cop::GreppableRails::NoHelperInController
- Defined in:
- lib/rubocop/cop/greppable_rails/no_helper_in_controller.rb
Overview
Prohibits helper :name calls at controller class scope. Implicit
helper inclusion makes the helper method's call site impossible to
grep from the controller — call the helper module explicitly where
you need it instead.
Constant Summary collapse
- MSG =
"Don't include helper via call helper in Controller."- RESTRICT_ON_SEND =
%i[helper].freeze
Instance Method Summary collapse
Instance Method Details
#on_send(node) ⇒ Object
32 33 34 35 36 37 38 39 |
# File 'lib/rubocop/cop/greppable_rails/no_helper_in_controller.rb', line 32 def on_send(node) parent = node.parent parent = parent.parent if parent&.begin_type? return unless parent&.class_type? return unless parent.identifier.const_name.end_with?("Controller") add_offense(node) if offense?(node) end |