Class: RuboCop::Cop::Layout::OrderedMethods
- Inherits:
-
Base
- Object
- Base
- RuboCop::Cop::Layout::OrderedMethods
- Extended by:
- AutoCorrector
- Includes:
- AllowedMethods, RangeHelp
- Defined in:
- lib/rubocop/cop/layout/ordered_methods.rb
Overview
Constant Summary collapse
- COMPARISONS =
{ 'alphabetical' => lambda do |left_node, right_node| (method_name(left_node) <=> method_name(right_node)) != 1 end }.freeze
- ERR_INVALID_COMPARISON =
'Invalid "Comparison" config for ' \ "#{cop_name}. Expected one of: #{COMPARISONS.keys.join(', ')}".freeze
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.method_name(node) ⇒ Object
45 46 47 48 49 |
# File 'lib/rubocop/cop/layout/ordered_methods.rb', line 45 def self.method_name(node) return node.method_name unless node.send_type? node.first_argument.method_name end |
Instance Method Details
#on_begin(node) ⇒ Object
51 52 53 54 |
# File 'lib/rubocop/cop/layout/ordered_methods.rb', line 51 def on_begin(node) start_node = node.children.find(&:class_type?)&.children&.last || node check(start_node) end |