Sonar Scanner misinterpreting src/index.js with other index.js files

SonarQube version: Developer Edition v2025.5 (113872)

Sonar Scanner version: SonarScanner CLI 7.3.0.5189

The sonar scanner appears to misinterpret lcov report coverage for multiple files named “index.js”. I cannot share my source code, so here is an example of the failure.

I have a project with the following files:

src/index.js (133 lines)
src/common/index.js (51 lines)
src/routers/index.js

My lcov report generated by vitest includes information for src/index.js and src/common/index.js (see attached).
sample-lcov.info.txt (1.2 KB)

The lcov info includes information for lines 52-130. When the sonar scanner process the file, it reports the following:

17:15:34.543 DEBUG Problem during processing LCOV report: can't save DA data for line 23 of coverage report file (java.lang.IllegalArgumentException: Line with number 52 doesn't belong to file index.js).
17:15:34.543 DEBUG Problem during processing LCOV report: can't save DA data for line 24 of coverage report file (java.lang.IllegalArgumentException: Line with number 53 doesn't belong to file index.js).
... (lines 54-126)
17:15:34.544 DEBUG Problem during processing LCOV report: can't save DA data for line 58 of coverage report file (java.lang.IllegalArgumentException: Line with number 129 doesn't belong to file index.js).
17:15:34.544 DEBUG Problem during processing LCOV report: can't save DA data for line 59 of coverage report file (java.lang.IllegalArgumentException: Line with number 130 doesn't belong to file index.js).
17:15:34.578 WARN  Found 37 inconsistencies in coverage report. Re-run analyse in debug mode to see details.

If I rename my src/index.js file to src/app.js, the sonar scanner does not run into this issue. My best explanation is that “src/common/index.js” is alphabetically ahead of “src/index.js” and so the sonar scanner is trying to use the common index file instead.

Hello @lucasjvw,

can you share all the sonar properties you are passing to the scanner, please? What scanner are you using? cli, npm, mvn?

Cheers!