Class: RuboCop::Cop::Teamtailor::AlphabeticalSerializerAttributes
- Inherits:
-
Base
- Object
- Base
- RuboCop::Cop::Teamtailor::AlphabeticalSerializerAttributes
- Extended by:
- AutoCorrector
- Defined in:
- lib/rubocop/cop/teamtailor/alphabetical_serializer_attributes.rb
Constant Summary collapse
- MSG =
"Serializer attributes should be in alphabetical order (symbols first, then hashes)"- RESTRICT_ON_SEND =
%i[attributes serializer_attributes].freeze
Instance Method Summary collapse
Instance Method Details
#on_send(node) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/rubocop/cop/teamtailor/alphabetical_serializer_attributes.rb', line 12 def on_send(node) return unless node.arguments.any? return unless in_serializer_class?(node) args = node.arguments sorted_args = sort_arguments(args) return if args_match?(args, sorted_args) add_offense(node) do |corrector| corrector.replace(arguments_range(node), format_arguments(sorted_args, node)) end end |