Class: RuboCop::Cop::Rails::RenderPlainText
- Inherits:
-
Base
- Object
- Base
- RuboCop::Cop::Rails::RenderPlainText
- Extended by:
- AutoCorrector
- Defined in:
- lib/rubocop/cop/rails/render_plain_text.rb
Overview
Identifies places where ‘render text:` can be replaced with `render plain:`.
Constant Summary collapse
- MSG =
'Prefer `render plain:` over `render text:`.'
- RESTRICT_ON_SEND =
%i[render].freeze
Instance Method Summary collapse
Instance Method Details
#on_send(node) ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/rubocop/cop/rails/render_plain_text.rb', line 37 def on_send(node) render_plain_text?(node) do |, option_node, option_value| content_type_node = find_content_type() return unless compatible_content_type?(content_type_node) add_offense(node) do |corrector| = .pairs - [option_node, content_type_node].compact corrector.replace(node, replacement(, option_value)) end end end |