Template for a good new topic, formatted with Markdown:
ALM used: Bitbucket Cloud
CI system used: Bitbucket Cloud
Scanner command used when applicable
Languages of the repository: Go
Error observed: None
Steps to reproduce: None
Potential workaround
Remove sonar.tests from sonar-project.properties
Add sonar.exclusions=**/*_test.go into sonar-project.properties
Do not share screenshots of logs – share the text itself (bonus points for being well-formatted)!
Started last week, we are observed there is a behavioral changes in our Golang repositories.
On all our PR scan, suddenly we saw surge of code smells pop out from our go test file. After looking into details, the rule that violated is supposedly only to being used at main sources and not test files.
You list removing sonar.tests as a workaround. Does that mean you’ve tired it? That only when the files are explicitly listed as tests are they 1) picked up and 2) scanned with this rule?
Can you provide your analysis log?
The analysis / scanner log is what’s output from the analysis command. Hopefully, the log you provide - redacted as necessary - will include that command as well.
Yes we already tried it. Originally our properties file will have sonar.tests properties and it is able to pick up the test file, however since last week all of the file is being scanned with Rules that supposed only for Main Source (not including test file) that you can see on the screenshot (rule go:S1192)
From my understanding rule mentioned above should not being scanned for test file (because it is never do before last week, and it is failing across all of our go repository)
This is small snapshot of the log before we do the workaround, I will try to get the full log if possible from my end.
Thanks for the log snippet. That’s already very helpful. This sounds like a rule behavior change, and I’m not easily finding any announcements related to that. I’ve flagged this for the language experts, but please do keep digging for your full analysis log in case they need it.