Class: RuboCop::Cop::Elegant::NoNilReturn
- Inherits:
-
Base
- Object
- Base
- RuboCop::Cop::Elegant::NoNilReturn
- Defined in:
- lib/rubocop/cop/elegant/no_nil_return.rb
Overview
Forbids a method from returning the literal nil explicitly. The cop flags two patterns: a return nil statement anywhere inside the method body, and a method whose tail expression is the literal nil (whether it stands alone or appears as the last statement of a multi-statement body). Methods that omit return, use a bare return keyword, or merely happen to evaluate to nil through control flow are not flagged.
Constant Summary collapse
- MSG =
'Method must not return nil explicitly'
Instance Method Summary collapse
Instance Method Details
#on_def(node) ⇒ Object
17 18 19 |
# File 'lib/rubocop/cop/elegant/no_nil_return.rb', line 17 def on_def(node) check(node) end |
#on_defs(node) ⇒ Object
21 22 23 |
# File 'lib/rubocop/cop/elegant/no_nil_return.rb', line 21 def on_defs(node) check(node) end |