muii
(木易什么来着)
December 16, 2022, 2:30am
1
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.
Colin
(Colin)
December 19, 2022, 9:11am
2
Hey there.
Thanks for your feedback! I’ve moved your post to the section on reporting a false-positive.
As noted in this thread:
Hey SonarSource Community!
False-positives happen , as do false-negatives, and we’re eager to fix them. We are thrilled when our users report problems, so we can make our products better.
What is a false-positive (FP)?
A false-positive is when an issue is raised unexpectedly on code that should not trigger an issue, or where the suggested action doesn’t make any sense for the code.
What is a false-negative (FN)?
A false-negative is when an issue should be raised on a piece of code, but isn’t…
Can you please provide a text-based code reproducer that raises the false-positive?
Thanks!
bjansen
(Bastien Jansen)
February 1, 2023, 1:23pm
3
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;
}
Using SonarLint 7.4.0.60471 for IntelliJ.
bjansen
(Bastien Jansen)
February 1, 2023, 2:04pm
4
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 .