This rule enforces the use of render plain: syntax in Ruby on Rails applications instead of the render text: syntax. This is because render text: defaults to rendering the MIME type as text/html, which may not always be the desired outcome. On the other hand, render plain: explicitly renders the MIME type as text/plain.
By using render plain:, the developer is being explicit about the MIME type that is being rendered, which can prevent potential issues down the line. It is especially crucial when working with text that should not be interpreted as HTML.
To adhere to this rule, simply replace any instances of render text: with render plain:. If the content type needs to be specified, it can be done so directly within the render plain: call, e.g., render plain: 'foo', content_type: 'text/plain'.
Non-Compliant Code Examples
# default MIME of `text/html`rendertext:'foo'# can simplify with plainrendertext:'bar',content_type:'text/plain'
Compliant Code Examples
renderplain:'foo'
シームレスな統合。 Datadog Code Security をお試しください
Datadog Code Security
このルールを試し、Datadog Code Security でコードを解析する
このルールの使用方法
1
2
rulesets:- rails-best-practices # Rules to enforce Ruby best practices.