Class: RuboCop::Cop::Betterment::ImplicitRedirectType
- Inherits:
-
RuboCop::Cop
- Object
- RuboCop::Cop
- RuboCop::Cop::Betterment::ImplicitRedirectType
- Defined in:
- lib/rubocop/cop/betterment/implicit_redirect_type.rb
Overview
Require explicit redirect statuses in routes.rb. Permanent redirects (301) are cached by clients, which makes it difficult to change later, and/or reuse the route for something else.
Constant Summary collapse
- ROUTES_FILE_NAME =
'routes.rb'
- MSG =
'Rails will create a permanent (301) redirect, which is dangerous. ' \ 'Please specify your desired status, e.g. redirect(..., status: 302)'
Instance Method Summary collapse
Instance Method Details
#on_block(node) ⇒ Object
48 49 50 51 52 53 54 |
# File 'lib/rubocop/cop/betterment/implicit_redirect_type.rb', line 48 def on_block(node) return unless routes_file? if (node) { || .none? { |n| valid_status_option?(n) } } || (node) add_offense(node) end end |
#on_send(node) ⇒ Object
56 57 58 59 60 61 62 |
# File 'lib/rubocop/cop/betterment/implicit_redirect_type.rb', line 56 def on_send(node) return unless routes_file? if (node) { || .none? { |n| valid_status_option?(n) } } || (node) add_offense(node) end end |