Class: RuboCop::Cop::Yoshiki::Style::SortedKeywordArguments
- Inherits:
-
Base
- Object
- Base
- RuboCop::Cop::Yoshiki::Style::SortedKeywordArguments
- Extended by:
- AutoCorrector
- Includes:
- AllowedMethods, ReparsedEquivalence, KeywordOnlyArguments
- Defined in:
- lib/rubocop/cop/yoshiki/style/sorted_keyword_arguments.rb
Overview
Enforces alphabetical order for keyword-only method call arguments.
Layout is Yoshiki/Layout/HangingKeywordArguments. Value-omission parentheses are Yoshiki/Lint/ParenthesizeValueOmission. Padding is Layout/HashAlignment.
Constant Summary collapse
- MSG =
'Sort keyword arguments alphabetically by key name.'.freeze
Instance Method Summary collapse
- #on_investigation_end ⇒ Object
- #on_send(node) ⇒ Object (also: #on_csend)
Instance Method Details
#on_investigation_end ⇒ Object
42 43 44 45 46 47 48 49 50 51 |
# File 'lib/rubocop/cop/yoshiki/style/sorted_keyword_arguments.rb', line 42 def on_investigation_end verified_by_reparse(@pending || []).each do |node| add_offense(offense_range(node), message: MSG) do |corrector| autocorrect(corrector, node) end end @pending = [] super end |
#on_send(node) ⇒ Object Also known as: on_csend
35 36 37 38 39 |
# File 'lib/rubocop/cop/yoshiki/style/sorted_keyword_arguments.rb', line 35 def on_send node return unless eligible?(node) (@pending ||= []) << node end |