Class: RuboCop::Cop::Rails::UnusedRenderContent
- Inherits:
-
Base
- Object
- Base
- RuboCop::Cop::Rails::UnusedRenderContent
- Includes:
- RangeHelp
- Defined in:
- lib/rubocop/cop/rails/unused_render_content.rb
Overview
If you try to render content along with a non-content status code (100-199, 204, 205, or 304), it will be dropped from the response.
This cop checks for uses of ‘render` which specify both body content and a non-content status.
Constant Summary collapse
- MSG =
'Do not specify body content for a response with a non-content status code'
- RESTRICT_ON_SEND =
%i[render].freeze
- NON_CONTENT_STATUS_CODES =
Set[*100..199, 204, 205, 304] & ::Rack::Utils::SYMBOL_TO_STATUS_CODE.values
- NON_CONTENT_STATUSES =
Set[ *::Rack::Utils::SYMBOL_TO_STATUS_CODE.invert.fetch_values(*NON_CONTENT_STATUS_CODES) ]
- BODY_OPTIONS =
Set[ :action, :body, :content_type, :file, :html, :inline, :json, :js, :layout, :plain, :raw, :template, :text, :xml ]
Instance Method Summary collapse
Instance Method Details
#on_send(node) ⇒ Object
59 60 61 62 63 |
# File 'lib/rubocop/cop/rails/unused_render_content.rb', line 59 def on_send(node) unused_render_content?(node) do |unused_content_node| add_offense(unused_content_node) end end |