New Code setup not working properly

  • We are using: Enterprise Edition Version 9.9.2 (build 77730)
  • I have set the New Code configuration 160 days.
  • Projects created and analyzed many times in April 2024 do not show anything on the new code tab anymore only on the Overall Code. I want to treat all the code created this year as new code.
  • I have tried to execute reanalyze again but it does not pick it up.

Hi,

Welcome to the community!

You’re not going to have any new code on first analysis. However, everything changed after that first analysis will be recognized as new code.

Unfortunately, the New Code period for main / a branch exists only in SonarQube, and does not work by reading your SCM data to the extent of determining what was updated in the 160 days before first analysis.

 
Ann

so the 160 days are counted for all the code analyzed in that time period except the code from the initial analysis?

Hi,

Your first analysis is day 0. Everything added/edited after that is “new” (until it ages out of your rolling New Code period).

 
HTH,
Ann

hi,

is there a way to analyze existing project and add all the code as new code? Or this needs to be two step process to analyze the project with no code and then with code?

thanks,
Mart

Hi Mart,

Yes, that would work - the two step process. But why?

There’s a reason we segregate new code from old - so you’re not faced with the burden of feeling like you have to clean up everything in a legacy project.

 
Ann

hi,
thanks for the answer but like I said originally, we want to treat every line of code created this year as new code as we transition to the “clean as you code” process.
Mart

Hi Mart,

If you really want to pursue this, then what you can do is

  • delete your projects
  • check out the 1Jan state of the code
  • analyze with sonar.projectDate=2024-01-01
  • resume normal analyses

Sorry I didn’t think of this before. But that accurately sets up your step 1 of the two-step process without putting everything into the New Code period.

 
HTH,
Ann

hi,
thanks, will do that this way.
Mart

1 Like