-
-
Notifications
You must be signed in to change notification settings - Fork 263
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 Rails/ActionControllerFlashBeforeRender
cop
#759
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
koic
reviewed
Aug 29, 2022
koic
reviewed
Aug 29, 2022
koic
reviewed
Aug 29, 2022
koic
reviewed
Aug 29, 2022
koic
reviewed
Aug 29, 2022
koic
reviewed
Aug 29, 2022
koic
reviewed
Aug 29, 2022
koic
reviewed
Aug 29, 2022
americodls
force-pushed
the
flash-before-render
branch
2 times, most recently
from
August 29, 2022 07:58
bd1d63d
to
da3f7ef
Compare
Is there any way to scope it only to Rails controllers 🤔? |
americodls
force-pushed
the
flash-before-render
branch
2 times, most recently
from
August 29, 2022 23:40
e625a35
to
b697f90
Compare
I added some changes to make the cop more specific and tidied up the tests. |
koic
reviewed
Aug 30, 2022
koic
reviewed
Aug 30, 2022
spec/rubocop/cop/rails/action_controller_flash_before_render_spec.rb
Outdated
Show resolved
Hide resolved
koic
reviewed
Aug 30, 2022
spec/rubocop/cop/rails/action_controller_flash_before_render_spec.rb
Outdated
Show resolved
Hide resolved
americodls
force-pushed
the
flash-before-render
branch
from
August 30, 2022 23:17
b697f90
to
51eeee2
Compare
americodls
force-pushed
the
flash-before-render
branch
from
August 30, 2022 23:21
51eeee2
to
469025e
Compare
Thanks! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR suggests a new Cop for detecting
flash
assignment beforerender
a page (the correct approach would be to assign a message toflash.now
(check on rails guides) .This is a common mistake in Ruby on Rails, and it is easy to fall into this trap the flash will be rendered on the page. But the flash message still persisted and will show up on the following redirect.
This is an example of that issue: rubygems/rubygems.org#3149
Solved here: rubygems/rubygems.org#3198
This is a very simple version but helped me to find more 6 issues on that project.
I hope I can receive some suggestions on how to improve this solution.
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.