Class: RuboCop::Cop::Sevencop::RailsRouteAs
- Inherits:
-
Base
- Object
- Base
- RuboCop::Cop::Sevencop::RailsRouteAs
- Defined in:
- lib/rubocop/cop/sevencop/rails_route_as.rb
Overview
Always use as option on routing methods.
Constant Summary collapse
- MSG =
"Always use `as` option on routing methods. Use `as: nil` if you don't need named routes."- RESTRICT_ON_SEND =
i[ delete get head patch post put ].freeze
Instance Method Summary collapse
- #on_send(node) ⇒ void (also: #on_csend)
Instance Method Details
#on_send(node) ⇒ void Also known as: on_csend
This method returns an undefined value.
30 31 32 33 34 35 36 |
# File 'lib/rubocop/cop/sevencop/rails_route_as.rb', line 30 def on_send(node) last_argument = node.last_argument return unless last_argument&.hash_type? return if last_argument.pairs.any? { |pair| pair.key.value == :as } add_offense(node) end |