Hello,
We are using sonarcloud and we have 79k LOC divided in 6 projects where each project has 4 long lived branches (master, staging, qa, develop) and is currently supporting PR analysis.
Last week we sent a PR on a brand new project that has 2.1k LOC (included in the 79k) and we started getting this error…
This analysis will make your organization 'XYZ' to reach the maximum
allowed lines limit (having 161226 lines).
Please contact the administrator of the organization to resolve this issue.
and when we re-run the same pipeline we are getting…
This analysis will make your organization 'XYZ' to reach the maximum
allowed lines limit (having 182398 lines).
Please contact the administrator of the organization to resolve this issue.
there is clearly something wrong here, by just re running the pipeline I see +21k LOCs in a project that only has 2.1k LOCs? and is worth to mention that there is no new code, we are just adding a long lived branch.
Something is not right or I’m not understanding this… can anyone provide any help or guidance? this is the first time I see this problem, it’s also my first time using the cloud version, not sure if it was a wise choice
Pipeline YAML
definitions:
caches:
sonar: ~/.sonar/cache # Caching SonarCloud artifacts will speed up your build
steps:
- step: &build-test-custom-sonar
name: Build, test and analyze on SonarCloud (Custom run)
caches:
- node
- sonar
script:
- npm install --quiet --legacy-peer-deps
- npm run coverage -- --no-watch --no-progress --browsers=ChromeHeadlessNoSandbox
- npm run sonar
pipelines:
default:
- step: *build-test-custom-sonar
I was looking for the analysis logs rather than the context files.
Tangentially, I see some interesting things in your context:
- sonar.language=js - this parameter hasn’t worked for years. Analysis is always* multi-lingual
- sonar.sources.inclusions=apps/**/src/app I see this, but not a definition of sonar.sources, which means you’re allowing it to default to .. In a monorepo, I suspect that’s not actually what you want
- sonar.test.inclusions=**/*.spec.ts - sonar.tests.inclusions=apps/**/src/app
Only one of these keys is correct (the first one). But I find it odd that the patterns don’t match.
Additionally, I’m not seeing a definition of the basic sonar.tests.
You have two failing analyses of a 2.1k project, both reporting 100k+ LOC. I agree that the 21k difference between the two LOC counts is strange. At the same time, I think there’s obviously a bigger problem. If we take the smaller of the two analyses as a baseline: where did the extra 159.1k LOC come from?
So now I’d like to come back to this:
You asserted that sonar.sources is set in your sonar-project.properties file, and thoughtfully provided it. In that file I see this:
Note that nowhere in there is sonar.exclusions, and sonar.inclusions has an entirely different value.
From this, I conclude
your sonar-project.properties file is not being picked up
sonar.sources is defaulting to ., rather than the carfully curated list you provided
Is it possible there are extra random files in .? The two analysis logs you provided don’t indicate that they find different numbers of files, but at this point I feel like everything’s up for grabs.
I think we need to step back to making sure analysis is running with the properties you intended, and if there are still LOC anomalies, we can look at them then.
Indeed, I’ve just run a new clean execution of the same branch and now the sonar context is picking up the correct properties file , not sure what happened with those 2 executions, but you were right seeing it from the +150k
I’ve notice that in the FAILED execution the context had this value… notice that server settings has one prop…
Just to tidy up, the difference in the server settings in interesting, but since that’s just a report - from the server - of the values set on the server, I’m going to guess that maybe you added settings before the latest run…?
Anyway, that’ll be something to look at if there are future problems, but for now I don’t think it’s something we need to worry about.