Skip to content

Commit

Permalink
Refine an example for "Suppressing Exceptions" rule
Browse files Browse the repository at this point in the history
Follow up of rubocop/rubocop#7805 (comment).

This PR refines an example for "Suppressing Exceptions" rule.

And `do_something rescue nil` will be changed from bad case to good case
based on RuboCop (0.81)'s behavior and the comment below.
rubocop/rubocop#7297 (comment)
  • Loading branch information
koic authored and bbatsov committed Mar 20, 2020
1 parent cf24267 commit 3a20519
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions README.adoc
Expand Up @@ -1813,12 +1813,25 @@ Don't suppress exceptions.
----
# bad
begin
# an exception occurs here
do_something # an exception occurs here
rescue SomeError
# the rescue clause does absolutely nothing
end
# bad
# good
begin
do_something # an exception occurs here
rescue SomeError
handle_exception
end
# good
begin
do_something # an exception occurs here
rescue SomeError
# Notes on why exception handling is not performed
end
# good
do_something rescue nil
----

Expand Down

0 comments on commit 3a20519

Please sign in to comment.