Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Exclude files in Sonar Code Coverage Analysis Test - Angular 7

How do I exclude ts.files in SonarQube Analysis for better Code Coverage.

I tried with with below code

"test": {
          "builder": "@angular-devkit/build-angular:karma",
          "options": {
            "main": "src/test.ts",
            "polyfills": "src/polyfills.ts",
            "tsConfig": "src/tsconfig.spec.json",
            "karmaConfig": "src/karma.conf.js",
            "codeCoverageExclude": [
              "src/app/user/about-report/about-report.component.ts"
            ],
          }
       }

But no luck its is getting analized in sonar. Can you help me out. I am using Angular 7.

like image 297
aryaa Avatar asked Oct 29 '25 16:10

aryaa


2 Answers

In sonar-project.properties , Try adding something like:

sonar.exclusions= **/*.spec.ts, **/*.ts, src/test/*
like image 114
Shashank Vivek Avatar answered Nov 01 '25 07:11

Shashank Vivek


There is the following directive that can be used in the sonar-project.properties file:

sonar.coverage.exclusions=src/main/webapp

Or via website, go to Administration > General Settings > Analysis Scope > Code Coverage and set the Coverage Exclusions property

like image 21
surfealokesea Avatar answered Nov 01 '25 05:11

surfealokesea



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!