Module: RuboCop::Cop::OnMethodDef
- Included in:
- Lint::DefEndAlignment, Lint::NestedMethodDefinition, Lint::UselessSetterCall, MethodComplexity, Metrics::MethodLength, Style::AccessorMethodName, Style::AlignParameters, Style::ClosingParenthesisIndentation, Style::DefWithParentheses, Style::DocumentationMethod, Style::EmptyLinesAroundMethodBody, Style::EmptyMethod, Style::FirstMethodParameterLineBreak, Style::GuardClause, Style::IndentationWidth, Style::MethodDefParentheses, Style::MethodMissing, Style::MultilineMethodDefinitionBraceLayout, Style::NonNilCheck, Style::PredicateName, Style::RedundantBegin, Style::RedundantReturn, Style::SingleLineMethods, Style::SpaceAfterMethodName
- Defined in:
- lib/rubocop/cop/mixin/on_method_def.rb
Overview
Common functionality for checking instance methods and singleton methods.
Instance Method Summary collapse
-
#method_def_node_parts(node) ⇒ Object
This method provides scope agnostic method node destructuring by moving the scope to the end where it can easily be ignored.
- #on_def(node) ⇒ Object
- #on_defs(node) ⇒ Object
Instance Method Details
#method_def_node_parts(node) ⇒ Object
This method provides scope agnostic method node destructuring by moving the scope to the end where it can easily be ignored.
19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/rubocop/cop/mixin/on_method_def.rb', line 19 def method_def_node_parts(node) if node.def_type? method_name, args, body = *node elsif node.defs_type? scope, method_name, args, body = *node else return [] end [method_name, args, body, scope] end |
#on_def(node) ⇒ Object
7 8 9 10 |
# File 'lib/rubocop/cop/mixin/on_method_def.rb', line 7 def on_def(node) method_name, args, body = *node on_method_def(node, method_name, args, body) end |
#on_defs(node) ⇒ Object
12 13 14 15 |
# File 'lib/rubocop/cop/mixin/on_method_def.rb', line 12 def on_defs(node) _scope, method_name, args, body = *node on_method_def(node, method_name, args, body) end |