On Travis, all source files are discarded by the JS exclusions file filter

Parameters

  • Versions used: SonarQube Scanner 3.0.3.778
  • Platform: Travis CI under Ubuntu 18.04

Description

The analysis run by sonar-scanner no longer finds any files to analyze in Travis 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. A bug report has been filed on Travis, and the Travis staff discovered that the issue lies in the pattern used by this filter, which discards any file inside a folder called build:

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

As a result, the filter discards all the files in a Travis build. Quoting Travis’ staff:

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.

Workaround

Adding these two lines in sonar-project.properties :

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

This overrides the (incorrect) exclusion pattern in the JS plugin and allows files to be included again.

A post was merged into an existing topic: SonarCloud pipeline, working for 4months, but today I get “INFO: 0 files indexed”