java:S3516 Error detection

SonarQube version 9.7.1 (build 62043)

In my codes,a method is designed to return two values,One of them is null,another one is not null,like:

but you think these are the same value.

And in SonarLint 7.2.1.58118(IDEA) with the same rules as it,the same issue was not detected.

Hey there.

Thanks for your feedback! I’ve moved your post to the section on reporting a false-positive.

As noted in this thread:

Can you please provide a text-based code reproducer that raises the false-positive?

Thanks!

Hi,

I just came across the same FP. Here’s a very simple reproducer:

	public boolean something() {
		try {
			return true;
		} catch (RuntimeException e) {
			LOGGER.debug("no", e);
		}
		return false;
	}

image

Using SonarLint 7.4.0.60471 for IntelliJ.

Then calling something() also triggers java:S2589 which also thinks the returned value is always true.

Hello there, there is already a ticket for this, as it is a known issue. We will try to fix it as soon as it will be possible for us! You can track its progress here.