Class: RuboCop::Cop::Legion::Framework::ModuleFunctionPrivate
- Inherits:
-
Base
- Object
- Base
- RuboCop::Cop::Legion::Framework::ModuleFunctionPrivate
- Defined in:
- lib/rubocop/cop/legion/framework/module_function_private.rb
Overview
Detects modules that call both bare ‘module_function` and bare `private`. Using `private` after `module_function` resets method visibility to instance-only, which is almost never intended.
Only bare-word forms (no arguments) are flagged. Targeted calls like ‘module_function :foo` or `private :bar` are not flagged.
Constant Summary collapse
- MSG =
'`private` after `module_function` resets visibility to instance-only. ' \ 'Do not use both in the same module.'
- SEVERITY =
:convention
Instance Method Summary collapse
Instance Method Details
#on_module(node) ⇒ Object
37 38 39 40 41 42 43 44 45 46 |
# File 'lib/rubocop/cop/legion/framework/module_function_private.rb', line 37 def on_module(node) body = node.body return unless body = (body) private_node = [:private] return unless [:module_function] && private_node add_offense(private_node, severity: SEVERITY) end |