Code coverage report not showing up for javascript/typescript app

I can’t see the javascript/typescript sensor in the sonarscan report as well.

Thanks in advance.

Hi,

Welcome to the community!

What format is your coverage report, and how are you passing it into analysis? sonar.javascript.lcov.reportPaths is the only recognized analysis parameter for JavaScript coverage.

 
HTH,
Ann

Hi Ann,
I am generating the lcov.info file using vitest coverage. This property is also set in sonar-project.properties

Thanks.

Hi,

Can you share your full analysis log?

The analysis / scanner log is what’s output from the analysis command. Hopefully, the log you provide - redacted as necessary - will include that command as well.

This guide will help you find them.

 
Ann

Hey,

Run SonarSource/sonarqube-scan-action@bfd4e558cda28cda6b5defafb9232d191be8c203
Run ${GITHUB_ACTION_PATH}/scripts/sanity-checks.sh
Run actions/cache@v4
Cache Size: ~50 MB (52578503 B)
/usr/bin/tar -xf /home/runner/work/_temp/7d8b6355-a868-4c82-8196-1f572c2cf179/cache.tzst -P -C /home/runner/work/formbricks/formbricks --use-compress-program unzstd
Cache restored successfully
Cache restored from key: sonar-scanner-cli-6.2.1.4610-Linux-X64
Run echo "${RUNNER_TEMP}/sonar-scanner-cli-6.2.1.4610-Linux-X64/bin" >> $GITHUB_PATH
Run ${GITHUB_ACTION_PATH}/scripts/run-sonar-scanner-cli.sh 
+ sonar-scanner
10:02:57.496 INFO  Scanner configuration file: /home/runner/work/_temp/sonar-scanner-cli-6.2.1.4610-Linux-X64/conf/sonar-scanner.properties
10:02:57.499 INFO  Project root configuration file: /home/runner/work/formbricks/formbricks/sonar-project.properties
10:02:57.512 INFO  SonarScanner CLI 6.2.1.4610
10:02:57.513 INFO  Java 17.0.12 Eclipse Adoptium (64-bit)
10:02:57.514 INFO  Linux 6.8.0-1020-azure amd64
10:02:57.537 INFO  User cache: /home/runner/.sonar/cache
10:02:58.010 INFO  JRE provisioning: os[linux], arch[x86_64]
10:03:01.479 INFO  Communicating with SonarCloud
10:03:01.744 INFO  Starting SonarScanner Engine...
10:03:01.745 INFO  Java 17.0.11 Eclipse Adoptium (64-bit)
10:03:02.423 INFO  Load global settings
10:03:02.763 INFO  Load global settings (done) | time=341ms
10:03:02.766 INFO  Server id: 1BD809FA-AWHW8ct9-T_TB3XqouNu
10:03:02.894 INFO  Loading required plugins
10:03:02.894 INFO  Load plugins index
10:03:03.012 INFO  Load plugins index (done) | time=119ms
10:03:03.013 INFO  Load/download plugins
10:03:03.647 INFO  Load/download plugins (done) | time=634ms
10:03:03.999 INFO  Found an active CI vendor: 'Github Actions'
10:03:04.008 INFO  Load project settings for component key: 'formbricks_formbricks'
10:03:04.148 INFO  Load project settings for component key: 'formbricks_formbricks' (done) | time=141ms
10:03:04.153 INFO  Process project properties
10:03:04.160 INFO  Project key: formbricks_formbricks
10:03:04.162 INFO  Base dir: /home/runner/work/formbricks/formbricks
10:03:04.162 INFO  Working dir: /home/runner/work/formbricks/formbricks/.scannerwork
10:03:04.165 INFO  Load project branches
10:03:04.343 INFO  Load project branches (done) | time=178ms
10:03:04.345 INFO  Check ALM binding of project 'formbricks_formbricks'
10:03:04.491 INFO  Detected project binding: BOUND
10:03:04.492 INFO  Check ALM binding of project 'formbricks_formbricks' (done) | time=146ms
10:03:04.493 INFO  Load project pull requests
10:03:04.986 INFO  Load project pull requests (done) | time=494ms
10:03:04.988 INFO  Load branch configuration
10:03:04.989 INFO  Github event: push
10:03:04.992 INFO  Auto-configuring branch main
10:03:04.992 INFO  Load branch configuration (done) | time=4ms
10:03:04.999 INFO  Load quality profiles
10:03:05.244 INFO  Load quality profiles (done) | time=244ms
10:03:05.249 INFO  Load active rules
10:03:13.498 INFO  Load active rules (done) | time=8249ms
10:03:13.648 INFO  Organization key: formbricks
10:03:13.649 INFO  Branch name: main, type: long-lived
10:03:13.661 INFO  Preprocessing files...
10:03:14.502 INFO  0 languages detected in 0 preprocessed files
10:03:14.505 INFO  11641 files ignored because of inclusion/exclusion patterns
10:03:14.506 INFO  0 files ignored because of scm ignore settings
10:03:14.522 INFO  Loading plugins for detected languages
10:03:14.524 INFO  Load/download plugins
10:03:14.526 INFO  Load/download plugins (done) | time=1ms
10:03:14.553 INFO  Load project repositories
10:03:14.727 INFO  Load project repositories (done) | time=175ms
10:03:14.729 INFO  Indexing files...
10:03:14.730 INFO  Project configuration:
10:03:14.730 INFO    Included sources: apps/web, packages/database, packages/lib, packages/types, packages/surveys
10:03:14.730 INFO    Excluded sources: **/build-wrapper-dump.json, apps/web, packages/lib, packages/database, packages/types, packages/surveys
10:03:14.730 INFO    Included tests: apps/web, packages/lib, packages/database, packages/types, packages/surveys
10:03:14.736 INFO  0 files indexed
10:03:14.737 INFO  ------------- Run sensors on module formbricks_formbricks
10:03:14.757 INFO  Load metrics repository
10:03:14.874 INFO  Load metrics repository (done) | time=118ms
10:03:14.877 INFO  Sensor cache enabled
10:03:14.961 INFO  Load sensor cache
10:03:15.906 INFO  Load sensor cache (404) | time=946ms
10:03:16.116 INFO  Sensor JaCoCo XML Report Importer [jacoco]
10:03:16.117 INFO  'sonar.coverage.jacoco.xmlReportPaths' is not defined. Using default locations: target/site/jacoco/jacoco.xml,target/site/jacoco-it/jacoco.xml,build/reports/jacoco/test/jacocoTestReport.xml
10:03:16.117 INFO  No report imported, no coverage information will be imported by JaCoCo XML Report Importer
10:03:16.117 INFO  Sensor JaCoCo XML Report Importer [jacoco] (done) | time=2ms
10:03:16.118 INFO  Sensor Java Config Sensor [iac]
10:03:16.146 INFO  0 source files to be analyzed
10:03:16.150 INFO  0/0 source files have been analyzed
10:03:16.151 INFO  Sensor Java Config Sensor [iac] (done) | time=34ms
10:03:16.153 INFO  Sensor IaC Docker Sensor [iac]
10:03:16.224 INFO  0 source files to be analyzed
10:03:16.227 INFO  0/0 source files have been analyzed
10:03:16.227 INFO  Sensor IaC Docker Sensor [iac] (done) | time=72ms
10:03:16.227 INFO  Sensor EnterpriseTextAndSecretsSensor [textenterprise]
10:03:16.228 INFO  Available processors: 4
10:03:16.228 INFO  Using 4 threads for analysis.
10:03:16.633 INFO  The property "sonar.tests" is not set. To improve the analysis accuracy, we categorize a file as a test file if any of the following is true:
  * The filename starts with "test"
  * The filename contains "test." or "tests."
  * Any directory in the file path is named: "doc", "docs", "test" or "tests"
  * Any directory in the file path has a name ending in "test" or "tests"

10:03:16.651 INFO  Using git CLI to retrieve untracked files
10:03:16.916 INFO  Analyzing language associated files and files included via "sonar.text.inclusions" that are tracked by git
10:03:16.916 INFO  Sensor EnterpriseTextAndSecretsSensor [textenterprise] (done) | time=692ms
10:03:16.918 INFO  ------------- Run sensors on project
10:03:17.015 INFO  Sensor Zero Coverage Sensor
10:03:17.015 INFO  Sensor Zero Coverage Sensor (done) | time=0ms
10:03:17.017 INFO  CPD Executor Calculating CPD for 0 files
10:03:17.018 INFO  CPD Executor CPD calculation finished (done) | time=0ms
10:03:32.831 INFO  Analysis report generated in 15812ms, dir size=267 KB
10:03:32.845 INFO  Analysis report compressed in 14ms, zip size=52 KB
10:03:33.188 INFO  Analysis report uploaded in 343ms
10:03:33.189 INFO  ANALYSIS SUCCESSFUL, you can find the results at: https://sonarcloud.io/dashboard?id=formbricks_formbricks&branch=main
10:03:33.189 INFO  Note that you will be able to access the updated dashboard once the server has processed the submitted analysis report
10:03:33.190 INFO  More about the report processing at https://sonarcloud.io/api/ce/task?id=AZTVkKEwZZ2UgdrUl2_j
10:03:33.193 INFO  Analysis total time: 29.375 s
10:03:33.193 INFO  SonarScanner Engine completed successfully
10:03:33.523 INFO  EXECUTION SUCCESS
10:03:33.524 INFO  Total time: 36.030s

These are the scanning logs. I am doing this on an open source project, Formbricks, you can check the config on the main branch of the repository as well.
Could you please help me debug the logs?

Hi,

What actually does show up in your analysis?

Because based on your logs, I would expect it to be entirely empty:

10:03:14.502 INFO  0 languages detected in 0 preprocessed files
...
10:03:14.736 INFO  0 files indexed

 
Ann

Yeah, I am also curious about this.
Why is this showing 0 files indexed? All the files are coming under exclusions, but there is no such property set.

Hi,

This started with coverage not showing up. But there can’t be coverage if there are no files. What does your analysis look like? Does anything show up?

The settings hierarchy is discussed here. You should figure out where your exclusions are set and, I suppose, clear them.

 
HTH,
Ann

Hey!
Thanks for being so patient, but I can’t really find any overriding settings for the file exclusions.
Is there anything which I should provide you to be able to better debug this issue?
I’m running the SonarSource/sonarqube-scan-action@bfd4e558cda28cda6b5defafb9232d191be8c203 in a github action, above was its output.
PS: formbricks is a monorepo, if it makes any difference.
Thanks

Hi,

Again,

Where did you look? Can you share screenshots?

 
Thx,
Ann

Hi Ann,
I checked the:

  1. sonar-project.properties file
  2. In the Administration > General Settings > Analysis scope
  3. Also in my workflow file
    attaching the screenshots for the same.

Thanks,
Piyush


Hi,

Thanks for that detail.

I know I asked for screenshots, but for text values like your pipeline, copy/paste is actually preferred. It’s easier to read and more fulsome. For instance your pipeline screenshot seems to cut off just when it gets interesting. What comes after SONAR_TOKEN?

And what is your SonarCloud plan? Do you perhaps have exclusions set at the organization level?

 
Ann

Hey!

Regarding the pipeline, it was the complete screenshot of the workflow.
I’m on the free plan currently. No exclusions on the Organization level (as they are already part of the paid feature too)

(Attachment sonarqube.yml is missing)

Hi,

Okay, I figured this out:

First, you’ve set sonar.sources to apps/web. That means the maximum analysis scope is only what’s under that directory.

Then you set, via the UI, inclusions on apps/web, and several packages subdirectories. But inclusions can’t add to the initial analysis scope; they can only carve portions out of it. So after your inclusions, your analysis scope is still apps/web.

Cool.

Then you set test inclusions.

You set exactly the same patterns here that you set for source inclusions.

But any given file can only be one or the other, source or test. Not both.

So what you’ve defined as tests: apps/web &etc., must not be source files. Therefore they should be excluded from consideration as source files. So analysis does that for you automatically.

 
HTH,
Ann

Hi,

It makes sense, but I tried removing the apps/web from both source file inclusion and test file inclusion, but it didn’t work.
I am required to generate the analysis report for all the mentioned paths, but I want to generate the coverage for apps/web only.

In the image, apps/web is not in the excluded sources; still, it says 0 indexed files

Thanks

Hi,

Can I have the full log in text format?

Also, could you clean out entirely all your inclusions and exclusions settings and try again?

 
Thx,
Ann

1 Like

Hey!

I just cleared out the inclusions settings from the UI, and it started working.
Thanks, Ann, for your patience and assistance.

Best,
Piyush

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