Class: RuboCop::Cop::Sevencop::MethodDefinitionOrdered
- Inherits:
-
Base
- Object
- Base
- RuboCop::Cop::Sevencop::MethodDefinitionOrdered
- Extended by:
- AutoCorrector
- Includes:
- RangeHelp, Sevencop::CopConcerns::Ordered, VisibilityHelp
- Defined in:
- lib/rubocop/cop/sevencop/method_definition_ordered.rb
Overview
Sort method definition in alphabetical order.
Constant Summary collapse
- MSG =
'Sort method definition in alphabetical order.'
Instance Method Summary collapse
- #on_def(node) ⇒ void (also: #on_defs)
Instance Method Details
#on_def(node) ⇒ void Also known as: on_defs
This method returns an undefined value.
39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/rubocop/cop/sevencop/method_definition_ordered.rb', line 39 def on_def(node) previous_older_sibling = find_previous_older_sibling(node) return unless previous_older_sibling add_offense(node) do |corrector| swap( range_with_comments_and_lines(previous_older_sibling), range_with_comments_and_lines(node), corrector: corrector, newline: true ) end end |