Cop/RedirectWithStatus: Stop checking location programmatically
What does this MR do and why?
Use RuboCop's Include directive instead. With this the cop is now also
inspecting controller concerns (not ending with _controller.rb).
This commit also refactors to cop to use the RESTRICT_ON_SEND
optimization and improves code coverage.
Coverage
| Before 99.83% | After 100% |
|---|---|
| https://gitlab.com/gitlab-org/ruby/gems/gitlab-styles/-/jobs/3601473389 | https://gitlab.com/gitlab-org/ruby/gems/gitlab-styles/-/jobs/3604019751 |
Test on gitlab-org/gitlab
Because we now also check controller concerns we got us two offenses when inspecting gitlab-org/gitlab.
$ bundle exec rubocop -C false --only Cop/RedirectWithStatus app/controllers/ ee/app/controllers/
Inspecting 704 files
.........................................................................................C........C.............................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................
Offenses:
app/controllers/concerns/issuable_actions.rb:100:21: C: Cop/RedirectWithStatus: Do not use "redirect_to" without "status" in "destroy" action.
format.html { redirect_to index_path }
^^^^^^^^^^^
app/controllers/concerns/membership_actions.rb:54:9: C: Cop/RedirectWithStatus: Do not use "redirect_to" without "status" in "destroy" action.
redirect_to members_page_url, notice: message
^^^^^^^^^^^
704 files inspected, 2 offenses detected
Edited by Peter Leitzen