Class: RuboCop::Cop::GreppableRails::UseInlineAccessModifier
- Inherits:
-
Base
- Object
- Base
- RuboCop::Cop::GreppableRails::UseInlineAccessModifier
- Defined in:
- lib/rubocop/cop/greppable_rails/use_inline_access_modifier.rb
Overview
Enforces the inline form of private/protected access modifiers
(private def foo) over the group form (private then def foo)
and the symbol-argument form (private :foo). The inline form keeps
a method's visibility greppable on the same line as its definition.
public and module_function are intentionally out of scope.
Constant Summary collapse
- MSG =
"Use inline style access modifier."- RESTRICT_ON_SEND =
%i[private protected].freeze
Instance Method Summary collapse
Instance Method Details
#on_send(node) ⇒ Object
37 38 39 40 41 42 |
# File 'lib/rubocop/cop/greppable_rails/use_inline_access_modifier.rb', line 37 def on_send(node) return unless node.access_modifier? return if node.parent&.pair_type? add_offense(node) if offense?(node) end |