SonarGo: False positives on S1763 (dead code)

Steps to reproduce:

  1. Have a piece of Go code with a return inside an if.
  2. Have a statement after the if block.

Expected results:

  1. The rule go:S1763 does not fire on the statement after the if block.

Actual results:

  1. NOK: The rule go:S1763 does fire on the statement after the if block.

Versions used:

  • SonarQube 7.9.2 Community Edition
  • SonarGo 1.6.0

Hello @ernstdehaan, thanks for the feedback.

If I understand correctly, the reproducer could look like this:

func foo(isDefault bool) {
	if(isDefault) {
		return
	}
	fmt.Println("something")
}

This code does not raise an issue on SonarQube 8.1.

However, if I add a semi-column after the return (return;), an issue is raised.
Is it your case?
If yes, I found this ticket to track this FP, if not, can you provide the exact piece of code that raises the issue?

Best,
Quentin

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.