Excluding a few HUGE header files ... cannot do

  • versions used SonarQube: 7.9.0.26994
  • error observed
    I have in one of my projects a few HUGE C/C++ header files with test data in total 40k lines. No real value in scanning those with sonarqube (I have ~6 headers, but in the example below I show only two)
    I have tried to exclude the files:

sonar-scanner -Dsonar.exclusions=test/parameters_0.h,test/parameters_1.h …

  • I have also tried to add the four headers to my SonarQube webpage → Administration > Analysis Scope > Source File Exclusions

However I see that these files STILL are counted into my total amount of lines. For that project it is ok, but I then tried to add a new project, which has the first as a submodule - and suddently I am way above the 100k limit of my paid SonarQube developer license. Bummer!

I like to honor the license limitation but it is really stupid for me that 4 data files count as they do, and ultimatively limit me in what I can do (fair and reasonably) with SonarQube.

I have read quite a few posts from Search results for 'lines of code' - Sonar Community

If you have an idea let me know.

Hi @peter.toft,

it probably means you have not properly excluded those files if you still see them in your SonarQube UI. Could you please share the log of the sonar-scanner with --debug parameter?

I see
09:18:05 09:18:05.790 INFO: Indexing files…
09:18:05 09:18:05.792 INFO: Project configuration:
09:18:05 09:18:05.793 INFO: Excluded sources: test/parameters_0.h,test/parameters_1.h

No more mentioning of those files in the log file.

Hi @peter.toft,

then I believe they are not imported into SonarQube and not counting for LOC counting, it is not easy to help you without logs or more information just based on some statements.

I know

What I also see with https://sonarqubeserver/sonarqube/dashboard?id=project2 is

The last analysis has failed to not exceed the 100000 lines of code limit allowed by the current license.Go to License page.

but https://sonarqubeserver/sonarqube/admin/extension/license/app
shows that I have 56,486 lines currently analyzed and a limit of 100000 lines.

@mpaladin I might understand it and please comment …

Even though I have -Dsonar.exclusions=file1,file2 etc
I am also adding making an XML file with coverage information by adding

-Dsonar.cfamily.gcov.reportsPath=build_folder

and - my guess is - if the gcov report include a file1 or file2 - are they then counted anyway into the sum of lines given by my license?

Hi @peter.toft,

it means that you are trying to push an amount of lines which would pass your limit.

No, if they are not imported into SonarQube UI they are not counted even if they appear in the gcov report.

Few hints:

  • Are you properly setting sonar.sources folder?
  • Are you pushing to the main branch or a different branch?

@mpaladin I am starting to see a pattern here.
Instead of excluding files I started to only include files around the big files - suddent the line count dropped like a rock…
I will investigate further - but I foresee a real bug report coming up.

Hi @peter.toft,

thank you for the update, please let us know when you understood the issue.