-
-
Notifications
You must be signed in to change notification settings - Fork 270
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add new Rails/UnusedRenderContent cop #970
Conversation
86fe4df
to
fac79f3
Compare
@@ -1096,6 +1096,11 @@ Rails/UnusedIgnoredColumns: | |||
Include: | |||
- app/models/**/*.rb | |||
|
|||
Rails/UnusedRenderContent: | |||
Description: 'Do not specify body content for a response with a non-content status code.' | |||
Enabled: pending |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add Severity: warning
because this looks like a Lint-equivalent rule.
+ Severity: warning
# This cop checks for uses of `render` which specify both body content and a non-content status. | ||
|
||
# @example |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#
required.
# This cop checks for uses of `render` which specify both body content and a non-content status. | |
# @example | |
# This cop checks for uses of `render` which specify both body content and a non-content status. | |
# | |
# @example |
2356123
to
25901bc
Compare
Thanks for your feedback, @koic. I have addressed both comments. I also rebased onto latest |
@samrjenkins Yeah, looks good to me. Can you squash these commits into one? |
25901bc
to
8555ac5
Compare
@koic done 👍 |
Thanks! |
Issue: #967
The Rails documentation states:
https://guides.rubyonrails.org/layouts_and_rendering.html
On a number of occasions I have seen controller actions containing code such as:
In cases such as these, the specified content for the response body is ignored and the code should be refactored to:
This pull request introduces a cop which identifies instances of unused body content.
Before submitting the PR make sure the following are checked:
[Fix #issue-number]
(if the related issue exists).master
(if not - rebase it).bundle exec rake default
. It executes all tests and runs RuboCop on its own code.{change_type}_{change_description}.md
if the new code introduces user-observable changes. See changelog entry format for details.