No coverage for New version

Hello, I have a problem with code coverage not being displayed for New code - Previous version.
Steps I did:

  1. Cloned a repo.
  2. Reverted the main branch to init commit to get v.1.0 (init of app, no coverage)
  3. Run the command:
sonar-scanner \
-Dsonar.cliOrganization=MYORG \
-Dsonar.organization=MYORG \
-Dsonar.cliProjectKey=MYORG_MYPROJ \
-Dsonar.projectKey=MYORG_MYPROJ \
-Dsonar.cliProjectName=MYPROJ \
-Dsonar.projectName=MYPROJ \
-Dsonar.cliProjectVersion=1.0 \
-Dsonar.projectVersion=1.0 \
-Dsonar.cliSources=src/ \
-Dsonar.sources=src/ \
-Dsonar.cliLanguage=js \
-Dsonar.language=js \
-Dsonar.javascript.lcov.reportPaths=coverage/lcov.info \
-Dsonar.javascript.node.maxspace=8192 \
-Dsonar.host.url=https://sonarcloud.io
  1. Reverted the main to some older commit.
  2. Run the scanner again with version parameter set to 1.3.
  3. Updated the main to the latest commit.
  4. Run the jest -coverage to gather metrics.
  5. Run the scanner again with version parameter set to 1.4.

And the problem is that under “New code” it shows that the new code in between of v.1.3 and v.1.4 has coverage with “-” and 0 new lines. But as I look for coverage at “Overall code” it shows coverage for whole project.

The problem is that we worked on covering the old code and new code with tests and that we require the metric to show it for the “New code” only (that was added under src/ folder between v.1.3 and 1.4).
At the activity tab I see it properly tagged with versions.

I tried playing with different params, but without luck.

  • ALM used: Azure DevOps
  • CI system used: None - running from dev-box

Ok, in some post I read that I should play with
-DprojectDate… but that brings another question - how?!

I already have an analysis that is later in time than the one in past I want to make… and you cannot delete it.

Ok, I solved this issue by creating new long living branch by -D sonar.branch.name parameter with -D sonar.projectDate chronologically starting with the oldest releases… so that has built me the proper “history” of changes and “New version” returned metrics.

But… I would like to know if there is any official way for importing existing releases to the Sonar Cloud to have it properly structured on the main… besides deleting whole project and starting again from scratch. Deleting is not an option as this is managed by others.