google / google/error-prone

Automatically suppress false positive for BooleanParameter in JUnit assertEquals

Open
#868 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
7.2k
Forks
820
Avg merge
5h 9m
Merged PRs (30d)
50

Description

I've just hit this:

> [WARNING] /home/vorburger/dev/ODL/git/infrautils/common/util/src/test/java/org/opendaylight/infrautils/utils/concurrent/KeyedLocksTest.java:[90,40] [BooleanParameter] Use parameter comments to document ambiguous literals (see http://errorprone.info/bugpattern/BooleanParameter)
> Did you mean 'assertEquals("Thread isAlive", /* expected= */false, thread1.isAlive());'?

so a [BooleanParameter](http://errorprone.info/bugpattern/BooleanParameter) warning for:

assertEquals("Thread isAlive", false, thread1.isAlive());

but that proposed `/* expected= */` would be just visual noise IMHO - `assertEquals` is a well enough known that this is pretty clear as is... perhaps this could somehow be added to the automatic supression list?

PS: Unfortunately in JUnit 4 at least (have not checked JUnit 5) there is no assertEquals(boolean expected, boolean actual) but that uses assertEquals(Object expected, Object actual) - not sure if that makes white listing this any more difficult.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.