New code period is set before first analysis... but issues are not computed on new code

Hi all and merry christmas to all community members!

I need to clarify how new code period works when it is set before the first analysis of one project in SonarCloud.

This is the scenario:

  • We have set a new period that is an specific date (let’s say February, 1, 2022) for all the projects on the organization.
  • A new project is created today (December, 16) and added into SonarCloud.
  • Source code was committed on November, and as the SCM information is being shared with SonarCloud, the issues have created with the right date (the date when the line of code was committed to SCM). Let’s say November, 20).
  • SonarCloud is detecting the issues and issue dates are correct (November, 20).
  • The problem is that the issues are not marked on the new code section, only on overall code. But they were injected in the code in November, after the new code period, that is February.

It seems that because the project was created in December, SonarCloud is not computing anything between February and December, even when there are lines of code and issues committed in November, because SonarCloud is not considering the source files as new (they were created before the first analysis).

Is that the expected behavior? Could you please help me to understand how it works?

Thank you very much!

Hey there.

This is the expected behavior – SonarCloud won’t go back and classify files as old/new on the first scan based on that date. That first scan becomes the “baseline” – after which everything is considered new.

So if February 1, 2022 is the specified date and the first analysis is on December 16, 2022… the real start of the New Code Period is December 16, 2022.

Hi Colin!

Thank you so much for your quick response.

If that is the expected behavior then I suggest to change the UI to display the real start of the new code period for that project.

It doesn’t make sense for me that the UI keeps showing February, 1, or March 1, 2022, when the the real start of the New Code Period is December 16, 2022:

Is it possible for SonarCloud to automatically set the new code period with the date of the first scan that becomes the baseline (if first scan is after the new code period)?

We don’t want to see a “false” new code period on the UI, we want to see the real start of the new code period.

Could you please try to review this to improve the user experience? Now we know that under this situation and to avoid any misunderstanding we should set the new code period for the project manually to the first scan date, but it will be better if SonarCloud set it automatically.

Thanks!