You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
My previously valid usage of # rubocop:disable Lint/SuppressedException is being flagged by the Lint/RedundantCopDisableDirective cop. Upon removing the rubocop:disable, the Lint/SuppressedException cop raises a violation again.
Expected behavior
My usage of rubocop:disable should not be flagged as a Lint/RedundantCopDisableDirective; it seems to be legitimately disabling the Lint/SuppressedException cop.
Actual behavior
My usage of rubocop:disable is flagged.
Steps to reproduce the problem
Create the file spec/dummy_spec.rb;
RSpec.describeDummydoit'dummy spec'do# This rescue is here to ensure the test does not fail because of the `raise`# rubocop:disable Lint/SuppressedExceptionexpect{beginsubject;rescueActiveRecord::Rollback;end}.not_to(change(Post,:count))# rubocop:enable Lint/SuppressedExceptionendend
Edit the file (to remove the apparently invalid rubocop:disable and rubocop:enable) as follows;
RSpec.describeDummydoit'dummy spec'do# This rescue is here to ensure the test does not fail because of the `raise`expect{beginsubject;rescueActiveRecord::Rollback;end}.not_to(change(Post,:count))endend
Re-run RuboCop as before;
➜ bundle exec rubocop spec/dummy_spec.rb
spec/dummy_spec.rb:4:29: W: Lint/SuppressedException: Do not suppress exceptions.
expect { begin subject; rescue ActiveRecord::Rollback; end }.not_to(change(Post, :count))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1/1 file |====================================================================== 100 ======================================================================>| Time: 00:00:00
1 file inspected, 1 offense detected
RuboCop version
This has occurred since updating to RuboCop 0.81, and continues in RuboCop 0.82. It did not occur for RuboCop 0.80. Haven't had a chance to bisect the exact commit where it was introduced (but happy to if the cause isn't clear).
To avoid false negatives for single line rescue statements with a
comment on the next line, we look for comments, not on the line
after rescue, but one lines between rescue and the corresponding
end.
My previously valid usage of
# rubocop:disable Lint/SuppressedException
is being flagged by theLint/RedundantCopDisableDirective
cop. Upon removing therubocop:disable
, theLint/SuppressedException
cop raises a violation again.Expected behavior
My usage of
rubocop:disable
should not be flagged as aLint/RedundantCopDisableDirective
; it seems to be legitimately disabling theLint/SuppressedException
cop.Actual behavior
My usage of
rubocop:disable
is flagged.Steps to reproduce the problem
Create the file
spec/dummy_spec.rb
;Run RuboCop on the file and observe output;
Edit the file (to remove the apparently invalid
rubocop:disable
andrubocop:enable
) as follows;Re-run RuboCop as before;
RuboCop version
This has occurred since updating to
RuboCop 0.81
, and continues inRuboCop 0.82
. It did not occur forRuboCop 0.80
. Haven't had a chance to bisect the exact commit where it was introduced (but happy to if the cause isn't clear).The text was updated successfully, but these errors were encountered: