Sonarqube + Cypress error: Could not resolve file paths in lcov.info

Hello,

  • which versions are you using: SonarQube Community Edition v10.5.1, sonar-scanner 5.0.1.3006
  • how is SonarQube deployed: Helm
  • what are you trying to achieve:
    Recently some e2e tests have been added to a project we were already analyzing on Sonarqube. The tests are successfully execute using cypress and at the end an lcov.info file is being generated. We are trying to upload this lcov.info file to Sonarqube in order to get Coverage %.
    In order to do so we first added the following line in our sonar-project.properties file: e2e.sonar.javascript.lcov.reportPaths=cypress/coverage/lcov.info
    From the logs we can tell that Sonar finds and reads lcov.info but it cannot resolve the paths included in it:

13:10:45.637 DEBUG: Property sonar.javascript.lcov.reportPaths is used.
13:10:45.637 DEBUG: Using ‘cypress/coverage/lcov.info’ to resolve LCOV files
13:10:45.637 INFO: Analysing [/home/jenkins/agent/workspace/project-cypress-analysis_master/e2e/cypress/coverage/lcov.info]
13:10:45.664 WARN: Could not resolve 194 file paths in [/home/jenkins/agent/workspace/project-cypress-analysis_master/e2e/cypress/coverage/lcov.info]
13:10:45.664 DEBUG: Unresolved paths:
…/project-ui/src/main.ts
…/project-ui/src/polyfills.ts
…/project-ui/src/app/app.component.html
…/project-ui/src/app/app.component.ts
…/project-ui/src/app/app.constants.ts
…/project-ui/src/app/app.module.ts
…/project-ui/src/app/app.routes.ts
…/project-ui/src/app/attribute/attribute.service.ts
…/project-ui/src/app/auth/auth.service.ts
…/project-ui/src/app/authority/authority-fields.service.ts

  • what have you tried so far to achieve this:
    We have tried changing the paths to any possible combination: full path, relative path, etc. Nothing worked. We even downgraded "ts-node" to "10.7.0" because in a similar post we read that it solved the issue, but it did not in our case. Could it be that cypress configuration and the lcov.info are in directory ‘e2e’ and the paths mentioned in lcov.info are in a different directory (‘project-ui’)?

Any help in order to resolve this would be much appreciated.

Thank you

P.S.: In case it helps I have attached a screenshot that depicts the project’s structure:

Hey there.

This surprised me – you’re configuring the coverage report as if you have specified modules using sonar.modules. Is that what you’re doing?

Normally, we would just suggest appending the coverage report to sonar.javascript.lcov.reportPaths, which supports a comma-separated list of values.

Hi Colin,

Thank you for your response.

Yes, we decided to define e2e as a module because if we specify it as such: sonar.javascript.lcov.reportPaths=e2e/cypress/coverage/lcov.info we receive the following output:

07:33:23.723 INFO: Sensor JavaScript/TypeScript Coverage [javascript]
07:33:23.724 DEBUG: Property sonar.javascript.lcov.reportPaths is used.
07:33:23.724 DEBUG: Using ‘e2e/cypress/coverage/lcov.info’ to resolve LCOV files
07:34:02.521 INFO: No LCOV files were found using e2e/cypress/coverage/lcov.info
07:34:02.522 WARN: No coverage information will be saved because all LCOV files cannot be found

As mentioned above, we tried all possible paths while defining or not defining e2e as a module, but nothing seems to work.

This is what our sonar-project.properties file looks like, in case it helps:

sonar.projectName=projectName
sonar.projectKey=projectKey
sonar.modules=project-server,project-ui,e2e

project-server.sonar.sources=src/main/java/
project-server.sonar.java.binaries=target/**
project-server.sonar.tests=src/test/java/
project-server.sonar.java.test.binaries=target/test-classes/**
project-server.sonar.junit.reportPaths=target/surefire-reports/
project-server.sonar.coverage.jacoco.xmlReportPaths=target/site/jacoco-aggregate/jacoco.xml

project-ui.sonar.sources=src/
project-ui.sonar.tests=src/
project-ui.sonar.exclusions=**/*.spec.ts,**/*test.ts,**/*.html
project-ui.sonar.test.inclusions=**/*.spec.ts,**/*test.ts
  
e2e.sonar.javascript.lcov.reportPaths=cypress/coverage/lcov.info
e2e.sonar.exclusions=**/*.js

sonar.sourceEncoding=UTF-8
sonar.java.source=17
sonar.java.libraries=**/*
sonar.java.jdkHome=/usr/lib/jvm/java-17-openjdk-amd64

Can you please advise on the next steps?

What’s the absolute file path of your coverage report?

The sonar analysis is running as part of a jenkins job, so the file resides inside a jenkins workspace, with the following absolute path:
/nfs-data/jenkins-workspace/workspace/project-cypress-analysis_master/e2e/cypress/coverage/lcov.info

The paths inside that lcov.info which sonarqube claims as “unresolved” are as such:

…/project-ui/src/main.ts
…/project-ui/src/polyfills.ts
etc

@Colin
Are there any updates on this issue?

Hey there.

I do intend to come back to this thread, but I didn’t have the chance this week.

2 Likes

Did you able to resolve this issue ?