Why does the SonarQube Scanner look outside of the sonar.sources directories?

  • which versions are you using: Developer Edition v10.6, sonarqube-scanner 4.2.3
  • how is SonarQube deployed: Docker
  • web project (TypeScript, HTML, and SCSS)
    I have the following sonar-project.properties:
sonar.sources=libs/,apps/
sonar.inclusions=**/*.ts,**/*.scss,**/*.html
sonar.javascript.lcov.reportPaths=**/coverage-test/lcov.info

I run the scanner from the frontend directory, so it should scan the frontend/apps and frontend/libs directories. However, sometimes I encounter an error:

java.io.UncheckedIOException: java.nio.file.NoSuchFileException: .../frontend/dist/libs/...
...
org.sonar.plugins.javascript.lcov.CoverageSensor.getLcovFiles(CoverageSensor.java:99)

It seems that CoverageSensor is looking for files outside the directories specified in the sonar.sources properties, specifically in frontend/dist. This directory might be removed by a parallel task, which can cause the scanner to throw an error.

Hi,

What’s in your coverage report? Does it refer to ../frontend/dist/?

 
Ann

I asked Sonar to look for all **/coverage-test/lcov.info. However, since my sonar-properties.properties file specifies sonar.sources and sonar.tests to point only to the libs and apps directories, I expected it to search only within those directories and not in the dist directory, which is parallel to them.

The project structure is:

  • frontend/
    • sonar-properties.properties
    • dist/
    • apps/
    • libs/

Why is CoverageSensor looking for files outside the directories specified in the sonar.sources and sonar.tests properties ?

Hi,

It feels like we’re having nearly the same conversation, twice, in parallel.

Awesome. Only those files will be indexed as source and test files. But again,

 
Ann

Yes, the root cause is the same—Sonar scan traverses files outside the directories defined in the sonar.sources and sonar.tests properties.

As for the coverage report, I have an Angular monorepo in the frontend repository with multiple projects, each with its own coverage information. To gather all coverage data, I set the property:

sonar.javascript.lcov.reportPaths=**/coverage-test/lcov.info

The frontend/dist directory doesn’t contain any coverage information. A build step (running in parallel with Sonar) can create or delete files under frontend/dist, which I suspect is causing the error.

Hi,

That doesn’t answer the question. Since this is, essentially, the second topic about the same question, lets just set this one aside for now.

 
Ann