Sensor JavaScript/TypeScript Coverage ignores the report lcov.info

Hi everyone,
I have the Java/Javascript multi-modules project.
All modules are defined in the root pom.xml file.
We use 2 coverage reports Jacoco and LCOV for Java and JavaScript/Typescript languages.
Bith reports generate on the tests-step of the GitHub Action pipeline and share as an artifact between the GitHub jobs.
The JavaScript/Typescript coverage report is placed in the ui.frontend/coverage/lcov.info.
The Jacoco coverage report is placed in the core/target/site/jacoco/jacoco.xml

SonarQube doesn’t import the LCOV JavaScript/TypeScript coverage report.
I see in the logs it tries to find the report in the ui.apps/coverage/lcov.info but it fails beacase the report is absent here.

[INFO] 08:47:14.618 No LCOV files were found using ./coverage/lcov.info
Warning:  08:47:14.618 No coverage information will be saved because all LCOV files cannot be found.

When I added -X option to debug, I see the next message in the ui.frontend module:

'JavaScript/TypeScript Coverage' skipped because there is no related file in current project

I’ve tried different options to define the path to report:
-Dsonar.javascript.lcov.reportPaths=./coverage/lcov.info
-Dsonar.javascript.lcov.reportPaths=coverage/lcov.info
-Dsonar.javascript.lcov.reportPaths=./ui.frontend/coverage/lcov.info
-Dsonar.javascript.lcov.reportPaths=ui.frontend/coverage/lcov.info
-Dsonar.javascript.lcov.reportPaths=**/lcov.info

The original command:

          mvn l -B verify org.sonarsource.scanner.maven:sonar-maven-plugin:sonar -DskipTests \
          -Dsonar.projectKey=projectKey \
          -Dsonar.host.url=${{ secrets.sonar_host_url }} \
          -Dsonar.token=${{ secrets.sonar_token }} \
          -Dsonar.language=java,js \
          -Dsonar.javascript.lcov.reportPaths=./coverage/lcov.info \
          -Dsonar.coverage.jacoco.xmlReportPaths=target/site/jacoco/jacoco.xml 

I’ve added the additional step in the pipeline to check artifacts and permissions. It looks good, the reports are stored in the right place but only the lcov.info is ignored by Sonar.
Do you any ideas why it happens?

SonarQube Enterprise Edition * Version 9.9 (build 65466)

I’ve added before the main command the next script to check artifacts:

          echo "Checking the coverage reports"
          COVERAGE_REPORTS=("ui.frontend/coverage/lcov.info" "core/target/site/jacoco/jacoco.xml")
          for FILE in "${COVERAGE_REPORTS[@]}"; do
            if [ -f "$FILE" ]; then
                echo "$FILE exists."
                cat $FILE
            else
                echo "The coverage $FILE does not exist."
                exit 1
            fi
          done

It shows the files in the console correctly.
Why the sonar ignores it?

Hi,

Welcome to the community!

First, which version of the SonarScanner for Maven are you using?

You have two modules, one for Java (core), one for JavaScript (ui.frontend), right? And inside the JS module, there’s a coverage directory?

 
Thx,
Ann

Hi,
Thanks for your response.
The exact version of the SonarScanner hasn’t been defined:

[INFO] --- sonar-maven-plugin:4.0.0.4121:sonar (default-cli) @ jll-com-phoenix ---
Warning:  12:49:45.796 Using an unspecified version instead of an explicit plugin version may introduce breaking analysis changes at an unwanted time. It is highly recommended to use an explicit version, e.g. 'org.sonarsource.scanner.maven:sonar-maven-plugin:4.0.0.4121'.

We have more modules than core, ui.frontend, and ui.apps.
The core module is for Java and we have the Jacoco coverage report here: core/target/site/jacoco/jacoco.xml. It works fine.
The ui.frontend and ui.apps modules with JavaScript/TypeScript sources. The LCOV coverage report is stored inside the ui.frontend but the Sonar tries to find it inside the ui.apps module:

Checking the coverage reports
ui.frontend/coverage/lcov.info exists.
-rw-r--r-- 1 runner docker 21266 Oct 29 12:47 ui.frontend/coverage/lcov.info
core/target/site/jacoco/jacoco.xml exists.
-rw-r--r-- 1 runner docker 359880 Oct 29 12:47 core/target/site/jacoco/jacoco.xml

Hi,

Do you have one report for both modules? I think you’ll need to split it up and provide a report per module.

 
Ann

Hi Ann,
I’ve checked that, and it looks like the report has been generated only for ui.frontend module.

Hi,

Then I guess this answers the question of why analysis isn’t picking up coverage for the other modules?

 
Ann

Hi Ann,
I suppose the right answer is “because of the project-specific”. :slight_smile:
But still.
The main question is why it tries to pick up the report in the module ui.apps instead of ui.frontend and for the ui.frontend module it writes that there is no related file?
Where and what is it misconfigured?
Do you have any ideas?

Hi,

Let’s back up.

Where do coverage files exist?

 
Ann

Hi Ann,

The code files covered by the report are stored in the ui.frontend folder(module)
The coverage report files are here: ui.frontend/coverage/*(folder with all data including the lcov.info file)

1 Like

Hi,

Looking back through this all…

I think this may be about this:

You’re providing one, relative path in a multi-module project. I think it’s just being applied in the wrong place/time. My first thought is to specify this not on the command line but at the module level. And it’s not clear to me from our docs how to go about that, especially for a JS module, which likely doesn’t have a POM file.

So… I’m going to flag this for more expert eyes.

 
Ann

1 Like

Hello @Siarhei_Harbuz,

To further investigate the coverage problem you are experiencing, I would need the following information:

  • The tree structure of your project: It will help me understand how your multi-module project is organized.
  • The full debug logs of the analysis: It will allow me to identify any inconsistencies between your analysis configuration and your project’s organization

If the information contains sensitive data, feel free to share it with me privately.

I look forward to receiving these details.

Best,
Yassin

Hi Ann,
We’ve fixed this issue.
There was a misconfigured module ui.frontend (in the pom.xml) regarding the source code path.
Thank you Ann for your assistance!

1 Like

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