Class: RuboCop::Cop::Rails::HttpStatus
- Inherits:
-
Base
- Object
- Base
- RuboCop::Cop::Rails::HttpStatus
- Extended by:
- AutoCorrector
- Includes:
- ConfigurableEnforcedStyle
- Defined in:
- lib/rubocop/cop/rails/http_status.rb
Overview
Enforces use of symbolic or numeric value to define HTTP status.
Defined Under Namespace
Classes: NumericStyleChecker, SymbolicStyleChecker
Constant Summary collapse
- RESTRICT_ON_SEND =
%i[render redirect_to head assert_response assert_redirected_to].freeze
Instance Method Summary collapse
Instance Method Details
#on_send(node) ⇒ Object
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
# File 'lib/rubocop/cop/rails/http_status.rb', line 67 def on_send(node) http_status(node) do |hash_node_or_status_code| status = if hash_node_or_status_code.hash_type? status_code(hash_node_or_status_code) else hash_node_or_status_code end return unless status checker = checker_class.new(status) return unless checker.offensive? add_offense(checker.node, message: checker.) do |corrector| corrector.replace(checker.node, checker.preferred_style) end end end |