My coverage shows 0%

I have two projects in my sonarQube, the first one with java (no problem). the second one with angular, and Jasmine test framework.
My problem is that I the column coverage in sonarQube show 0% for the second project. and it’s works fine for the first project.


any solution please ?

Hello @IFK_TT,

Welcome to our community, and thank you for your message.

The analyser probably didn’t find any LCOV files from your TypeScript project. I suggest you to run the analysis in verbose mode with -X to see if there is any log of the form:

No coverage information will be saved because all LCOV files cannot be found.

If this is the case, then you probably need to set the property sonar.javascript.lcov.reportPaths adequately.

Yassin

Hello @Yassin,

Thanks for your replay, and sorry for my delay.

I’m beginner with typescript and sonar, I have set the property sonar.javascript.lcov.reportPaths, but i still have the same problem !!

This is my application root directories

and this is my pom.xml:

    <properties>
            <sonar.projectKey>appli-blanche-quality-appli-blanche-frontend-develop</sonar.projectKey>
            <sonar-maven-plugin.version>3.7.0.1746</sonar-maven-plugin.version>
            <sonar.ts.tslint.configPath>tslint.json</sonar.ts.tslint.configPath>
            <maven-clean-plugin.version>3.1.0</maven-clean-plugin.version>
            <frontend-maven-plugin.version>1.6</frontend-maven-plugin.version>
            <nodeVersion.version>v10.15.3</nodeVersion.version>
            <npmVersion.version>5.10.0</npmVersion.version>
            <sonar.sources>src/app,pom.xml</sonar.sources>
            <sonar.exclusions>node_modules/**</sonar.exclusions>
            <sonar.ts.coverage.lcovReportPath>coverage/lcov.info</sonar.ts.coverage.lcovReportPath>
            <sonar.ts.tslint.configPath>tslint.json</sonar.ts.tslint.configPath>
            <sonar.ts.tslint.nodePath>node/node</sonar.ts.tslint.nodePath>
            <sonar.ts.tslint.path>node_modules/.bin/tslint</sonar.ts.tslint.path>
            <sonar.typescript.node>node/node</sonar.typescript.node>
            <jacoco-maven-plugin.version>0.8.5</jacoco-maven-plugin.version>
        </properties>
....
            <plugins>
                    <plugin>
                        <groupId>org.sonarsource.scanner.maven</groupId>
                        <artifactId>sonar-maven-plugin</artifactId>
                        <version>${sonar-maven-plugin.version}</version>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-surefire-plugin</artifactId>
                        <version>3.0.0-M3</version>
                    </plugin>
                    <plugin>
                        <groupId>org.jacoco</groupId>
                        <artifactId>jacoco-maven-plugin</artifactId>
                        <version>${jacoco-maven-plugin.version}</version>
                        <executions>
                            <execution>
                                <goals>
                                    <goal>prepare-agent</goal>
                                </goals>
                            </execution>
                            <execution>
                                <id>jacoco-report</id>
                                <phase>test</phase>
                                <goals>
                                    <goal>report</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
        ...
        </plugins>

Hello again,

Thank you for sharing both your project directory and your pom.xml. From what I can see, you didn’t set sonar.javascript.lcov.reportPaths; your pom.xml still defines sonar.ts.coverage.lcovReportPath instead.

In any case, could you please share the analysis logs when you run the scanner? Those will help understanding why your coverage file is not taken into account.

Yassin

Hello,

Thanks for your replay.

this is the log fil for sonar analysis

    [Pipeline] { (SonarQube analysis)
[Pipeline] withSonarQubeEnv (hide)
Injecting SonarQube environment variables using the configuration: SonarQube
[Pipeline] {
[Pipeline] withMaven
[withMaven] Options: []
[withMaven] Available options: 
[withMaven] using JDK installation provided by the build agent
[withMaven] using Maven installation '3.5.0'
[Pipeline] {
[Pipeline] sh
+ mvn sonar:sonar -Dsonar.projectKey=appli-blanche-quality-appli-blanche-frontend-develop
----- withMaven Wrapper script -----
Picked up JAVA_TOOL_OPTIONS: -Dmaven.ext.class.path="/var/jenkins_home/workspace/appli-blanche-frontend_develop@tmp/withMaven1c3050b8/pipeline-maven-spy.jar" -Dorg.jenkinsci.plugins.pipeline.maven.reportsFolder="/var/jenkins_home/workspace/appli-blanche-frontend_develop@tmp/withMaven1c3050b8" 
Apache Maven 3.5.0 (ff8f5e7444045639af65f6095c62210b5713f426; 2017-04-03T21:39:06+02:00)
Maven home: /opt/transverse/all_maven/apache-maven-3.5.0
Java version: 1.8.0_222, vendor: Oracle Corporation
Java home: /usr/local/openjdk-8/jre
Default locale: en, platform encoding: UTF-8
OS name: "linux", version: "3.10.0-1127.13.1.el7.x86_64", arch: "amd64", family: "unix"
[INFO] [jenkins-event-spy] Generate /var/jenkins_home/workspace/appli-blanche-frontend_develop@tmp/withMaven1c3050b8/maven-spy-20201103-121158-6955937129738832034510.log.tmp ...
[INFO] Scanning for projects...
[INFO] 
[INFO] ------------------------------------------------------------------------
[INFO] Building appli-blanche-frontend 22.400.0.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- sonar-maven-plugin:3.7.0.1746:sonar (default-cli) @ appli-blanche-front ---
[INFO] Downloading: http://repository-maven.forge.xxx.xxx.xx/public/org/apache/maven/plugins/maven-compiler-plugin/maven-metadata.xml
[INFO] Downloaded: http://repository-maven.forge.xxxx.xxx.xx/public/org/apache/maven/plugins/maven-compiler-plugin/maven-metadata.xml (1.7 kB at 335 B/s)
[INFO] User cache: /var/jenkins_home/.sonar/cache
[INFO] SonarQube version: 6.7.7
[INFO] Default locale: "en", source code encoding: "UTF-8" (analysis is platform dependent)
[INFO] Publish mode
[INFO] Load global settings
[INFO] Load global settings (done) | time=116ms
[INFO] Server id: 2141343F-AW68GcPv7aRs6Hf6G54p
[INFO] User cache: /var/jenkins_home/.sonar/cache
[INFO] Load plugins index
[INFO] Load plugins index (done) | time=59ms
[INFO] Process project properties
[INFO] Load project repositories
[INFO] Load project repositories (done) | time=107ms
[INFO] Execute project builders
[INFO] Execute project builders (done) | time=0ms
[INFO] Load quality profiles
[INFO] Load quality profiles (done) | time=40ms
[INFO] Load active rules
[INFO] Load active rules (done) | time=309ms
[INFO] Load metrics repository
[INFO] Load metrics repository (done) | time=25ms
[INFO] Project key: appli-blanche-quality-appli-blanche-frontend-develop
[INFO] -------------  Scan appli-blanche-frontend
[INFO] Base dir: /var/jenkins_home/workspace/appli-blanche-frontend_develop
[INFO] Working dir: /var/jenkins_home/workspace/appli-blanche-frontend_develop/target/sonar
[INFO] Source paths: src/app, pom.xml
[INFO] Source encoding: UTF-8, default locale: en
[INFO] Load server rules
[INFO] Load server rules (done) | time=86ms
[INFO] Index files
[INFO] Included sources: 
[INFO]   **/*.spec.ts
[INFO] Excluded sources: 
[INFO]   node_modules/**
[INFO] 8 files indexed
[INFO] 56 files ignored because of inclusion/exclusion patterns
[INFO] Quality profile for ts: Sonar way recommended
[INFO] Sensor HTML [web]
[INFO] Sensor HTML [web] (done) | time=14ms
[INFO] Sensor SonarTS [typescript]
[INFO] Analyzing 8 typescript file(s) with the following configuration file /var/jenkins_home/workspace/appli-blanche-frontend_develop/tsconfig.json
[INFO] 8 files analyzed out of 8
[INFO] Sensor SonarTS [typescript] (done) | time=5948ms
[INFO] Sensor SonarTS Coverage [typescript]
[INFO] Analysing [/var/jenkins_home/workspace/appli-blanche-frontend_develop/coverage/lcov.info]
[WARNING] Could not resolve 31 file paths in [/var/jenkins_home/workspace/appli-blanche-frontend_develop/coverage/lcov.info], first unresolved path: src/polyfills.ts
[INFO] Sensor SonarTS Coverage [typescript] (done) | time=5ms
[INFO] Sensor Zero Coverage Sensor
[INFO] Sensor Zero Coverage Sensor (done) | time=31ms
[INFO] Sensor CPD Block Indexer
[INFO] Sensor CPD Block Indexer (done) | time=1ms
[INFO] SCM Publisher is disabled
[INFO] Calculating CPD for 8 files
[INFO] CPD calculation finished
[INFO] Analysis report generated in 128ms, dir size=85 KB
[INFO] Analysis reports compressed in 32ms, zip size=33 KB
[INFO] Analysis report uploaded in 47ms
[INFO] ANALYSIS SUCCESSFUL, you can browse https://open-sonar.forge.xxx.xxx.xx/dashboard/index/appli-blanche-quality-appli-blanche-frontend-develop
[INFO] Note that you will be able to access the updated dashboard once the server has processed the submitted analysis report
[INFO] More about the report processing at https://open-sonar.forge.xxx.xxx.xx/api/ce/task?id=AXWNzrGEkp8uls_t5s3J
[INFO] Task total time: 9.093 s
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 15.929 s
[INFO] Finished at: 2020-11-03T12:12:14+01:00
[INFO] Final Memory: 24M/654M
[INFO] ------------------------------------------------------------------------
[INFO] [jenkins-event-spy] Generated /var/jenkins_home/workspace/appli-blanche-frontend_develop@tmp/withMaven1c3050b8/maven-spy-20201103-121158-6955937129738832034510.log
[Pipeline] }

Thank you for the logs.

Unfortunately, you’re using a version of SonarQube that is past EOL, and you’re going to have a hard time finding help with it.

You need to upgrade SonarQube at your earliest convenience to either the latest version (8.5.1) or the current LTS (7.9.4).

Coming back to your problem, there is something fishy when analysing the coverage file as depicted by the following log:

[WARNING] Could not resolve 31 file paths in [/var/jenkins_home/workspace/appli-blanche-frontend_develop/coverage/lcov.info], first unresolved path: src/polyfills.ts

Before digging that up further, I let you first upgrading your SonarQube setup, see if that changes anything, and come back to us if the issue persists.

Yassin