Class: RuboCop::Cop::Rails::RequestReferer
- Inherits:
-
Base
- Object
- Base
- RuboCop::Cop::Rails::RequestReferer
- Extended by:
- AutoCorrector
- Includes:
- ConfigurableEnforcedStyle
- Defined in:
- lib/rubocop/cop/rails/request_referer.rb
Overview
Checks for consistent uses of ‘request.referer` or `request.referrer`, depending on the cop’s configuration.
Constant Summary collapse
- MSG =
'Use `request.%<prefer>s` instead of `request.%<current>s`.'
- RESTRICT_ON_SEND =
%i[referer referrer].freeze
Instance Method Summary collapse
Instance Method Details
#on_send(node) ⇒ Object
33 34 35 36 37 38 39 40 41 |
# File 'lib/rubocop/cop/rails/request_referer.rb', line 33 def on_send(node) referer?(node) do return unless node.method?(wrong_method_name) add_offense(node) do |corrector| corrector.replace(node, "request.#{style}") end end end |