Must-share information (formatted with Markdown):
I’m currently using SonarQube Version 8.9.1 (build 44547) and sonar-scanner, sonar-scanner-cli-126.96.36.1993
We are using Teamcity to Analyze our code and perform analysis through sonar-scanner and further sends the data to sonarqube server for validating against the quality gate
We have created a custom QualityGate for our projects which applies to new code and the following are the conditions of the quality gate
The problem we are facing is, post analysis of the new code, our quality gate is failing with reason stating “3 critical issues”, but in the issue count section under new code category we are seeing “0 issues”
If we click on that “3 critical issues” we are navigated to issues page and it shows “we couldn’t find any matching results”
Welcome to the community!
Thanks for including the screenshots; they’re very helpful. In fact, while your project has 0 new Bugs, and 0 new Vulnerabilities, it does have new issues: Code Smells. Five of them. And it looks like 3 of them are Critical.
Rather than raw issue counts, I suggest you use ratings in your Quality Gate. For Bugs and Vulnerabilities, I guess you’re looking for a rating of C or better (you get a D if you have Critical issues of those types). The metric definitions may help.
Thank you so much for your quick response.
I was so focused on the bugs & vulnerabilities that i didnt realize code smells are categorized as issues too. Thanks for the suggestions on moving to rating system rather than count, it makes sense to go via rating.
I have a follow-up question though, after clicking on the ‘5 new code smell’ issues the screen redirects me to issues page but those 5 issues are not displayed, what could be the reason for that?
Though the quality gate on new code has failed just 2 days back, when i see the issues page without filter, i see no new issues have been reported in the last 2 days, all of them are two months old. So how did it find out 5 new code smells in the new code?
Can you try nudging the Creation Date filter back just a little bit? I think there might be a glitch there. Or are you saying that all of your Code Smells are 2mo old?
Thanks for your continued support
So i tried what you told me(take the filter back a little bit) but the result is same, no records are getting displayed. And all the code smells displayed under ‘Issues’ tab are from 2 months old.
I did some further digging and found that the origin of the 5 code smells that are getting displayed.
Under ‘Measures’ Tab, in ‘Maintainability’ category i can see those 5 code smells being displayed for New code
Surprisingly the same 5 code smells are not displayed under Issues tab when ‘New Code’ filter is put up. To add to that, when I checked those code smells from the measures tab, the date on them is shown as ‘2 months old’, so they are displayed under Issues tab, just not under New code filter.
As far as i was aware, the ‘New code’ only checks the difference between current code and the code in the build analyzed before this, so basically T and T-1 should be compared. Is that understanding correct or does the New code terminology is different and configurable?
So… if you don’t have any code smells newer than 2 months old, let’s take a look at the issues you do have. Are they all from different rules or is there a pattern?
Also, I’m looking back at your initial screenshot & it looks like we’re dealing with a branch that has another branch as the New Code Period reference. Can you verify whether or not the Code Smells in question also appear in the reference branch?
I’m really sorry that it took me a while to get back with the info.
Though the branch was same between the previous and current result, on a subsequent analysis run, our code smells went away. so we are good for now and we can close this thread.
Thanks again for your help & swift response.
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.