Overall Code Smells as New Code Smells

  • SonarQube Developer Edition Version 8.5.1
    I have a Java project with a custom Quality Gate which has one condition on New Code (code smells). I configured the master branch as reference for New Code. The problem occures when analyzing the test branch. For example, I have the same code in both test and master branches with 61 Code Smells. I commit some changes to the test branch (by adding 10 System.out.println() lines in a new class which are interpreted as Code Smells). I’m starting the analysis in test branch. My intuition tells me that number of New Code smells should be 10 and Overall Code Smells should be 71 but this numbers are the same (71). The interesting fact is that when I set the previous version as a specific setting then everything works fine. I mean, I have the same code in both branches. Next I increase the build version and put some changes in the test branch. I start the analysis and the result shows only 10 New Smell Codes.

Hi @marioncobretti,

I could not reproduce your error. I’m confused by this sentence:

Overall Code Smells should be 71 but this numbers are the same (71)

You mean that, New Code also shows 71 Code Smells? I would expect it to show either 0, or 10. If it shows the same as Overall, then perhaps your initial analysis had an issue.

Could you try the following:

  1. Make sure master is analyzed with the latest version of your code.
  2. Create a new branch from master (say, test-2)
  3. Introduce 10 new Code Smells in test-2
  4. Analyze test-2
  5. On SonarQube, you should see only values on Overall for test-2 (71 Code Smells). Go to the New Code settings page, and make master a reference branch for test-2.
  6. Re-analyze test-2 (you shouldn’t have to change any code)
  7. On SonarQube, the New Code period should now correctly show 10 Code Smells, and Overall should have 71

Does it work?