Question on lines of code

Hi
Our org current has 1,899,946/1.9M lines of code in our license, we can’t run any scan because it will make our organization to reach the maximum allowed lines limit. but i am having a question regarding how the new code been calculated in a pull-request scan.
the latest pull-request scan on the project will make our organization having 1901013 lines, but i don’t think we have more than 1000 (1901013 -1,899,946) lines of new code in that pull-request. the new code definition of the project is number of days (30).

The pull request scan was initiated from a new feature branch created from the main branch. Will the code in this feature branch be classified as new code?

this the project link : Summary - aamc-enterprise-security-aws-java in aamc-org SonarQube Cloud

Hey @fjiang-aamc

I expect it won’t be possible to understand why you’re being pushed over the edge by this pull request without actually seeing the PR results. This

Can a large file be excluded from the main branch of another project to temporarily lower your LoC enough to see the PR results? Your analysis results will snap right back into place after removing the exclusion.

Is this branch analyzed on SonarCloud? What branch is this PR analysis targeting – your main branch or the feature branch?

the targeting branch is main branch, so based on my understanding, please correct me if i am wrong, Sonarcloud determines “new code” in a pull request scan by comparing the changes in the PR to the target branch. For short-live branch, sonarcloud identifies new code by performing a diff between the short-lived branch and its target branch. the New code definition is applicable for long-live branch only.

That is correct.

Thank you for your quick reply.
How sonar detect what’s target branch for the short-lived branch? and for example, if i have a short-lived branch with 5000 new lines of code, and if we don’t merge it into long-lived branch or develop branch, those lines of code will always be counted as new code and be added into our license for every scans.

@fjiang-aamc Unless sonar.branch.target is provided, the main branch is assumed to be the target branch.

It depends. SonarQube Cloud actually considers that only the largest branch of a project should be counted towards the Lines of Code utilization.

You’ve started to discuss short-lived branches, but I understood the original post was about pull requests. What kind of analysis are you performing?

hi Colin
Thank you for your quick response. the pull-request, i think i understood and we are good for now.
for the question of lines of code consumption , do i need to raise a new ticket or we can discuss here.

I’m not really sure what the pending question is! Can you clarify?