private static int method(int alwaysGreaterThanZero) {
if (alwaysGreaterThanZero < 1)
return 0;
int result = 0;
for (int i = alwaysGreaterThanZero; i > 0; --i)
result += alwaysGreaterThanZero;
return (0 / result);
}
This gives
Zero should not be a possible denominator
while result won’t be ever zero, because alwaysGreaterThanZero will be always greater than zero, so loop will be executed at least once.
Indeed, we do not have plans for the near future to fix this false positive.
You can resolve the issue as ‘False Positive’ in SonarQube (see issue lifecycle). For this, you need to have “Administer Issues” permission in SonarQube, see our documentation.
That doesn’t help.
That was not accident that I tagged this topic sonarlint.
So it’s about SonarLint and from what I know, I can just use // NOSONAR (as much as I don’t like it).
Or deactivate rule.