Class: RuboCop::Cop::Rails::MultipleRoutePaths
- Inherits:
-
Base
- Object
- Base
- RuboCop::Cop::Rails::MultipleRoutePaths
- Extended by:
- AutoCorrector
- Includes:
- RuboCop::Cop::RoutesHelper
- Defined in:
- lib/rubocop/cop/rails/multiple_route_paths.rb
Overview
Checks for mapping a route with multiple paths, which is deprecated and will be removed in Rails 8.1.
Constant Summary collapse
- MSG =
'Use separate routes instead of combining multiple route paths in a single route.'- RESTRICT_ON_SEND =
HTTP_METHODS- IGNORED_ARGUMENT_TYPES =
%i[array hash].freeze
Constants included from RuboCop::Cop::RoutesHelper
RuboCop::Cop::RoutesHelper::HTTP_METHODS
Instance Method Summary collapse
Methods included from RuboCop::Cop::RoutesHelper
Instance Method Details
#on_send(node) ⇒ Object
26 27 28 29 30 31 32 33 34 35 |
# File 'lib/rubocop/cop/rails/multiple_route_paths.rb', line 26 def on_send(node) return unless within_routes?(node) route_paths = node.arguments.reject { |argument| IGNORED_ARGUMENT_TYPES.include?(argument.type) } return if route_paths.count < 2 add_offense(node) do |corrector| corrector.replace(node, migrate_to_multiple_routes(node, route_paths)) end end |