Hi
We just convert our main project to be a monorepo.
We expected after switching that the only analysis taken in consideration when counting line of codes will be the subprojects, but we see that the old analysis of the all project are still taken counted and so we are getting to the limit and cannot get the scan results.
How can we remove the old analysis that we don’t want to be taken in consideration anymore when counting line of code ?
You’ll need to make sure that for each project, you’ve successfully adjusted the analysis scope to only consider files in the appropriate sub-project. Typically this is done by adjusting sonar.sources.
Hi @Colin thanks for the answer.
I don’t see how it is related, I am probably missing something but as I see it when converting a project to be a monorepo the all project line count should be set to zero no ?
Even if set properly the paths the previous count before converting is still in place no ?
Anyway I checked and I set properly the paths (also I tried by specifying the dir property)
I’d suggest including some screenshots and snippets of your configuration so we can better understand what’s going on (what’s not being excluded that you expect to be). The more details you share, the more helpful we can be.
Keep in mind that on your initial project (the one which was converted to a monorepo, to which you can now add new projects), you will always see the history of the project unless you actually the project. However this has nothing to do with license utilization – only the most recent analyses are taken into account (SonarCloud counts the largest branch of your project, so if you have some old branches lying around, that could explain it)
I think we will remove the project completely and create it from scratch as Monorepo.
In order to support backward compatibility we created an extra sonar subproject to the Monorepo and we named it subprojectApp we change the global token and variable in the CI for old branches to report in prev mode to it.
Just to clarify our configuration:
Before:
App
subProjectA
subProjectB
subProjectC
Before:
We had a step in CI that was running all subproject tests + sonar scan pipe
We used to see the result in sonar under App project
After
We run test + sonar in parallel steps for each subproject and we report to sonar with each subproject key we generated
When we check the line-count in sonar-cloud we see
App - ±300K line of code
subProjectA - ±250K line of code
subProjectB - ±30K line of code
subProjectC - ±20K line of code
subprojectApp - ±300K line of code
So sonar is reporting ±900K line of code - and I wonder why the 370K of the App is still counting.
Anyway thanks for the help in case the deletion and the creation will not work I will probably post new questions so thanks ahead!!
We’re just going through this pain now, thanks for asking this question. I conclude from the lack of follow-up that deleting and recreating the projects did the trick? I’m about to do this myself.
My current feeling about SonarCloud is that monorepo support is cludgy and has been bodged in without thinking through all the consequences. It shouldn’t be necessary for us to laboriously delete and recreate projects if monorepos were a first-class citizen in the first place. It would also be good to be able to delete the history from a project rather than have to delete and recreate it.