apex-code-coverage-transformer 2.4.1 → 2.5.1
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 +38 -260
- 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 +69 -0
- package/lib/handlers/cloverCoverageHandler.js.map +1 -0
- package/lib/handlers/coberturaCoverageHandler.d.ts +8 -0
- package/lib/handlers/coberturaCoverageHandler.js +62 -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/lcovCoverageHandler.d.ts +7 -0
- package/lib/handlers/lcovCoverageHandler.js +26 -0
- package/lib/handlers/lcovCoverageHandler.js.map +1 -0
- package/lib/handlers/sonarCoverageHandler.d.ts +7 -0
- package/lib/handlers/sonarCoverageHandler.js +27 -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/findFilePath.js +2 -0
- package/lib/helpers/findFilePath.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/setCoveredLines.d.ts +1 -0
- package/lib/helpers/setCoveredLines.js +27 -0
- package/lib/helpers/setCoveredLines.js.map +1 -0
- package/lib/helpers/transformDeployCoverageReport.js +11 -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 +20 -3
- 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/lib/helpers/setCoveredLinesClover.d.ts +0 -2
- package/lib/helpers/setCoveredLinesClover.js +0 -35
- package/lib/helpers/setCoveredLinesClover.js.map +0 -1
- package/lib/helpers/setCoveredLinesCobertura.d.ts +0 -2
- package/lib/helpers/setCoveredLinesCobertura.js +0 -34
- package/lib/helpers/setCoveredLinesCobertura.js.map +0 -1
- package/lib/helpers/setCoveredLinesSonar.d.ts +0 -2
- package/lib/helpers/setCoveredLinesSonar.js +0 -30
- package/lib/helpers/setCoveredLinesSonar.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.1](https://github.com/mcarvin8/apex-code-coverage-transformer/compare/v2.5.0...v2.5.1) (2025-01-09)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Bug Fixes
|
|
12
|
+
|
|
13
|
+
* set covered lines before processing format ([d96bd88](https://github.com/mcarvin8/apex-code-coverage-transformer/commit/d96bd88b341dbb8abe49ece21252e998abae617b))
|
|
14
|
+
|
|
15
|
+
## [2.5.0](https://github.com/mcarvin8/apex-code-coverage-transformer/compare/v2.4.1...v2.5.0) (2025-01-08)
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
### Features
|
|
19
|
+
|
|
20
|
+
* add support for lcovonly info format ([a663cb2](https://github.com/mcarvin8/apex-code-coverage-transformer/commit/a663cb2db49e62a8c6cf278fe6a7e28c9e0a94c6))
|
|
21
|
+
* rename xml flag to output-report ([bb25a47](https://github.com/mcarvin8/apex-code-coverage-transformer/commit/bb25a478e285dc7de612368c51243e0525a71b02))
|
|
22
|
+
|
|
8
23
|
## [2.4.1](https://github.com/mcarvin8/apex-code-coverage-transformer/compare/v2.4.0...v2.4.1) (2024-12-22)
|
|
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", "lcovonly", 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:
|
|
@@ -153,248 +167,12 @@ Error (1): ENOENT: no such file or directory: {packageDirPath}
|
|
|
153
167
|
|
|
154
168
|
## Example
|
|
155
169
|
|
|
156
|
-
This [code coverage JSON file](https://raw.githubusercontent.com/mcarvin8/apex-code-coverage-transformer/main/test/deploy_coverage_no_file_exts.json) created during a Salesforce CLI deployment
|
|
157
|
-
|
|
158
|
-
```xml
|
|
159
|
-
<?xml version="1.0"?>
|
|
160
|
-
<coverage version="1">
|
|
161
|
-
<file path="packaged/triggers/AccountTrigger.trigger">
|
|
162
|
-
<lineToCover lineNumber="52" covered="false"/>
|
|
163
|
-
<lineToCover lineNumber="53" covered="false"/>
|
|
164
|
-
<lineToCover lineNumber="59" covered="false"/>
|
|
165
|
-
<lineToCover lineNumber="60" covered="false"/>
|
|
166
|
-
<lineToCover lineNumber="1" covered="true"/>
|
|
167
|
-
<lineToCover lineNumber="2" covered="true"/>
|
|
168
|
-
<lineToCover lineNumber="3" covered="true"/>
|
|
169
|
-
<lineToCover lineNumber="4" covered="true"/>
|
|
170
|
-
<lineToCover lineNumber="5" covered="true"/>
|
|
171
|
-
<lineToCover lineNumber="6" covered="true"/>
|
|
172
|
-
<lineToCover lineNumber="7" covered="true"/>
|
|
173
|
-
<lineToCover lineNumber="8" covered="true"/>
|
|
174
|
-
<lineToCover lineNumber="9" covered="true"/>
|
|
175
|
-
<lineToCover lineNumber="10" covered="true"/>
|
|
176
|
-
<lineToCover lineNumber="11" covered="true"/>
|
|
177
|
-
<lineToCover lineNumber="12" covered="true"/>
|
|
178
|
-
<lineToCover lineNumber="13" covered="true"/>
|
|
179
|
-
<lineToCover lineNumber="14" covered="true"/>
|
|
180
|
-
<lineToCover lineNumber="15" covered="true"/>
|
|
181
|
-
<lineToCover lineNumber="16" covered="true"/>
|
|
182
|
-
<lineToCover lineNumber="17" covered="true"/>
|
|
183
|
-
<lineToCover lineNumber="18" covered="true"/>
|
|
184
|
-
<lineToCover lineNumber="19" covered="true"/>
|
|
185
|
-
<lineToCover lineNumber="20" covered="true"/>
|
|
186
|
-
<lineToCover lineNumber="21" covered="true"/>
|
|
187
|
-
<lineToCover lineNumber="22" covered="true"/>
|
|
188
|
-
<lineToCover lineNumber="23" covered="true"/>
|
|
189
|
-
<lineToCover lineNumber="24" covered="true"/>
|
|
190
|
-
<lineToCover lineNumber="25" covered="true"/>
|
|
191
|
-
<lineToCover lineNumber="26" covered="true"/>
|
|
192
|
-
<lineToCover lineNumber="27" covered="true"/>
|
|
193
|
-
</file>
|
|
194
|
-
<file path="force-app/main/default/classes/AccountProfile.cls">
|
|
195
|
-
<lineToCover lineNumber="52" covered="false"/>
|
|
196
|
-
<lineToCover lineNumber="53" covered="false"/>
|
|
197
|
-
<lineToCover lineNumber="59" covered="false"/>
|
|
198
|
-
<lineToCover lineNumber="60" covered="false"/>
|
|
199
|
-
<lineToCover lineNumber="54" covered="true"/>
|
|
200
|
-
<lineToCover lineNumber="55" covered="true"/>
|
|
201
|
-
<lineToCover lineNumber="56" covered="true"/>
|
|
202
|
-
<lineToCover lineNumber="57" covered="true"/>
|
|
203
|
-
<lineToCover lineNumber="58" covered="true"/>
|
|
204
|
-
<lineToCover lineNumber="61" covered="true"/>
|
|
205
|
-
<lineToCover lineNumber="62" covered="true"/>
|
|
206
|
-
<lineToCover lineNumber="63" covered="true"/>
|
|
207
|
-
<lineToCover lineNumber="64" covered="true"/>
|
|
208
|
-
<lineToCover lineNumber="65" covered="true"/>
|
|
209
|
-
<lineToCover lineNumber="66" covered="true"/>
|
|
210
|
-
<lineToCover lineNumber="67" covered="true"/>
|
|
211
|
-
<lineToCover lineNumber="68" covered="true"/>
|
|
212
|
-
<lineToCover lineNumber="69" covered="true"/>
|
|
213
|
-
<lineToCover lineNumber="70" covered="true"/>
|
|
214
|
-
<lineToCover lineNumber="71" covered="true"/>
|
|
215
|
-
<lineToCover lineNumber="72" covered="true"/>
|
|
216
|
-
<lineToCover lineNumber="1" covered="true"/>
|
|
217
|
-
<lineToCover lineNumber="2" covered="true"/>
|
|
218
|
-
<lineToCover lineNumber="3" covered="true"/>
|
|
219
|
-
<lineToCover lineNumber="4" covered="true"/>
|
|
220
|
-
<lineToCover lineNumber="5" covered="true"/>
|
|
221
|
-
<lineToCover lineNumber="6" covered="true"/>
|
|
222
|
-
<lineToCover lineNumber="7" covered="true"/>
|
|
223
|
-
<lineToCover lineNumber="8" covered="true"/>
|
|
224
|
-
<lineToCover lineNumber="9" covered="true"/>
|
|
225
|
-
<lineToCover lineNumber="10" covered="true"/>
|
|
226
|
-
</file>
|
|
227
|
-
</coverage>
|
|
228
|
-
```
|
|
229
|
-
|
|
230
|
-
and this format for Cobertura:
|
|
231
|
-
|
|
232
|
-
```xml
|
|
233
|
-
<?xml version="1.0" ?>
|
|
234
|
-
<!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="1734621101529" complexity="0" version="0.1">
|
|
236
|
-
<sources>
|
|
237
|
-
<source>.</source>
|
|
238
|
-
</sources>
|
|
239
|
-
<packages>
|
|
240
|
-
<package name="main" line-rate="0.871" branch-rate="1">
|
|
241
|
-
<classes>
|
|
242
|
-
<class name="AccountTrigger" filename="packaged/triggers/AccountTrigger.trigger" line-rate="0.8710" branch-rate="1">
|
|
243
|
-
<methods/>
|
|
244
|
-
<lines>
|
|
245
|
-
<line number="52" hits="0" branch="false"/>
|
|
246
|
-
<line number="53" hits="0" branch="false"/>
|
|
247
|
-
<line number="59" hits="0" branch="false"/>
|
|
248
|
-
<line number="60" hits="0" branch="false"/>
|
|
249
|
-
<line number="1" hits="1" branch="false"/>
|
|
250
|
-
<line number="2" hits="1" branch="false"/>
|
|
251
|
-
<line number="3" hits="1" branch="false"/>
|
|
252
|
-
<line number="4" hits="1" branch="false"/>
|
|
253
|
-
<line number="5" hits="1" branch="false"/>
|
|
254
|
-
<line number="6" hits="1" branch="false"/>
|
|
255
|
-
<line number="7" hits="1" branch="false"/>
|
|
256
|
-
<line number="8" hits="1" branch="false"/>
|
|
257
|
-
<line number="9" hits="1" branch="false"/>
|
|
258
|
-
<line number="10" hits="1" branch="false"/>
|
|
259
|
-
<line number="11" hits="1" branch="false"/>
|
|
260
|
-
<line number="12" hits="1" branch="false"/>
|
|
261
|
-
<line number="13" hits="1" branch="false"/>
|
|
262
|
-
<line number="14" hits="1" branch="false"/>
|
|
263
|
-
<line number="15" hits="1" branch="false"/>
|
|
264
|
-
<line number="16" hits="1" branch="false"/>
|
|
265
|
-
<line number="17" hits="1" branch="false"/>
|
|
266
|
-
<line number="18" hits="1" branch="false"/>
|
|
267
|
-
<line number="19" hits="1" branch="false"/>
|
|
268
|
-
<line number="20" hits="1" branch="false"/>
|
|
269
|
-
<line number="21" hits="1" branch="false"/>
|
|
270
|
-
<line number="22" hits="1" branch="false"/>
|
|
271
|
-
<line number="23" hits="1" branch="false"/>
|
|
272
|
-
<line number="24" hits="1" branch="false"/>
|
|
273
|
-
<line number="25" hits="1" branch="false"/>
|
|
274
|
-
<line number="26" hits="1" branch="false"/>
|
|
275
|
-
<line number="27" hits="1" branch="false"/>
|
|
276
|
-
</lines>
|
|
277
|
-
</class>
|
|
278
|
-
<class name="AccountProfile" filename="force-app/main/default/classes/AccountProfile.cls" line-rate="0.8710" branch-rate="1">
|
|
279
|
-
<methods/>
|
|
280
|
-
<lines>
|
|
281
|
-
<line number="52" hits="0" branch="false"/>
|
|
282
|
-
<line number="53" hits="0" branch="false"/>
|
|
283
|
-
<line number="59" hits="0" branch="false"/>
|
|
284
|
-
<line number="60" hits="0" branch="false"/>
|
|
285
|
-
<line number="54" hits="1" branch="false"/>
|
|
286
|
-
<line number="55" hits="1" branch="false"/>
|
|
287
|
-
<line number="56" hits="1" branch="false"/>
|
|
288
|
-
<line number="57" hits="1" branch="false"/>
|
|
289
|
-
<line number="58" hits="1" branch="false"/>
|
|
290
|
-
<line number="61" hits="1" branch="false"/>
|
|
291
|
-
<line number="62" hits="1" branch="false"/>
|
|
292
|
-
<line number="63" hits="1" branch="false"/>
|
|
293
|
-
<line number="64" hits="1" branch="false"/>
|
|
294
|
-
<line number="65" hits="1" branch="false"/>
|
|
295
|
-
<line number="66" hits="1" branch="false"/>
|
|
296
|
-
<line number="67" hits="1" branch="false"/>
|
|
297
|
-
<line number="68" hits="1" branch="false"/>
|
|
298
|
-
<line number="69" hits="1" branch="false"/>
|
|
299
|
-
<line number="70" hits="1" branch="false"/>
|
|
300
|
-
<line number="71" hits="1" branch="false"/>
|
|
301
|
-
<line number="72" hits="1" branch="false"/>
|
|
302
|
-
<line number="1" hits="1" branch="false"/>
|
|
303
|
-
<line number="2" hits="1" branch="false"/>
|
|
304
|
-
<line number="3" hits="1" branch="false"/>
|
|
305
|
-
<line number="4" hits="1" branch="false"/>
|
|
306
|
-
<line number="5" hits="1" branch="false"/>
|
|
307
|
-
<line number="6" hits="1" branch="false"/>
|
|
308
|
-
<line number="7" hits="1" branch="false"/>
|
|
309
|
-
<line number="8" hits="1" branch="false"/>
|
|
310
|
-
<line number="9" hits="1" branch="false"/>
|
|
311
|
-
<line number="10" hits="1" branch="false"/>
|
|
312
|
-
</lines>
|
|
313
|
-
</class>
|
|
314
|
-
</classes>
|
|
315
|
-
</package>
|
|
316
|
-
</packages>
|
|
317
|
-
</coverage>
|
|
318
|
-
```
|
|
170
|
+
This [code coverage JSON file](https://raw.githubusercontent.com/mcarvin8/apex-code-coverage-transformer/main/test/deploy_coverage_no_file_exts.json) created during a Salesforce CLI deployment can be transformed into:
|
|
319
171
|
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
<coverage generated="1734898566028" clover="3.2.0">
|
|
325
|
-
<project timestamp="1734898566028" name="All files">
|
|
326
|
-
<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
|
-
<file name="AccountTrigger" path="packaged/triggers/AccountTrigger.trigger">
|
|
328
|
-
<metrics statements="31" coveredstatements="27" conditionals="0" coveredconditionals="0" methods="0" coveredmethods="0"/>
|
|
329
|
-
<line num="52" count="0" type="stmt"/>
|
|
330
|
-
<line num="53" count="0" type="stmt"/>
|
|
331
|
-
<line num="59" count="0" type="stmt"/>
|
|
332
|
-
<line num="60" count="0" type="stmt"/>
|
|
333
|
-
<line num="1" count="1" type="stmt"/>
|
|
334
|
-
<line num="2" count="1" type="stmt"/>
|
|
335
|
-
<line num="3" count="1" type="stmt"/>
|
|
336
|
-
<line num="4" count="1" type="stmt"/>
|
|
337
|
-
<line num="5" count="1" type="stmt"/>
|
|
338
|
-
<line num="6" count="1" type="stmt"/>
|
|
339
|
-
<line num="7" count="1" type="stmt"/>
|
|
340
|
-
<line num="8" count="1" type="stmt"/>
|
|
341
|
-
<line num="9" count="1" type="stmt"/>
|
|
342
|
-
<line num="10" count="1" type="stmt"/>
|
|
343
|
-
<line num="11" count="1" type="stmt"/>
|
|
344
|
-
<line num="12" count="1" type="stmt"/>
|
|
345
|
-
<line num="13" count="1" type="stmt"/>
|
|
346
|
-
<line num="14" count="1" type="stmt"/>
|
|
347
|
-
<line num="15" count="1" type="stmt"/>
|
|
348
|
-
<line num="16" count="1" type="stmt"/>
|
|
349
|
-
<line num="17" count="1" type="stmt"/>
|
|
350
|
-
<line num="18" count="1" type="stmt"/>
|
|
351
|
-
<line num="19" count="1" type="stmt"/>
|
|
352
|
-
<line num="20" count="1" type="stmt"/>
|
|
353
|
-
<line num="21" count="1" type="stmt"/>
|
|
354
|
-
<line num="22" count="1" type="stmt"/>
|
|
355
|
-
<line num="23" count="1" type="stmt"/>
|
|
356
|
-
<line num="24" count="1" type="stmt"/>
|
|
357
|
-
<line num="25" count="1" type="stmt"/>
|
|
358
|
-
<line num="26" count="1" type="stmt"/>
|
|
359
|
-
<line num="27" count="1" type="stmt"/>
|
|
360
|
-
</file>
|
|
361
|
-
<file name="AccountProfile" path="force-app/main/default/classes/AccountProfile.cls">
|
|
362
|
-
<metrics statements="31" coveredstatements="27" conditionals="0" coveredconditionals="0" methods="0" coveredmethods="0"/>
|
|
363
|
-
<line num="52" count="0" type="stmt"/>
|
|
364
|
-
<line num="53" count="0" type="stmt"/>
|
|
365
|
-
<line num="59" count="0" type="stmt"/>
|
|
366
|
-
<line num="60" count="0" type="stmt"/>
|
|
367
|
-
<line num="54" count="1" type="stmt"/>
|
|
368
|
-
<line num="55" count="1" type="stmt"/>
|
|
369
|
-
<line num="56" count="1" type="stmt"/>
|
|
370
|
-
<line num="57" count="1" type="stmt"/>
|
|
371
|
-
<line num="58" count="1" type="stmt"/>
|
|
372
|
-
<line num="61" count="1" type="stmt"/>
|
|
373
|
-
<line num="62" count="1" type="stmt"/>
|
|
374
|
-
<line num="63" count="1" type="stmt"/>
|
|
375
|
-
<line num="64" count="1" type="stmt"/>
|
|
376
|
-
<line num="65" count="1" type="stmt"/>
|
|
377
|
-
<line num="66" count="1" type="stmt"/>
|
|
378
|
-
<line num="67" count="1" type="stmt"/>
|
|
379
|
-
<line num="68" count="1" type="stmt"/>
|
|
380
|
-
<line num="69" count="1" type="stmt"/>
|
|
381
|
-
<line num="70" count="1" type="stmt"/>
|
|
382
|
-
<line num="71" count="1" type="stmt"/>
|
|
383
|
-
<line num="72" count="1" type="stmt"/>
|
|
384
|
-
<line num="1" count="1" type="stmt"/>
|
|
385
|
-
<line num="2" count="1" type="stmt"/>
|
|
386
|
-
<line num="3" count="1" type="stmt"/>
|
|
387
|
-
<line num="4" count="1" type="stmt"/>
|
|
388
|
-
<line num="5" count="1" type="stmt"/>
|
|
389
|
-
<line num="6" count="1" type="stmt"/>
|
|
390
|
-
<line num="7" count="1" type="stmt"/>
|
|
391
|
-
<line num="8" count="1" type="stmt"/>
|
|
392
|
-
<line num="9" count="1" type="stmt"/>
|
|
393
|
-
<line num="10" count="1" type="stmt"/>
|
|
394
|
-
</file>
|
|
395
|
-
</project>
|
|
396
|
-
</coverage>
|
|
397
|
-
```
|
|
172
|
+
- [SonarQube format](https://raw.githubusercontent.com/mcarvin8/apex-code-coverage-transformer/main/test/deploy_coverage_baseline_sonar.xml)
|
|
173
|
+
- [Cobertura format](https://raw.githubusercontent.com/mcarvin8/apex-code-coverage-transformer/main/test/deploy_coverage_baseline_cobertura.xml)
|
|
174
|
+
- [Clover format](https://raw.githubusercontent.com/mcarvin8/apex-code-coverage-transformer/main/test/deploy_coverage_baseline_clover.xml)
|
|
175
|
+
- [LCovOnly format](https://raw.githubusercontent.com/mcarvin8/apex-code-coverage-transformer/main/test/deploy_coverage_baseline_lcov.info)
|
|
398
176
|
|
|
399
177
|
## Issues
|
|
400
178
|
|
|
@@ -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,KAAK,EAAE,MAAM,6BAA6B,CAAC;AAC/D,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB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AAC;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[]): void;
|
|
6
|
+
finalize(): CloverCoverageObject;
|
|
7
|
+
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
export class CloverCoverageHandler {
|
|
3
|
+
coverageObj;
|
|
4
|
+
constructor() {
|
|
5
|
+
this.coverageObj = {
|
|
6
|
+
coverage: {
|
|
7
|
+
'@generated': Date.now(),
|
|
8
|
+
'@clover': '3.2.0',
|
|
9
|
+
project: {
|
|
10
|
+
'@timestamp': Date.now(),
|
|
11
|
+
'@name': 'All files',
|
|
12
|
+
metrics: {
|
|
13
|
+
'@statements': 0,
|
|
14
|
+
'@coveredstatements': 0,
|
|
15
|
+
'@conditionals': 0,
|
|
16
|
+
'@coveredconditionals': 0,
|
|
17
|
+
'@methods': 0,
|
|
18
|
+
'@coveredmethods': 0,
|
|
19
|
+
'@elements': 0,
|
|
20
|
+
'@coveredelements': 0,
|
|
21
|
+
'@complexity': 0,
|
|
22
|
+
'@loc': 0,
|
|
23
|
+
'@ncloc': 0,
|
|
24
|
+
'@packages': 1,
|
|
25
|
+
'@files': 0,
|
|
26
|
+
'@classes': 0,
|
|
27
|
+
},
|
|
28
|
+
file: [],
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
processFile(filePath, fileName, lines, uncoveredLines, coveredLines) {
|
|
34
|
+
const fileObj = {
|
|
35
|
+
'@name': fileName,
|
|
36
|
+
'@path': filePath,
|
|
37
|
+
metrics: {
|
|
38
|
+
'@statements': uncoveredLines.length + coveredLines.length,
|
|
39
|
+
'@coveredstatements': coveredLines.length,
|
|
40
|
+
'@conditionals': 0,
|
|
41
|
+
'@coveredconditionals': 0,
|
|
42
|
+
'@methods': 0,
|
|
43
|
+
'@coveredmethods': 0,
|
|
44
|
+
},
|
|
45
|
+
line: [],
|
|
46
|
+
};
|
|
47
|
+
for (const [lineNumber, isCovered] of Object.entries(lines)) {
|
|
48
|
+
fileObj.line.push({
|
|
49
|
+
'@num': Number(lineNumber),
|
|
50
|
+
'@count': isCovered === 1 ? 1 : 0,
|
|
51
|
+
'@type': 'stmt',
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
this.coverageObj.coverage.project.file.push(fileObj);
|
|
55
|
+
const projectMetrics = this.coverageObj.coverage.project.metrics;
|
|
56
|
+
projectMetrics['@statements'] += uncoveredLines.length + coveredLines.length;
|
|
57
|
+
projectMetrics['@coveredstatements'] += coveredLines.length;
|
|
58
|
+
projectMetrics['@elements'] += uncoveredLines.length + coveredLines.length;
|
|
59
|
+
projectMetrics['@coveredelements'] += coveredLines.length;
|
|
60
|
+
projectMetrics['@files'] += 1;
|
|
61
|
+
projectMetrics['@classes'] += 1;
|
|
62
|
+
projectMetrics['@loc'] += uncoveredLines.length + coveredLines.length;
|
|
63
|
+
projectMetrics['@ncloc'] += uncoveredLines.length + coveredLines.length;
|
|
64
|
+
}
|
|
65
|
+
finalize() {
|
|
66
|
+
return this.coverageObj;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
//# sourceMappingURL=cloverCoverageHandler.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cloverCoverageHandler.js","sourceRoot":"","sources":["../../src/handlers/cloverCoverageHandler.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAIb,MAAM,OAAO,qBAAqB;IACf,WAAW,CAAuB;IAEnD;QACE,IAAI,CAAC,WAAW,GAAG;YACjB,QAAQ,EAAE;gBACR,YAAY,EAAE,IAAI,CAAC,GAAG,EAAE;gBACxB,SAAS,EAAE,OAAO;gBAClB,OAAO,EAAE;oBACP,YAAY,EAAE,IAAI,CAAC,GAAG,EAAE;oBACxB,OAAO,EAAE,WAAW;oBACpB,OAAO,EAAE;wBACP,aAAa,EAAE,CAAC;wBAChB,oBAAoB,EAAE,CAAC;wBACvB,eAAe,EAAE,CAAC;wBAClB,sBAAsB,EAAE,CAAC;wBACzB,UAAU,EAAE,CAAC;wBACb,iBAAiB,EAAE,CAAC;wBACpB,WAAW,EAAE,CAAC;wBACd,kBAAkB,EAAE,CAAC;wBACrB,aAAa,EAAE,CAAC;wBA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C,IAAI,YAAY,CAAC,MAAM,CAAC;QAC5D,cAAc,CAAC,WAAW,CAAC,IAAI,cAAc,CAAC,MAAM,GAAG,YAAY,CAAC,MAAM,CAAC;QAC3E,cAAc,CAAC,kBAAkB,CAAC,IAAI,YAAY,CAAC,MAAM,CAAC;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[]): void;
|
|
7
|
+
finalize(): CoberturaCoverageObject;
|
|
8
|
+
}
|