Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handling of assert #166

Closed
Maaartinus opened this issue Aug 5, 2017 · 1 comment
Closed

Handling of assert #166

Maaartinus opened this issue Aug 5, 2017 · 1 comment

Comments

@Maaartinus
Copy link

I'm getting RCN_REDUNDANT_NULLCHECK_OF_NONNULL_VALUE on

	assert started != null;
	if (started == null) ...

which is obviously wrong as assertions may be on or off. And no, this is no misuse of assertions.(*)

In production, assert is off, everywhere else it's on, which works like additional testing. So there are two versions of the code to be analyzed at the same time. When the null check makes sense in either version, then it's not redundant.


(*) I'm using Preconditions where they're needed and asserts where the tests are either too expensive or too unimportant. In this case, I believe that started is always set, but if it isn't, I'm surprised, but willing to live with it (it's a logging-only variable in a concurrent code).

@iloveeclipse
Copy link
Member

This project continues development in a new home: https://github.com/spotbugs/spotbugs/

Please do not open new issues here anymore!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants