apex-code-coverage-transformer 2.4.0 → 2.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +15 -0
- package/README.md +123 -24
- package/lib/commands/acc-transformer/transform.d.ts +1 -1
- package/lib/commands/acc-transformer/transform.js +15 -8
- package/lib/commands/acc-transformer/transform.js.map +1 -1
- package/lib/handlers/cloverCoverageHandler.d.ts +7 -0
- package/lib/handlers/cloverCoverageHandler.js +77 -0
- package/lib/handlers/cloverCoverageHandler.js.map +1 -0
- package/lib/handlers/coberturaCoverageHandler.d.ts +8 -0
- package/lib/handlers/coberturaCoverageHandler.js +75 -0
- package/lib/handlers/coberturaCoverageHandler.js.map +1 -0
- package/lib/handlers/getCoverageHandler.d.ts +2 -0
- package/lib/handlers/getCoverageHandler.js +19 -0
- package/lib/handlers/getCoverageHandler.js.map +1 -0
- package/lib/handlers/lcovonlyCoverageHandler.d.ts +7 -0
- package/lib/handlers/lcovonlyCoverageHandler.js +37 -0
- package/lib/handlers/lcovonlyCoverageHandler.js.map +1 -0
- package/lib/handlers/sonarCoverageHandler.d.ts +7 -0
- package/lib/handlers/sonarCoverageHandler.js +38 -0
- package/lib/handlers/sonarCoverageHandler.js.map +1 -0
- package/lib/helpers/constants.js +1 -1
- package/lib/helpers/constants.js.map +1 -1
- package/lib/helpers/generateReport.d.ts +2 -0
- package/lib/helpers/generateReport.js +31 -0
- package/lib/helpers/generateReport.js.map +1 -0
- package/lib/helpers/setCoveredLinesClover.js +0 -9
- package/lib/helpers/setCoveredLinesClover.js.map +1 -1
- package/lib/helpers/setCoveredLinesLcov.d.ts +2 -0
- package/lib/helpers/setCoveredLinesLcov.js +24 -0
- package/lib/helpers/setCoveredLinesLcov.js.map +1 -0
- package/lib/helpers/transformDeployCoverageReport.js +8 -89
- package/lib/helpers/transformDeployCoverageReport.js.map +1 -1
- package/lib/helpers/transformTestCoverageReport.js +8 -88
- package/lib/helpers/transformTestCoverageReport.js.map +1 -1
- package/lib/helpers/types.d.ts +18 -1
- package/lib/hooks/postrun.js +4 -4
- package/lib/hooks/postrun.js.map +1 -1
- package/messages/transformer.transform.md +7 -6
- package/oclif.lock +523 -521
- package/oclif.manifest.json +12 -10
- package/package.json +5 -5
- package/lib/helpers/generateXml.d.ts +0 -2
- package/lib/helpers/generateXml.js +0 -14
- package/lib/helpers/generateXml.js.map +0 -1
- package/lib/helpers/initializeCoverageObject.d.ts +0 -5
- package/lib/helpers/initializeCoverageObject.js +0 -68
- package/lib/helpers/initializeCoverageObject.js.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,21 @@
|
|
|
5
5
|
|
|
6
6
|
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
|
7
7
|
|
|
8
|
+
## [2.5.0](https://github.com/mcarvin8/apex-code-coverage-transformer/compare/v2.4.1...v2.5.0) (2025-01-08)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Features
|
|
12
|
+
|
|
13
|
+
* add support for lcovonly info format ([a663cb2](https://github.com/mcarvin8/apex-code-coverage-transformer/commit/a663cb2db49e62a8c6cf278fe6a7e28c9e0a94c6))
|
|
14
|
+
* rename xml flag to output-report ([bb25a47](https://github.com/mcarvin8/apex-code-coverage-transformer/commit/bb25a478e285dc7de612368c51243e0525a71b02))
|
|
15
|
+
|
|
16
|
+
## [2.4.1](https://github.com/mcarvin8/apex-code-coverage-transformer/compare/v2.4.0...v2.4.1) (2024-12-22)
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
### Bug Fixes
|
|
20
|
+
|
|
21
|
+
* fix clover file level metrics in deploy reports ([cddded4](https://github.com/mcarvin8/apex-code-coverage-transformer/commit/cddded4f996771af1fafa07213f7e9866f4c1191))
|
|
22
|
+
|
|
8
23
|
## [2.4.0](https://github.com/mcarvin8/apex-code-coverage-transformer/compare/v2.3.0...v2.4.0) (2024-12-21)
|
|
9
24
|
|
|
10
25
|
|
package/README.md
CHANGED
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
- [Install](#install)
|
|
10
10
|
- [Who is the Plugin For?](#who-is-the-plugin-for)
|
|
11
11
|
- [Creating Code Coverage Files with the Salesforce CLI](#creating-code-coverage-files-with-the-salesforce-cli)
|
|
12
|
+
- [What this Plugin fixes in the Salesforce CLI Coverage Reports](#what-this-plugin-fixes-in-the-salesforce-cli-coverage-reports)
|
|
12
13
|
- [Command](#command)
|
|
13
14
|
- [`sf acc-transformer transform`](#sf-acc-transformer-transform)
|
|
14
15
|
- [Hook](#hook)
|
|
@@ -18,7 +19,7 @@
|
|
|
18
19
|
- [License](#license)
|
|
19
20
|
</details>
|
|
20
21
|
|
|
21
|
-
A Salesforce CLI plugin to transform the Apex code coverage JSON files created during deployments and test runs into SonarQube, Cobertura, or Clover format.
|
|
22
|
+
A Salesforce CLI plugin to transform the Apex code coverage JSON files created during deployments and test runs into SonarQube, Cobertura, LCovOnly, or Clover format.
|
|
22
23
|
|
|
23
24
|
## Install
|
|
24
25
|
|
|
@@ -32,11 +33,11 @@ This plugin is intended for users who deploy their Apex codebase (Apex classes a
|
|
|
32
33
|
|
|
33
34
|
This plugin will work if you run local tests or run all tests in an org, including tests that originate from installed managed and unlocked packages. Since files from managed and unlocked packages aren't retrieved into Salesforce DX repositories, these files cannot be included in your code coverage reports.
|
|
34
35
|
|
|
35
|
-
When the plugin is unable to find the Apex file from the Salesforce CLI coverage report in your repository, it will print a warning and not add that file's coverage data to the coverage
|
|
36
|
+
When the plugin is unable to find the Apex file from the Salesforce CLI coverage report in your repository, it will print a warning and not add that file's coverage data to the coverage report created by this plugin. A warning will be printed for each file not found in a package directory in your repository. See [Errors and Warnings](https://github.com/mcarvin8/apex-code-coverage-transformer?tab=readme-ov-file#errors-and-warnings) for more information.
|
|
36
37
|
|
|
37
38
|
## Creating Code Coverage Files with the Salesforce CLI
|
|
38
39
|
|
|
39
|
-
**This tool will only support the "json" coverage format from the Salesforce CLI. Do not use the "json-summary", "clover", or "cobertura" format from the Salesforce CLI.**
|
|
40
|
+
**This tool will only support the "json" coverage format from the Salesforce CLI. Do not use the "json-summary", "clover", "lcovonly", or "cobertura" format from the Salesforce CLI.**
|
|
40
41
|
|
|
41
42
|
To create the code coverage JSON when deploying or validating, append `--coverage-formatters json --results-dir "coverage"` to the `sf project deploy` command. This will create a coverage JSON in this relative path - `coverage/coverage/coverage.json`.
|
|
42
43
|
|
|
@@ -53,7 +54,18 @@ sf apex get test --test-run-id <test run id> --code-coverage --result-format jso
|
|
|
53
54
|
|
|
54
55
|
The code coverage JSONs created by the Salesforce CLI aren't accepted automatically for Salesforce DX repositories and needs to be converted using this plugin.
|
|
55
56
|
|
|
56
|
-
|
|
57
|
+
## What this Plugin fixes in the Salesforce CLI Coverage Reports
|
|
58
|
+
|
|
59
|
+
1. The coverage reports created by this plugin will add correct file-paths per your Salesforce DX repository. Salesforce CLI coverage reports have the `no-map/` prefix hard-coded into their coverage reports. The coverage report created in this plugin will only contain Apex coverage results against files found in your Salesforce DX repository, allowing you to use these reports in external code quality tools like SonarQube.
|
|
60
|
+
2. Normalizes the coverage reports created by the Salesforce CLI deploy and test command. The coverage reports created by both CLI commands follow different formats and have different coverage format options. These differences cause issues when trying to have external tools like SonarQube parse the coverage reports. This plugin handles parsing both command coverage reports and converting them into common formats accepted by external tools like SonarQube and GitLab.
|
|
61
|
+
3. The coverage reports created by this plugin "fixes" an issue with Salesforce CLI deploy command coverage reports. The coverage reports created by the deploy command contains several inaccuracies in their covered lines.
|
|
62
|
+
1. Salesforce's deploy covered report may report out-of-range lines as "covered", i.e. line 100 in a 98-line apex class is reported as "covered".
|
|
63
|
+
2. Salesforce's deploy covered report may report extra lines than the total lines in the apex class, i.e. 120 lines are included in the deploy coverage report for a 100-line apex class.
|
|
64
|
+
3. The coverage percentage may vary based on how many lines the API returns in the original deploy coverage report.
|
|
65
|
+
4. I had to add a re-numbering function to this plugin to work-around these inaccuracies and ensure the transformed coverage reports are accepted by external tools like SonarQube.
|
|
66
|
+
5. Once the Salesforce server team fixes the API to correctly return coverage in deploy command reports, I will remove this re-numbering function in this plugin.
|
|
67
|
+
6. See issues [5511](https://github.com/forcedotcom/salesforcedx-vscode/issues/5511) and [1568](https://github.com/forcedotcom/cli/issues/1568).
|
|
68
|
+
7. **NOTE**: This does not affect coverage reports created by the Salesforce CLI test commands.
|
|
57
69
|
|
|
58
70
|
## Command
|
|
59
71
|
|
|
@@ -65,35 +77,37 @@ The `apex-code-coverage-transformer` has 1 command:
|
|
|
65
77
|
|
|
66
78
|
```
|
|
67
79
|
USAGE
|
|
68
|
-
$ sf acc-transformer transform -j <value> -
|
|
80
|
+
$ sf acc-transformer transform -j <value> -r <value> -f <value> [--json]
|
|
69
81
|
|
|
70
82
|
FLAGS
|
|
71
83
|
-j, --coverage-json=<value> Path to the code coverage JSON file created by the Salesforce CLI deploy or test command.
|
|
72
|
-
-
|
|
73
|
-
[default: "coverage.xml"]
|
|
84
|
+
-r, --output-report=<value> Path to the code coverage file that will be created by this plugin.
|
|
85
|
+
[default: "coverage.[xml/info]"]
|
|
74
86
|
-f, --format=<value> Output format for the code coverage format.
|
|
75
|
-
Valid options are "sonar", "clover", or "cobertura".
|
|
87
|
+
Valid options are "sonar", "clover", "lcovonly", or "cobertura".
|
|
76
88
|
[default: "sonar"]
|
|
77
89
|
|
|
78
90
|
GLOBAL FLAGS
|
|
79
91
|
--json Format output as json.
|
|
80
92
|
|
|
81
93
|
DESCRIPTION
|
|
82
|
-
Transform the Apex code coverage JSON file created by the Salesforce CLI deploy and test command into SonarQube, Clover, or Cobertura format.
|
|
94
|
+
Transform the Apex code coverage JSON file created by the Salesforce CLI deploy and test command into SonarQube, Clover, LCovOnly, or Cobertura format.
|
|
83
95
|
|
|
84
96
|
EXAMPLES
|
|
85
|
-
$ sf acc-transformer transform -j "coverage.json" -
|
|
97
|
+
$ sf acc-transformer transform -j "coverage.json" -r "coverage.xml" -f "sonar"
|
|
98
|
+
|
|
99
|
+
$ sf acc-transformer transform -j "coverage.json" -r "coverage.xml" -f "cobertura"
|
|
86
100
|
|
|
87
|
-
$ sf acc-transformer transform -j "coverage.json" -
|
|
101
|
+
$ sf acc-transformer transform -j "coverage.json" -r "coverage.xml" -f "clover"
|
|
88
102
|
|
|
89
|
-
$ sf acc-transformer transform -j "coverage.json" -
|
|
103
|
+
$ sf acc-transformer transform -j "coverage.json" -r "coverage.info" -f "lcovonly"
|
|
90
104
|
```
|
|
91
105
|
|
|
92
106
|
## Hook
|
|
93
107
|
|
|
94
108
|
A post-run hook has been configured if you elect to use it.
|
|
95
109
|
|
|
96
|
-
The post-run hook will automatically transform the code coverage JSON file
|
|
110
|
+
The post-run hook will automatically transform the code coverage JSON file after every Salesforce CLI deployment (`sf project deploy start`, `sf project deploy validate`, `sf project deploy report`, `sf project deploy resume` commands) and test run (`sf apex run test` and `sf apex get test` commands) if the JSON is found.
|
|
97
111
|
|
|
98
112
|
The hook requires you to create this file in the root of your repo: `.apexcodecovtransformer.config.json`
|
|
99
113
|
|
|
@@ -103,15 +117,15 @@ The `.apexcodecovtransformer.config.json` should look like this:
|
|
|
103
117
|
{
|
|
104
118
|
"deployCoverageJsonPath": "coverage/coverage/coverage.json",
|
|
105
119
|
"testCoverageJsonPath": "coverage/test-coverage.json",
|
|
106
|
-
"
|
|
120
|
+
"outputReportPath": "coverage.xml",
|
|
107
121
|
"format": "sonar"
|
|
108
122
|
}
|
|
109
123
|
```
|
|
110
124
|
|
|
111
125
|
- `deployCoverageJsonPath` is required to use the hook after deployments and should be the path to the code coverage JSON created by the Salesforce CLI deployment command. Recommend using a relative path.
|
|
112
126
|
- `testCoverageJsonPath` is required to use the hook after test runs and should be the path to the code coverage JSON created by the Salesforce CLI test command. Recommend using a relative path.
|
|
113
|
-
- `
|
|
114
|
-
- `format` is optional and should be the intended output format for the code coverage
|
|
127
|
+
- `outputReportPath` is optional and should be the path to the code coverage file created by this plugin. Recommend using a relative path. If this isn't provided, it will default to `coverage.[xml/info]` in the working directory.
|
|
128
|
+
- `format` is optional and should be the intended output format for the code coverage file created by this plugin. Options are "sonar", "clover", or "cobertura". If this isn't provided, it will default to "sonar".
|
|
115
129
|
|
|
116
130
|
If the `.apexcodecovtransformer.config.json` file isn't found, the hook will be skipped.
|
|
117
131
|
|
|
@@ -123,14 +137,14 @@ Any file in the coverage JSON that isn't found in any package directory will res
|
|
|
123
137
|
Warning: The file name AccountTrigger was not found in any package directory.
|
|
124
138
|
```
|
|
125
139
|
|
|
126
|
-
Files not found in any package directory will not be added to the coverage
|
|
140
|
+
Files not found in any package directory will not be added to the output coverage report. This includes Apex classes that originate from installed managed and unlocked packages when running all tests in your org.
|
|
127
141
|
|
|
128
|
-
If none of the files listed in the coverage JSON were found in a package directory, the plugin will print an additional warning stating no files were processed. In this case, the coverage
|
|
142
|
+
If none of the files listed in the coverage JSON were found in a package directory, the plugin will print an additional warning stating no files were processed. In this case, the output coverage report generated will be an empty file.
|
|
129
143
|
|
|
130
144
|
```
|
|
131
145
|
Warning: The file name AccountTrigger was not found in any package directory.
|
|
132
146
|
Warning: The file name AccountProfile was not found in any package directory.
|
|
133
|
-
Warning: None of the files listed in the coverage JSON were processed. The coverage
|
|
147
|
+
Warning: None of the files listed in the coverage JSON were processed. The coverage report will be empty.
|
|
134
148
|
```
|
|
135
149
|
|
|
136
150
|
The code coverage JSON files created by the Salesforce CLI deployment commands follow a different format than the code coverage files created by the test commands. If the code coverage JSON file provided does not match one of the 2 expected coverage data types, the plugin will fail with:
|
|
@@ -232,7 +246,7 @@ and this format for Cobertura:
|
|
|
232
246
|
```xml
|
|
233
247
|
<?xml version="1.0" ?>
|
|
234
248
|
<!DOCTYPE coverage SYSTEM "http://cobertura.sourceforge.net/xml/coverage-04.dtd">
|
|
235
|
-
<coverage lines-valid="62" lines-covered="54" line-rate="0.871" branches-valid="0" branches-covered="0" branch-rate="1" timestamp="
|
|
249
|
+
<coverage lines-valid="62" lines-covered="54" line-rate="0.871" branches-valid="0" branches-covered="0" branch-rate="1" timestamp="1736198880235" complexity="0" version="0.1">
|
|
236
250
|
<sources>
|
|
237
251
|
<source>.</source>
|
|
238
252
|
</sources>
|
|
@@ -321,11 +335,11 @@ and this format for Clover:
|
|
|
321
335
|
|
|
322
336
|
```xml
|
|
323
337
|
<?xml version="1.0" encoding="UTF-8"?>
|
|
324
|
-
<coverage generated="
|
|
325
|
-
<project timestamp="
|
|
338
|
+
<coverage generated="1736198880331" clover="3.2.0">
|
|
339
|
+
<project timestamp="1736198880331" name="All files">
|
|
326
340
|
<metrics statements="62" coveredstatements="54" conditionals="0" coveredconditionals="0" methods="0" coveredmethods="0" elements="62" coveredelements="54" complexity="0" loc="62" ncloc="62" packages="1" files="2" classes="2"/>
|
|
327
341
|
<file name="AccountTrigger" path="packaged/triggers/AccountTrigger.trigger">
|
|
328
|
-
<metrics statements="
|
|
342
|
+
<metrics statements="31" coveredstatements="27" conditionals="0" coveredconditionals="0" methods="0" coveredmethods="0"/>
|
|
329
343
|
<line num="52" count="0" type="stmt"/>
|
|
330
344
|
<line num="53" count="0" type="stmt"/>
|
|
331
345
|
<line num="59" count="0" type="stmt"/>
|
|
@@ -359,7 +373,7 @@ and this format for Clover:
|
|
|
359
373
|
<line num="27" count="1" type="stmt"/>
|
|
360
374
|
</file>
|
|
361
375
|
<file name="AccountProfile" path="force-app/main/default/classes/AccountProfile.cls">
|
|
362
|
-
<metrics statements="
|
|
376
|
+
<metrics statements="31" coveredstatements="27" conditionals="0" coveredconditionals="0" methods="0" coveredmethods="0"/>
|
|
363
377
|
<line num="52" count="0" type="stmt"/>
|
|
364
378
|
<line num="53" count="0" type="stmt"/>
|
|
365
379
|
<line num="59" count="0" type="stmt"/>
|
|
@@ -396,6 +410,91 @@ and this format for Clover:
|
|
|
396
410
|
</coverage>
|
|
397
411
|
```
|
|
398
412
|
|
|
413
|
+
and this format for LCovOnly:
|
|
414
|
+
|
|
415
|
+
```info
|
|
416
|
+
TN:
|
|
417
|
+
SF:packaged/triggers/AccountTrigger.trigger
|
|
418
|
+
FNF:0
|
|
419
|
+
FNH:0
|
|
420
|
+
DA:52,0
|
|
421
|
+
DA:53,0
|
|
422
|
+
DA:59,0
|
|
423
|
+
DA:60,0
|
|
424
|
+
DA:1,1
|
|
425
|
+
DA:2,1
|
|
426
|
+
DA:3,1
|
|
427
|
+
DA:4,1
|
|
428
|
+
DA:5,1
|
|
429
|
+
DA:6,1
|
|
430
|
+
DA:7,1
|
|
431
|
+
DA:8,1
|
|
432
|
+
DA:9,1
|
|
433
|
+
DA:10,1
|
|
434
|
+
DA:11,1
|
|
435
|
+
DA:12,1
|
|
436
|
+
DA:13,1
|
|
437
|
+
DA:14,1
|
|
438
|
+
DA:15,1
|
|
439
|
+
DA:16,1
|
|
440
|
+
DA:17,1
|
|
441
|
+
DA:18,1
|
|
442
|
+
DA:19,1
|
|
443
|
+
DA:20,1
|
|
444
|
+
DA:21,1
|
|
445
|
+
DA:22,1
|
|
446
|
+
DA:23,1
|
|
447
|
+
DA:24,1
|
|
448
|
+
DA:25,1
|
|
449
|
+
DA:26,1
|
|
450
|
+
DA:27,1
|
|
451
|
+
LF:31
|
|
452
|
+
LH:27
|
|
453
|
+
BRF:0
|
|
454
|
+
BRH:0
|
|
455
|
+
end_of_record
|
|
456
|
+
TN:
|
|
457
|
+
SF:force-app/main/default/classes/AccountProfile.cls
|
|
458
|
+
FNF:0
|
|
459
|
+
FNH:0
|
|
460
|
+
DA:52,0
|
|
461
|
+
DA:53,0
|
|
462
|
+
DA:59,0
|
|
463
|
+
DA:60,0
|
|
464
|
+
DA:54,1
|
|
465
|
+
DA:55,1
|
|
466
|
+
DA:56,1
|
|
467
|
+
DA:57,1
|
|
468
|
+
DA:58,1
|
|
469
|
+
DA:61,1
|
|
470
|
+
DA:62,1
|
|
471
|
+
DA:63,1
|
|
472
|
+
DA:64,1
|
|
473
|
+
DA:65,1
|
|
474
|
+
DA:66,1
|
|
475
|
+
DA:67,1
|
|
476
|
+
DA:68,1
|
|
477
|
+
DA:69,1
|
|
478
|
+
DA:70,1
|
|
479
|
+
DA:71,1
|
|
480
|
+
DA:72,1
|
|
481
|
+
DA:1,1
|
|
482
|
+
DA:2,1
|
|
483
|
+
DA:3,1
|
|
484
|
+
DA:4,1
|
|
485
|
+
DA:5,1
|
|
486
|
+
DA:6,1
|
|
487
|
+
DA:7,1
|
|
488
|
+
DA:8,1
|
|
489
|
+
DA:9,1
|
|
490
|
+
DA:10,1
|
|
491
|
+
LF:31
|
|
492
|
+
LH:27
|
|
493
|
+
BRF:0
|
|
494
|
+
BRH:0
|
|
495
|
+
end_of_record
|
|
496
|
+
```
|
|
497
|
+
|
|
399
498
|
## Issues
|
|
400
499
|
|
|
401
500
|
If you encounter any issues, please create an issue in the repository's [issue tracker](https://github.com/mcarvin8/apex-code-coverage-transformer/issues). Please also create issues to suggest any new features.
|
|
@@ -6,7 +6,7 @@ export default class TransformerTransform extends SfCommand<TransformerTransform
|
|
|
6
6
|
static readonly examples: string[];
|
|
7
7
|
static readonly flags: {
|
|
8
8
|
'coverage-json': import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
9
|
-
|
|
9
|
+
'output-report': import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
10
10
|
format: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
11
11
|
};
|
|
12
12
|
run(): Promise<TransformerTransformResult>;
|
|
@@ -20,9 +20,9 @@ export default class TransformerTransform extends SfCommand {
|
|
|
20
20
|
required: true,
|
|
21
21
|
exists: true,
|
|
22
22
|
}),
|
|
23
|
-
|
|
24
|
-
summary: messages.getMessage('flags.
|
|
25
|
-
char: '
|
|
23
|
+
'output-report': Flags.file({
|
|
24
|
+
summary: messages.getMessage('flags.output-report.summary'),
|
|
25
|
+
char: 'r',
|
|
26
26
|
required: true,
|
|
27
27
|
exists: false,
|
|
28
28
|
default: 'coverage.xml',
|
|
@@ -39,7 +39,7 @@ export default class TransformerTransform extends SfCommand {
|
|
|
39
39
|
async run() {
|
|
40
40
|
const { flags } = await this.parse(TransformerTransform);
|
|
41
41
|
const jsonFilePath = resolve(flags['coverage-json']);
|
|
42
|
-
|
|
42
|
+
let outputReportPath = resolve(flags['output-report']);
|
|
43
43
|
const format = flags['format'];
|
|
44
44
|
const jsonData = await readFile(jsonFilePath, 'utf-8');
|
|
45
45
|
let xmlData;
|
|
@@ -70,11 +70,18 @@ export default class TransformerTransform extends SfCommand {
|
|
|
70
70
|
});
|
|
71
71
|
}
|
|
72
72
|
if (filesProcessed === 0) {
|
|
73
|
-
this.warn('None of the files listed in the coverage JSON were processed. The coverage
|
|
73
|
+
this.warn('None of the files listed in the coverage JSON were processed. The coverage report will be empty.');
|
|
74
74
|
}
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
75
|
+
// Adjust the output file extension if the format is lcovonly
|
|
76
|
+
if (format === 'lcovonly' && !outputReportPath.endsWith('.info')) {
|
|
77
|
+
outputReportPath = outputReportPath.replace(/\.xml$/, '.info'); // Replace .xml with .info if it exists
|
|
78
|
+
if (!outputReportPath.endsWith('.info')) {
|
|
79
|
+
outputReportPath += '.info'; // Ensure the extension is .info
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
await writeFile(outputReportPath, xmlData);
|
|
83
|
+
this.log(`The coverage report has been written to ${outputReportPath}`);
|
|
84
|
+
return { path: outputReportPath };
|
|
78
85
|
}
|
|
79
86
|
}
|
|
80
87
|
//# sourceMappingURL=transform.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transform.js","sourceRoot":"","sources":["../../../src/commands/acc-transformer/transform.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAEb,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAEvD,OAAO,EAAE,SAAS,EAAE,KAA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AAQ,CAAC;YAC3B,cAAc,GAAG,MAAM,CAAC,cAAc,CAAC;QACzC,CAAC;aAAM,CAAC;YACN,IAAI,CAAC,KAAK,CACR,2GAA2G,CAC5G,CAAC;QACJ,CAAC;QAED,wBAAwB;QACxB,IAAI,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACxB,QAAQ,CAAC,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;gBAC3B,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;YACrB,CAAC,CAAC,CAAC;QACL,CAAC;QAED,IAAI,cAAc,KAAK,CAAC,EAAE,CAAC;YACzB,IAAI,CAAC,IAAI,CAAC,kGAAkG,CAAC,CAAC;QAChH,CAAC;QAED,6DAA6D;QAC7D,IAAI,MAAM,KAAK,UAAU,IAAI,CAAC,gBAAgB,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC;YACjE,gBAAgB,GAAG,gBAAgB,CAAC,OAAO,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC,CAAC,uCAAuC;YACvG,IAAI,CAAC,gBAAgB,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC;gBACxC,gBAAgB,IAAI,OAAO,CAAC,CAAC,gCAAgC;YAC/D,CAAC;QACH,CAAC;QAED,MAAM,SAAS,CAAC,gBAAgB,EAAE,OAAO,CAAC,CAAC;QAC3C,IAAI,CAAC,GAAG,CAAC,2CAA2C,gBAAgB,EAAE,CAAC,CAAC;QACxE,OAAO,EAAE,IAAI,EAAE,gBAAgB,EAAE,CAAC;IACpC,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { CloverCoverageObject, CoverageHandler } from '../helpers/types.js';
|
|
2
|
+
export declare class CloverCoverageHandler implements CoverageHandler {
|
|
3
|
+
private readonly coverageObj;
|
|
4
|
+
constructor();
|
|
5
|
+
processFile(filePath: string, fileName: string, lines: Record<string, number>, uncoveredLines: number[], coveredLines: number[], repoRoot: string, reportType: 'test' | 'deploy'): Promise<void>;
|
|
6
|
+
finalize(): CloverCoverageObject;
|
|
7
|
+
}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
import { setCoveredLinesClover } from '../helpers/setCoveredLinesClover.js';
|
|
3
|
+
import { normalizePathToUnix } from '../helpers/normalizePathToUnix.js';
|
|
4
|
+
export class CloverCoverageHandler {
|
|
5
|
+
coverageObj;
|
|
6
|
+
constructor() {
|
|
7
|
+
this.coverageObj = {
|
|
8
|
+
coverage: {
|
|
9
|
+
'@generated': Date.now(),
|
|
10
|
+
'@clover': '3.2.0',
|
|
11
|
+
project: {
|
|
12
|
+
'@timestamp': Date.now(),
|
|
13
|
+
'@name': 'All files',
|
|
14
|
+
metrics: {
|
|
15
|
+
'@statements': 0,
|
|
16
|
+
'@coveredstatements': 0,
|
|
17
|
+
'@conditionals': 0,
|
|
18
|
+
'@coveredconditionals': 0,
|
|
19
|
+
'@methods': 0,
|
|
20
|
+
'@coveredmethods': 0,
|
|
21
|
+
'@elements': 0,
|
|
22
|
+
'@coveredelements': 0,
|
|
23
|
+
'@complexity': 0,
|
|
24
|
+
'@loc': 0,
|
|
25
|
+
'@ncloc': 0,
|
|
26
|
+
'@packages': 1,
|
|
27
|
+
'@files': 0,
|
|
28
|
+
'@classes': 0,
|
|
29
|
+
},
|
|
30
|
+
file: [],
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
async processFile(filePath, fileName, lines, uncoveredLines, coveredLines, repoRoot, reportType) {
|
|
36
|
+
const fileObj = {
|
|
37
|
+
'@name': fileName,
|
|
38
|
+
'@path': normalizePathToUnix(filePath),
|
|
39
|
+
metrics: {
|
|
40
|
+
'@statements': uncoveredLines.length + coveredLines.length,
|
|
41
|
+
'@coveredstatements': coveredLines.length,
|
|
42
|
+
'@conditionals': 0,
|
|
43
|
+
'@coveredconditionals': 0,
|
|
44
|
+
'@methods': 0,
|
|
45
|
+
'@coveredmethods': 0,
|
|
46
|
+
},
|
|
47
|
+
line: [],
|
|
48
|
+
};
|
|
49
|
+
if (reportType === 'test') {
|
|
50
|
+
for (const [lineNumber, isCovered] of Object.entries(lines)) {
|
|
51
|
+
fileObj.line.push({
|
|
52
|
+
'@num': Number(lineNumber),
|
|
53
|
+
'@count': isCovered === 1 ? 1 : 0,
|
|
54
|
+
'@type': 'stmt',
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
else if (reportType === 'deploy') {
|
|
59
|
+
fileObj.line = [...uncoveredLines.map((lineNumber) => ({ '@num': lineNumber, '@count': 0, '@type': 'stmt' }))];
|
|
60
|
+
await setCoveredLinesClover(coveredLines, uncoveredLines, repoRoot, filePath, fileObj);
|
|
61
|
+
}
|
|
62
|
+
this.coverageObj.coverage.project.file.push(fileObj);
|
|
63
|
+
const projectMetrics = this.coverageObj.coverage.project.metrics;
|
|
64
|
+
projectMetrics['@statements'] += uncoveredLines.length + coveredLines.length;
|
|
65
|
+
projectMetrics['@coveredstatements'] += coveredLines.length;
|
|
66
|
+
projectMetrics['@elements'] += uncoveredLines.length + coveredLines.length;
|
|
67
|
+
projectMetrics['@coveredelements'] += coveredLines.length;
|
|
68
|
+
projectMetrics['@files'] += 1;
|
|
69
|
+
projectMetrics['@classes'] += 1;
|
|
70
|
+
projectMetrics['@loc'] += uncoveredLines.length + coveredLines.length;
|
|
71
|
+
projectMetrics['@ncloc'] += uncoveredLines.length + coveredLines.length;
|
|
72
|
+
}
|
|
73
|
+
finalize() {
|
|
74
|
+
return this.coverageObj;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
//# sourceMappingURL=cloverCoverageHandler.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cloverCoverageHandler.js","sourceRoot":"","sources":["../../src/handlers/cloverCoverageHandler.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAGb,OAAO,EAAE,qBAAqB,EAAE,MAAM,qC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QAC1D,cAAc,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;QAC9B,cAAc,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;QAChC,cAAc,CAAC,MAAM,CAAC,IAAI,cAAc,CAAC,MAAM,GAAG,YAAY,CAAC,MAAM,CAAC;QACtE,cAAc,CAAC,QAAQ,CAAC,IAAI,cAAc,CAAC,MAAM,GAAG,YAAY,CAAC,MAAM,CAAC;IAC1E,CAAC;IAEM,QAAQ;QACb,OAAO,IAAI,CAAC,WAAW,CAAC;IAC1B,CAAC;CACF"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { CoberturaCoverageObject, CoverageHandler } from '../helpers/types.js';
|
|
2
|
+
export declare class CoberturaCoverageHandler implements CoverageHandler {
|
|
3
|
+
private readonly coverageObj;
|
|
4
|
+
private packageObj;
|
|
5
|
+
constructor();
|
|
6
|
+
processFile(filePath: string, fileName: string, lines: Record<string, number>, uncoveredLines: number[], coveredLines: number[], repoRoot: string, reportType: 'test' | 'deploy'): Promise<void>;
|
|
7
|
+
finalize(): CoberturaCoverageObject;
|
|
8
|
+
}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
import { setCoveredLinesCobertura } from '../helpers/setCoveredLinesCobertura.js';
|
|
3
|
+
import { normalizePathToUnix } from '../helpers/normalizePathToUnix.js';
|
|
4
|
+
export class CoberturaCoverageHandler {
|
|
5
|
+
coverageObj;
|
|
6
|
+
packageObj;
|
|
7
|
+
constructor() {
|
|
8
|
+
this.coverageObj = {
|
|
9
|
+
coverage: {
|
|
10
|
+
'@lines-valid': 0,
|
|
11
|
+
'@lines-covered': 0,
|
|
12
|
+
'@line-rate': 0,
|
|
13
|
+
'@branches-valid': 0,
|
|
14
|
+
'@branches-covered': 0,
|
|
15
|
+
'@branch-rate': 1,
|
|
16
|
+
'@timestamp': Date.now(),
|
|
17
|
+
'@complexity': 0,
|
|
18
|
+
'@version': '0.1',
|
|
19
|
+
sources: { source: ['.'] },
|
|
20
|
+
packages: { package: [] },
|
|
21
|
+
},
|
|
22
|
+
};
|
|
23
|
+
this.packageObj = {
|
|
24
|
+
'@name': 'main',
|
|
25
|
+
'@line-rate': 0,
|
|
26
|
+
'@branch-rate': 1,
|
|
27
|
+
classes: { class: [] },
|
|
28
|
+
};
|
|
29
|
+
this.coverageObj.coverage.packages.package.push(this.packageObj);
|
|
30
|
+
}
|
|
31
|
+
async processFile(filePath, fileName, lines, uncoveredLines, coveredLines, repoRoot, reportType) {
|
|
32
|
+
const classObj = {
|
|
33
|
+
'@name': fileName,
|
|
34
|
+
'@filename': normalizePathToUnix(filePath),
|
|
35
|
+
'@line-rate': '0',
|
|
36
|
+
'@branch-rate': '1',
|
|
37
|
+
methods: {},
|
|
38
|
+
lines: { line: [] },
|
|
39
|
+
};
|
|
40
|
+
const totalLines = uncoveredLines.length + coveredLines.length;
|
|
41
|
+
const coveredLineCount = coveredLines.length;
|
|
42
|
+
// Process lines for 'test' or 'deploy' reports
|
|
43
|
+
if (reportType === 'test') {
|
|
44
|
+
for (const [lineNumber, isCovered] of Object.entries(lines)) {
|
|
45
|
+
classObj.lines.line.push({
|
|
46
|
+
'@number': Number(lineNumber),
|
|
47
|
+
'@hits': isCovered === 1 ? 1 : 0,
|
|
48
|
+
'@branch': 'false',
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
else if (reportType === 'deploy') {
|
|
53
|
+
classObj.lines.line = uncoveredLines.map((lineNumber) => ({
|
|
54
|
+
'@number': lineNumber,
|
|
55
|
+
'@hits': 0,
|
|
56
|
+
'@branch': 'false',
|
|
57
|
+
}));
|
|
58
|
+
await setCoveredLinesCobertura(coveredLines, uncoveredLines, repoRoot, filePath, classObj);
|
|
59
|
+
}
|
|
60
|
+
// Calculate and set the line rate for this class
|
|
61
|
+
if (totalLines > 0) {
|
|
62
|
+
const lineRate = (coveredLineCount / totalLines).toFixed(4);
|
|
63
|
+
classObj['@line-rate'] = lineRate;
|
|
64
|
+
}
|
|
65
|
+
this.coverageObj.coverage['@lines-valid'] += totalLines;
|
|
66
|
+
this.coverageObj.coverage['@lines-covered'] += coveredLineCount;
|
|
67
|
+
this.packageObj['@line-rate'] = Number((this.coverageObj.coverage['@lines-covered'] / this.coverageObj.coverage['@lines-valid']).toFixed(4));
|
|
68
|
+
this.coverageObj.coverage['@line-rate'] = this.packageObj['@line-rate'];
|
|
69
|
+
this.packageObj.classes.class.push(classObj);
|
|
70
|
+
}
|
|
71
|
+
finalize() {
|
|
72
|
+
return this.coverageObj;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
//# sourceMappingURL=coberturaCoverageHandler.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"coberturaCoverageHandler.js","sourceRoot":"","sources":["../../src/handlers/coberturaCoverageHandler.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAGb,OAAO,EAAE,wBAAwB,EAAE,MAAM,wCAAwC,CAAC;AAClF,OAAO,EAAE,mBAAmB,EAAE,MAAM,mCAAmC,CAAC;AAExE,MAAM,OAAO,wBAAwB;IAClB,WAAW,CAA0B;IAC9C,UAAU,CAAmB;IAErC;QACE,IAAI,CAAC,WAAW,GAAG;YACjB,QAAQ,EAAE;gBACR,cAAc,EAAE,CAAC;gBACjB,gBAAgB,EAAE,CAAC;gBACnB,YAAY,EAAE,CAAC;gBACf,iBAAiB,EAAE,CAAC;gBACpB,mBAAmB,EAAE,CAAC;gBACtB,cAAc,EAAE,CAAC;gBACjB,YAAY,EAAE,IAAI,CAAC,GAAG,EAAE;gBACxB,aAAa,EAAE,CAAC;gBAChB,UAAU,EAAE,KAAK;gBACjB,OAAO,EAAE,EAAE,MAAM,EAAE,CAAC,GAAG,CAAC,EAAE;gBAC1B,QAAQ,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE;aAC1B;SACF,CAAC;QACF,IAAI,CAAC,UAAU,GAAG;YAChB,OAAO,EAAE,MAAM;YACf,Y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
|
|
4
|
+
import { SonarCoverageHandler } from './sonarCoverageHandler.js';
|
|
5
|
+
import { LcovCoverageHandler } from './lcovonlyCoverageHandler.js';
|
|
6
|
+
export function getCoverageHandler(format) {
|
|
7
|
+
const handlers = {
|
|
8
|
+
sonar: new SonarCoverageHandler(),
|
|
9
|
+
cobertura: new CoberturaCoverageHandler(),
|
|
10
|
+
clover: new CloverCoverageHandler(),
|
|
11
|
+
lcovonly: new LcovCoverageHandler(),
|
|
12
|
+
};
|
|
13
|
+
const handler = handlers[format];
|
|
14
|
+
if (!handler) {
|
|
15
|
+
throw new Error(`Unsupported format: ${format}`);
|
|
16
|
+
}
|
|
17
|
+
return handler;
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=getCoverageHandler.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getCoverageHandler.js","sourceRoot":"","sources":["../../src/handlers/getCoverageHandler.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAGb,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AACnE,OAAO,EAAE,wBAAwB,EAAE,MAAM,+BAA+B,CAAC;AACzE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AACjE,OAAO,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAC;AAEnE,MAAM,UAAU,kBAAkB,CAAC,MAAc;IAC/C,MAAM,QAAQ,GAAoC;QAChD,KAAK,EAAE,IAAI,oBAAoB,EAAE;QACjC,SAAS,EAAE,IAAI,wBAAwB,EAAE;QACzC,MAAM,EAAE,IAAI,qBAAqB,EAAE;QACnC,QAAQ,EAAE,IAAI,mBAAmB,EAAE;KACpC,CAAC;IAEF,MAAM,OAAO,GAAG,QAAQ,CAAC,MAAM,CAAC,CAAC;IACjC,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,MAAM,IAAI,KAAK,CAAC,uBAAuB,MAAM,EAAE,CAAC,CAAC;IACnD,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { CoverageHandler, LcovCoverageObject } from '../helpers/types.js';
|
|
2
|
+
export declare class LcovCoverageHandler implements CoverageHandler {
|
|
3
|
+
private readonly coverageObj;
|
|
4
|
+
constructor();
|
|
5
|
+
processFile(filePath: string, fileName: string, lines: Record<string, number>, uncoveredLines: number[], coveredLines: number[], repoRoot: string, reportType: 'test' | 'deploy'): Promise<void>;
|
|
6
|
+
finalize(): LcovCoverageObject;
|
|
7
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
import { setCoveredLinesLcov } from '../helpers/setCoveredLinesLcov.js';
|
|
3
|
+
import { normalizePathToUnix } from '../helpers/normalizePathToUnix.js';
|
|
4
|
+
export class LcovCoverageHandler {
|
|
5
|
+
coverageObj;
|
|
6
|
+
constructor() {
|
|
7
|
+
this.coverageObj = { files: [] };
|
|
8
|
+
}
|
|
9
|
+
async processFile(filePath, fileName, lines, uncoveredLines, coveredLines, repoRoot, reportType) {
|
|
10
|
+
const lcovFile = {
|
|
11
|
+
sourceFile: normalizePathToUnix(filePath),
|
|
12
|
+
lines: [],
|
|
13
|
+
totalLines: uncoveredLines.length + coveredLines.length,
|
|
14
|
+
coveredLines: coveredLines.length,
|
|
15
|
+
};
|
|
16
|
+
if (reportType === 'test') {
|
|
17
|
+
for (const [lineNumber, isCovered] of Object.entries(lines)) {
|
|
18
|
+
lcovFile.lines.push({
|
|
19
|
+
lineNumber: Number(lineNumber),
|
|
20
|
+
hitCount: isCovered === 1 ? 1 : 0,
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
else if (reportType === 'deploy') {
|
|
25
|
+
lcovFile.lines = uncoveredLines.map((lineNumber) => ({
|
|
26
|
+
lineNumber: Number(lineNumber),
|
|
27
|
+
hitCount: 0,
|
|
28
|
+
}));
|
|
29
|
+
await setCoveredLinesLcov(coveredLines, uncoveredLines, repoRoot, filePath, lcovFile);
|
|
30
|
+
}
|
|
31
|
+
this.coverageObj.files.push(lcovFile);
|
|
32
|
+
}
|
|
33
|
+
finalize() {
|
|
34
|
+
return this.coverageObj;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=lcovonlyCoverageHandler.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lcovonlyCoverageHandler.js","sourceRoot":"","sources":["../../src/handlers/lcovonlyCoverageHandler.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAGb,OAAO,EAAE,mBAAmB,EAAE,MAAM,mCAAmC,CAAC;AACxE,OAAO,EAAE,mBAAmB,EAAE,MAAM,mCAAmC,CAAC;AAExE,MAAM,OAAO,mBAAmB;IACb,WAAW,CAAqB;IAEjD;QACE,IAAI,CAAC,WAAW,GAAG,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC;IACnC,CAAC;IAEM,KAAK,CAAC,WAAW,CACtB,QAAgB,EAChB,QAAgB,EAChB,KAA6B,EAC7B,cAAwB,EACxB,YAAsB,EACtB,QAAgB,EAChB,UAA6B;QAE7B,MAAM,QAAQ,GAAa;YACzB,UAAU,EAAE,mBAAmB,CAAC,QAAQ,CAAC;YACzC,KAAK,EAAE,EAAE;YACT,UAAU,EAAE,cAAc,CAAC,MAAM,GAAG,YAAY,CAAC,MAAM;YACvD,YAAY,EAAE,YAAY,CAAC,MAAM;SAClC,CAAC;QAEF,IAAI,UAAU,KAAK,MAAM,EAAE,CAAC;YAC1B,KAAK,MAAM,CAAC,UAAU,EAAE,SAAS,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;gBAC5D,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC;oBAClB,UAAU,EAAE,MAAM,CAAC,UAAU,CAAC;oBAC9B,QAAQ,EAAE,SAAS,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;iBAClC,CAAC,CAAC;YACL,CAAC;QACH,CAAC;aAAM,IAAI,UAAU,KAAK,QAAQ,EAAE,CAAC;YACnC,QAAQ,CAAC,KAAK,GAAG,cAAc,CAAC,GAAG,CAAC,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC;gBACnD,UAAU,EAAE,MAAM,CAAC,UAAU,CAAC;gBAC9B,QAAQ,EAAE,CAAC;aACZ,CAAC,CAAC,CAAC;YACJ,MAAM,mBAAmB,CAAC,YAAY,EAAE,cAAc,EAAE,QAAQ,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC;QACxF,CAAC;QAED,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IACxC,CAAC;IAEM,QAAQ;QACb,OAAO,IAAI,CAAC,WAAW,CAAC;IAC1B,CAAC;CACF"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { SonarCoverageObject, CoverageHandler } from '../helpers/types.js';
|
|
2
|
+
export declare class SonarCoverageHandler implements CoverageHandler {
|
|
3
|
+
private readonly coverageObj;
|
|
4
|
+
constructor();
|
|
5
|
+
processFile(filePath: string, _fileName: string, lines: Record<string, number>, uncoveredLines: number[], coveredLines: number[], repoRoot: string, reportType: 'test' | 'deploy'): Promise<void>;
|
|
6
|
+
finalize(): SonarCoverageObject;
|
|
7
|
+
}
|