When Is LOC exclusions calculated after adding exclusion

Hello Community,

We have exceeded our lines of code limit, and as a solution, added some exclusions to all our projects (300ish). (Via the api and using sonar.exclusions in the pom)

However the exclusions seem not to be accepted, so some questions to help investigate:

  1. When exclusions are added via the pom and the scan is run, on a branch that is not main or master, does it reduce the lines? or does it only apply to master?
  2. If exclusions are added via the UI or API, when do these exclusions actually get removed from total “lines of code”? Does it work without having to do a scan again?
  3. As we have exceeded the lines of code currently, scanning does not work. So If a new scan of a project is triggered, will the new exclusions be considered despite the scan failing?

On SonarQube Cloud

Exclusions have been added to “Source File Exclusions” in each project’s Administration → General Settings → Analysis Scope via the API (which appear correctly in the UI) and in the pom file <sonar.exclusions>

Thanks

James

Hi,

Welcome to the community!

Exclusions kick in during analysis. Simply adding exclusions in the UI doesn’t make those files/lines immediately drop out of your project.

License LOC are based on the largest branch of each project. So you’ll probably need to reanalyze all or most of your branches to get the exclusions applied in each one.

It’s actually very difficult to get into a state where you’ve exceeded the license LOC. New analyses are being rejected because they would push you over the limit. So a reanalysis with fewer LOC should work just fine. This is a hole you can dig analyze your way out of. :smiley:

 
HTH,
Ann