Class: RuboCop::Cop::Sevencop::RailsRouteOrdered
- Inherits:
-
Base
- Object
- Base
- RuboCop::Cop::Sevencop::RailsRouteOrdered
- Extended by:
- AutoCorrector
- Includes:
- RangeHelp
- Defined in:
- lib/rubocop/cop/sevencop/rails_route_ordered.rb
Overview
Sort routes by path and HTTP method.
Constant Summary collapse
- MSG =
'Sort routes by path and HTTP method.'
- RESTRICT_ON_SEND =
%i[ delete get head options patch post put ].freeze
Instance Method Summary collapse
Instance Method Details
#on_send(node) ⇒ void
This method returns an undefined value.
43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/rubocop/cop/sevencop/rails_route_ordered.rb', line 43 def on_send(node) previous_older_sibling = find_previous_older_sibling(node) return unless previous_older_sibling add_offense(node) do |corrector| corrector.swap( range_with_comments_and_lines(previous_older_sibling), range_with_comments_and_lines(node) ) end end |