Hi Michael,
yes, Java,
yes, latest version as you stated (4.14.0.11784 - in another Eclipse I use SonarLint 3.2.0.2101706271328 which seems to use the same rule implementation).
Only
difference in my code: class is public, not abstract, and checkRule is
private, not default in my setting (but I get the issue also when it's
default), and I can also omit doSomething(); (i.e. have an empty try
block).
The funny thing is: when I put it as the only method in my
class, I don't get this false positive, if I put it as one of many
methods in an arbitrary class, I get that issue, even I don't call that
method there.
So, I can get an issue, if I put the following piece of code in an arbitrary class as long as there's a bunch of other methods in the class - I don't have an idea what's exactly necessary - just try to put it in a bigger class you have at hand.
boolean checkFalseRule()
{
try
{
}
catch(Exception exc)
{
return false;
}
return true;
}
I get an issue about an empty code block and that false positive here (in the original code there's some code in the try block, and I get only the false positive).
For a second, I thought that SonarJava might check if the catch-block could be reached - but then, the issue would have also come if it's the only method in a class, so there must be something else.
My suggestion: put that small method in some bigger class and you'll get that issue - I tried a few with 500+ lines, and always got that false positive.
Thanks, see you,
Stefan.