We recently encountered an issue in our SonarCloud instance that is quite confusing to determine how to best resolve.
We have our main branch called DEV which Sonar continuously analyses for any merge requests.
While I can see in our Gitlab logs that Sonar did performed the analysis on a scheduled run for this branch, it had an issue:
Error during SonarScanner execution
CE Task finished abnormally with status: FAILED, you can check details here: https://sonarcloud.io/api/ce/task?id=*********************
Details of the issue (from the link) is below:
errorMessage":"This analysis will make your organization \u0027*********\u0027 to reach the maximum allowed lines limit (having 111540 lines). \nPlease contact the administrator of the organization to resolve this issue."
We also have another branch (let us call it QA) where Sonar analysis is also performed when the changes made to the main branch is being pushed to that branch.
On the QA branch though, SonarCloud did run and was able to report on the issues that the analysis found.
In this regard, we wanted to know why our main branch will report the maximum number of lines were reached, when our QA branch which would technically have approximately the same number of lines was able to get the SonarCloud analysis and reports run successfully.
main - commits added here after they’re okay in DEV?
QA - same as main(?)
Which would indicate that DEV is at least a few commits ahead of the branches that are still analyzing okay? So it sounds like new Lines of Code got added to DEV, but they haven’t made it into the other branches yet, which is why those branches can still successfully analyze.
We usually branch out of dev for any features / fixes that we work on and merge it back to dev. Once everything is tested and verified in our dev environment, we push those changes into the qa branch.
We have daily scanning schedules performed on both dev and qa branches, and a snapshot of these branches LOCs shows the following:
Typically yes. Unless we perform merge requests focusing on removing unused features/codes or have done refactoring that reduces the lines of code in different files.
So then this is perfectly normal. Your DEV branch analysis is failing because more LoC were added to it, pushing your project/organization over your license limit. The other branches can still be analyzed because those code additions haven’t made it that far yet.
I will try and see if I reduce the LoC (either by deleting unused codes or exclusion of specific folders) will make a difference.
I’ll perform an attempt to make the LoCs for the dev branch much less that the LoCs for the qa branch and we can see whether the scanning will push through.