I believe this screen shot says it all: the case
has four lines only but Sonar claims it has six.
I believe it gets confused by switch blocks where the opening and closing brackets are also counted as code lines.
I believe this screen shot says it all: the case
has four lines only but Sonar claims it has six.
I believe it gets confused by switch blocks where the opening and closing brackets are also counted as code lines.
I’ve moved your post to the category for reporting false-positives.
Can you please update your post with the information requested in the post above? Specifically the rule ID, and a text based sample of code (no screenshots).
Here’s a snippet that causes a false-positive for java:S1151
:
switch (op.toLowerCase(Locale.US)) {
case "add" -> {
if (user == null) {
throw new SCIMException(400, "User does not exist.");
}
user.addGroup(group);
}
case "remove" -> {
if (user != null) {
user.removeGroup(group);
}
}
default -> throw new SCIMException(400, "Patch operation is not allowed for members");
}
Hi @sithmein,
After testing and some investigation, this is indeed a FP.
I created a ticket for it and you can track progress here: [SONARJAVA-4919] - Jira
All the best,
Irina