Warn about throwIfUnchecked(unchecked)
, which could be just throw unchecked
.
#4625
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.
Warn about
throwIfUnchecked(unchecked)
, which could be justthrow unchecked
.This was prompted by google/guava#7434, in which the correct fix was
throwIfUnchecked(unchecked.getCause())
. (Compare one other instance of that.) But most hits in practice appear to becatch (RuntimeException e) { throwIfUnchecked(e); }
, which isn't a bug, just unnecessary code (which can typically be further simplified sometimes as far as to remove thetry
-catch
block entirely, as suggested by the Google-internalRethrowException
check).This check could be written with Refaster (unknown commit), but:
throwIfUnchecked
, and placeholders can have slow runtime and won't remove code that has comments. (This check doesn't remove comments, either, but at least it will remove the code around them.)RuntimeException | Error e
, which comes up a couple times in our depot.