Class: RuboCop::Cop::Sevencop::MethodDefinitionKeywordArgumentOrdered
- Inherits:
-
Base
- Object
- Base
- RuboCop::Cop::Sevencop::MethodDefinitionKeywordArgumentOrdered
- Extended by:
- AutoCorrector
- Defined in:
- lib/rubocop/cop/sevencop/method_definition_keyword_argument_ordered.rb
Overview
Sort method definition keyword arguments in alphabetical order.
Constant Summary collapse
- MSG =
'Sort method definition keyword arguments in alphabetical order.'
Instance Method Summary collapse
- #on_kwarg(node) ⇒ Object (also: #on_kwoptarg)
Instance Method Details
#on_kwarg(node) ⇒ Object Also known as: on_kwoptarg
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/rubocop/cop/sevencop/method_definition_keyword_argument_ordered.rb', line 26 def on_kwarg(node) previous_older_kwarg = find_previous_older_sibling(node) return unless previous_older_kwarg add_offense(node) do |corrector| corrector.insert_before( previous_older_kwarg, "#{node.source}, " ) corrector.remove( node.source_range.with( begin_pos: node.left_sibling.source_range.end_pos ) ) end end |