S1186 running on Test scope generates almost only false-positives in GoLang

Hello,

S1168 detects empty method/function blocks, but when writing a test you often write stubs, and you might be fine with having some methods of those stubs empty. This does not require a comment to explain, it’s normal for a test stub.

The added value of the rule in the Test scope seems minimal, while the amount of false positives raised is massive. Previously this rule was on Main scope only, which was perfectly fine. To lower the number of false positives in tests, the rule should at least detect stubs and other kinds of test-doubles and exclude them.

Language : Go (but this applies to most languages)

Environment : Sonarcloud

Reproducing : Just create a test with an empty function/method in it

Hello @inverno,

thanks for raising this issue!

We’ll look into the rule you mentioned to see if we can either improve it to be less noisy for test files or remove it from the test scope completely.
It will be included in the next release of the Go analyzer on SQC, so should not take that long to be resolved.

Best
Jonas

1 Like

@inverno

Good news, we just deployed a new version of the Go analyzer on SQC, which only runs S1186 on Main files and will spare test files.

Let me know if you experience any issues with this!

Best