cushon / issues-import

0 stars 0 forks source link

Code review request: new check for "try { fail/assert } catch (Throwable)" code #180

Closed cushon closed 9 years ago

cushon commented 9 years ago

Original issue created by adamwos@google.com on 2013-08-28 at 09:38 AM


Link to code review: https://codereview.appspot.com/13252044/

Purpose of code changes: New check for "try { fail/assert } catch (Throwable)" code

A common pattern for testing for expected exceptions is to execute code in a try block, with a fail() or assert*() in the try, catching an expected exception.

However, if the catch clause catches Throwable, and doesn't do any verification (e.g. instanceof) of the caught object, such a test always passes.

This introduces a bug checker for the following code pattern:

try { // do something Assert.fail(); // or any Assert.assert* // maybe do something more } catch (Throwable t) { // empty or only comments }

It matches try blocks that contain an invocation of any static method named "fail" and starting with "assert" from the following classes:

cushon commented 9 years ago

Original comment posted by eaftan@google.com on 2013-08-28 at 06:22 PM


(No comment entered for this change.)


Status: Started Owner: eaftan@google.com

cushon commented 9 years ago

Original comment posted by eaftan@google.com on 2013-08-31 at 12:20 AM


(No comment entered for this change.)


Status: Done