Sonar Scanner: all Java files excluded in Java project

The analysis run by sonar-scanner no longer finds any files to analyze in all my Java projects.

See for example this build. It has been run using the sonar-scanner -X option to enable full debugging info.

Scroll down to line 994 and following of the build log. You will see lines like this:

14:05:44.136 DEBUG: File Core/src/package-info.java was excluded by sonar.javascript.exclusions or sonar.typescript.exclusions
14:05:44.136 DEBUG: 'Core/src/package-info.java' excluded by org.sonar.plugins.javascript.JavaScriptExclusionsFileFilter

It turns out that all the Java source files in the project are excluded by this JavaScriptExclusionsFileFilter. Yet the project contains no JS at all, and the sonar configuration file makes no mention of sonar.javascript.exclusions or sonar.typescript.exclusions. Running the sonar scanner locally with the same settings and configuration correctly analyses all the files.

The analysis has been working correctly on Travis for years, and I didn’t change anything to the configuration files before it started having this issue. Compare for example this past build with the same configuration, and where Sonar does analyze all the files as it should.

I don’t know if this is a Sonar issue or a Travis issue, but since the same project and config files work OK on my local machine, I would lean towards Travis. Maybe there is something specific to the Sonar installation in Travis that triggers this problem?

Update: the analysis works again (see this build) by adding these two lines in sonar-project.properties:

sonar.javascript.exclusions=
sonar.typescript.exclusions=

This overrides the default exclusions for JS and TS (which, as mentioned in the first post, seem to exclude everything) by setting them to the empty string.

It works, but it does not seem to me like the expected behavior (why explicitly un-exclude JS files in a non-JS project? why this language and not the others?) --and besides, this hack is not needed when I run the analysis outside of Travis.

And the working directory in Travis is… /home/travis/build/<user>/<project>.

As you can see from the source, you can override this default by adding sonar.javascript.exclusions and/or sonar.typescript.exclusions to sonar-project.properties.


This is a bug (oversight) in the pattern matching behavior in my book. These patterns are meant to be matched against the part of the path under the project root rather than absolute path.