Code on branch does not match the code of the main branch

With Azure DevOps repository build, the code section on the branch is empty with the branch that is base on the main branch.
How can we explain that? We use branch to check the exclusion filter. Now it is not possible to compare if we add wrong exclusion or not. That make feel that when we do some sonar.sources change that sources path is not not working anymore as code on branch is empty but in fact the lines of code analyzed were the same.

Hey there.

Have you run an analysis on your main branch (running the CI with SonarCloud analysis on you rmain branch), or perhaps only a Pull Request or some secondary branch so far?

Hi Colin,
I run SonarCloud analysis on the main branch first. Then I create a feature branch base on the main one.
Run the analysis on the feature branch to see if we have the same number of lines.
The result is that the tab code is empty.
I expected to see same number of lines. Unfortunately the code tab is only for the changed lines.
I’m looking for a way to check line number effect and the code part that stay when we change the exclusion filter, sonar.sources and sonar.projectBaseDir.
I did not find how to manage that. The only way to see the number of lines is to commit directly into the main branch as on the code tab on branch there is no info that cover whole code. Not the best way doing lot of try by committing directly into main branch.
Sounds that there is no answer for that.

Hey there.

A short-lived branch will only show New Code (code changed in the branch) – read more about this in the documentation on Branch Analysis.

You can also adjust the long-lived branch pattern to analyze as a long-lived branch, showing results for all your code.

Maybe I’m not understanding something. Why is the number of lines so important to you?

If I understand well, we just have to create another long-lived branch for the feature.
With that we can see the code tab same as the main one.

What is important is to find which part of the code is affected by changing sonar.sources and sonar.projectBaseDir.
It is really hard to exclude the correct part of the code with the extraProperties: options.
The code info on the main branch is great as we can navigate into the code and see if they are no missing part or too much part.
Of course the number of line is important as we pay for it.
As example with one repo we have 3 projects with 400k LOC all together. When we analyze all without setting sonar.sources and sonar.projectBaseDir. then we got 3x 400k that is more the 1m and we have to go to next plan. SonarCloud is not able to find common code on multi project with one repo as we use set mono repo by projects

Thanks. This makes sense. I think raising a long-lived branch is the way to go.

Thanks @Colin. That’s great from you, to point me to the branch analysis documentation.
One solution could be:
When main branch were already analyzed, do all try to set up filter for the Analysis Scope on to a long-live branch feature. Once the Analysis scope is well define remove the long-live branch that was use for setup.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.