Sonar.inclusions not scanned when sonar.tests is set

Settings:

  • sonar-scanner-cli docker container latest version
  • SonarQube deployed with docker
  • I want to run a scan on a C++ project including a predefined list of files using -Dsonar.inclusions=src/**,include/\*\*,gui/*\* and settings the -Dsonar.tests=tests
  • I am currently running the full sonar-scanner command in the docker container connecting it to my remote instance of SonarQube server with the project key, token and host url

When I run this command:
sonar-scanner -Dsonar.projectKey=----- -Dsonar.token=sqp---- -Dsonar.host.url=http://192.168.222.250:9000 -Dsonar.inclusions=src/**,apps/**,include/**,gui/** -Dsonar.tests=tests -X

only two source files are founded:

10:56:12.734 INFO Indexing files…
10:56:12.734 INFO Project configuration:
10:56:12.735 INFO Included sources: src/**, apps/**, include/**, gui/**
10:56:12.740 DEBUG ‘tests/boilerplateqttest.cpp’ indexed as test with language ‘cpp’
10:56:12.746 DEBUG ‘tests/CMakeLists.txt’ indexed as test with no language
10:56:12.746 INFO 2 files indexed

and it is not considering the files in all the directories listed in the inclusions. If I remove the -Dsonar.tests I get this:

10:57:49.572 INFO Indexing files…
10:57:49.573 INFO Project configuration:
10:57:49.573 INFO Included sources: src/**, apps/**, include/**, gui/**
10:57:49.580 DEBUG ‘src/boilerplateqt.cpp’ indexed with language ‘cpp’
10:57:49.589 DEBUG ‘src/CMakeLists.txt’ indexed with no language
10:57:49.589 DEBUG ‘apps/main.cpp’ indexed with language ‘cpp’
10:57:49.591 DEBUG ‘apps/CMakeLists.txt’ indexed with no language
10:57:49.591 DEBUG ‘include/BoilerplateQt/boilerplateqt.h’ indexed with language ‘c’
10:57:49.591 DEBUG ‘include/BoilerplateQt/gui/boilerplateqtwidget.h’ indexed with language ‘c’
10:57:49.591 DEBUG ‘gui/boilerplateqtwidget.ui’ indexed with no language
10:57:49.591 DEBUG ‘gui/CMakeLists.txt’ indexed with no language
10:57:49.591 DEBUG ‘gui/boilerplateqtwidget.cpp’ indexed with language ‘cpp’
10:57:49.593 INFO 9 files indexed
10:57:49.595 INFO Quality profile for c: Sonar way
10:57:49.595 INFO Quality profile for cpp: Sonar way

Is this a bug for mixing inclusions and tests settings?

Hi,

Welcome to the community!

Can we have this full log? Off-hand, this looks like a PR analysis, where it’s normal to have such a limited analysis scope.

Tangentially, there’s no reason to do this:

Do this instead:
sonar.sources=src,apps,include,gui

Per the docs:

Comma-separated paths to directories… A directory in the list means that all analyzable files and directories recursively below it are included.

 
Ann