Test file inclusions seems to imply source exclusions

  • SonarQube:

All settings made in the UI

I have a project in which I want to scan all C source files and I also have gcov reports, but I only want to report on code coverage on the c sources in the src directory. My project level settings are:

  • sonar.inclusions - **/*.c
  • sonar.test.inclusions - src/*.c

When scanning this project, then scanner reports the following information:

INFO: Project configuration:
INFO:   Included sources: **/*.c
INFO:   Excluded sources: src/*.c
INFO:   Included tests: src/*.c
INFO: 75 files indexed
INFO: 1097 files ignored because of inclusion/exclusion patterns
INFO: 0 files ignored because of scm ignore settings

I have tried resetting the the UI parameters back to 0, adding/deleting no matter what, it seems that if I add src/*.c to the test inclusions, the scanner detects that as a source exclusion even though the source.exclusions field is empty in the UI. I have checked that the global exclusions field is also empty.

What could possibly be related is that this project used to exist with god knows what settings, but I deleted the project and then re-added a new one with the same key. Is it possible the old key exists somewhere in the DB and wasn’t properly flushed?

I have restarted the sonar server and the issue still persists.

Is this a bug or am I just not understanding the behavior of sonar.test.inclusion?

Hi KaibutsuX,

It’s more a misundertanding. sonar.test.inclusions will designate the matching files as being tests. It sounds like the property you’re looking for is actually sonar.coverage.exclusions which can be used to identify project source files which you do not want to include in reported coverage results. There’s no .inclusions flavor of this property, so you’ll need to devise a pattern value that matches what you don’t want. It may be as simple as *.c if it’s just C files in the top level folder you want to exclude.

Hope this helps!

oh that makes sense, thanks for the clarification!

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.