Sonar scan failing only on master branch

  • ALM used
    Bitbucket Cloud

  • CI system used
    Bitbucket Cloud

  • Scanner command used when applicable

step: &sonarCloud-Analysis
      name: SonarCloud Analysis
      script:
        - export PATH="$PATH:/root/.dotnet/tools"
        - dotnet sonarscanner begin /k:"xxx"  /d:"sonar.login=${SONAR_TOKEN}" /o:"xxx" /d:"sonar.host.url=https://sonarcloud.io"
        - dotnet restore xxx.sln --configfile Nuget.config
        - dotnet build xxx.sln --no-restore --configuration Release
        - dotnet sonarscanner end /d:"sonar.login=${SONAR_TOKEN}"
  • Languages of the repository
    (C#, javascript, html, css)

  • Private repo

  • Error observed

This analysis will make your organization 'xxx' to reach the maximum allowed lines limit (having 500893 lines). 
Please contact the administrator of the organization to resolve this issue.
  • Steps to reproduce
    Scans on all branches work fine. Only a scan on the master branch fails.

  • Potential workaround
    None at this time

  • Description
    Scans on PR branches and all other branches work fine. only scans on master fail with the above message. I asked support whether the solution to this was to purchase more LOC and I was referred here.

Hey there.

SonarCloud counts the largest branch of all projects towards the license limit. It seems like your main branch pushes you over that limit while other branches don’t (and most likely, short-lived branches and PRs will never be the largest branch in your project).

You can purchase more Lines of Code, or try adjusting the analysis scope to exclude files (sonar.exclusions).

Adding /d:sonar.verbose=true to your analysis should give you a really good idea what all files are being indexed, and where you might be able to exclude some (third-party modules, etc.)