apex-code-coverage-transformer 2.11.0 → 2.11.2
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 -1
- package/README.md +29 -34
- package/oclif.lock +1095 -950
- package/oclif.manifest.json +1 -1
- package/package.json +17 -12
package/CHANGELOG.md
CHANGED
|
@@ -5,12 +5,26 @@
|
|
|
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.11.2](https://github.com/mcarvin8/apex-code-coverage-transformer/compare/v2.11.1...v2.11.2) (2025-05-06)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Bug Fixes
|
|
12
|
+
|
|
13
|
+
* **deps:** bump @oclif/core from 4.2.10 to 4.3.0 ([e02c2c4](https://github.com/mcarvin8/apex-code-coverage-transformer/commit/e02c2c4e85636a1d64da1783d39db3a46b118bc2))
|
|
14
|
+
|
|
15
|
+
## [2.11.1](https://github.com/mcarvin8/apex-code-coverage-transformer/compare/v2.11.0...v2.11.1) (2025-03-25)
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
### Bug Fixes
|
|
19
|
+
|
|
20
|
+
* **deps:** bump @salesforce/core from 8.8.5 to 8.8.6 ([3cdbe52](https://github.com/mcarvin8/apex-code-coverage-transformer/commit/3cdbe52bfee45d34d8d355f61451529f9fadaeb3))
|
|
21
|
+
* **deps:** bump @salesforce/sf-plugins-core from 12.2.0 to 12.2.1 ([60d3f72](https://github.com/mcarvin8/apex-code-coverage-transformer/commit/60d3f72719fad96d46a55c02e616ab81e2f8d686))
|
|
22
|
+
|
|
8
23
|
## [2.11.0](https://github.com/mcarvin8/apex-code-coverage-transformer/compare/v2.10.0...v2.11.0) (2025-03-07)
|
|
9
24
|
|
|
10
25
|
|
|
11
26
|
### Features
|
|
12
27
|
|
|
13
|
-
* include ignore package directories flag in hook ([fded594](https://github.com/mcarvin8/apex-code-coverage-transformer/commit/fded594ccb229035aecfa426da972c5819a212a5))
|
|
14
28
|
* include ignore package directories flag in hook ([a7294a4](https://github.com/mcarvin8/apex-code-coverage-transformer/commit/a7294a47a85141d4b1d0e21854ac14d4f19b9e14))
|
|
15
29
|
|
|
16
30
|
|
package/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
#
|
|
1
|
+
# `apex-code-coverage-transformer`
|
|
2
2
|
|
|
3
3
|
[](https://www.npmjs.com/package/apex-code-coverage-transformer) [](https://npmjs.org/package/apex-code-coverage-transformer) [](https://raw.githubusercontent.com/mcarvin8/apex-code-coverage-transformer/main/LICENSE.md)
|
|
4
4
|
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
|
|
24
24
|
Transform the Salesforce Apex code coverage JSON files created during deployments and test runs into other [formats](#coverage-report-formats) accepted by SonarQube, GitHub, GitLab, Azure, Bitbucket, etc.
|
|
25
25
|
|
|
26
|
-
If there's a coverage format not yet supported by this plugin, feel free to provide a pull request or issue for the coverage format.
|
|
26
|
+
> If there's a coverage format not yet supported by this plugin, feel free to provide a pull request or issue for the coverage format.
|
|
27
27
|
|
|
28
28
|
## Install
|
|
29
29
|
|
|
@@ -65,14 +65,12 @@ This plugin can be used after running the below [sfdx-hardis](https://github.com
|
|
|
65
65
|
|
|
66
66
|
Both hardis commands will create the code coverage JSON to transform here: `hardis-report/apex-coverage-results.json`.
|
|
67
67
|
|
|
68
|
-
|
|
68
|
+
## Fixes and Enhancements
|
|
69
69
|
|
|
70
70
|
- **Maps Apex file names** in the original coverage report (e.g., `no-map/AccountTriggerHandler`) to their corresponding relative file paths in the Salesforce DX project (e.g., `force-app/main/default/classes/AccountTriggerHandler.cls`).
|
|
71
71
|
- **Normalizes coverage reports** across both deploy and test commands, improving compatibility with external tools.
|
|
72
72
|
- **Adds additional coverage formats** not available in the default Salesforce CLI deploy and test commands.
|
|
73
|
-
- **"Fixes" inaccuracies** in Salesforce CLI deploy command coverage reports, such as
|
|
74
|
-
- Out-of-range covered lines (e.g., line 100 reported as "covered" in a 98-line Apex class).
|
|
75
|
-
- Incorrect total line counts (e.g., 120 lines reported for a 100-line Apex class).
|
|
73
|
+
- **"Fixes" inaccuracies** in Salesforce CLI deploy command coverage reports, such as out-of-range covered lines (e.g., line 100 reported as "covered" in a 98-line Apex class) and incorrect total line counts (e.g., 120 lines reported for a 100-line Apex class).
|
|
76
74
|
- To address these inaccuracies, the plugin includes a **re-numbering function** that only applies to deploy coverage reports. This function reassigns out-of-range `covered` lines to unused lines, ensuring reports are accepted by external tools.
|
|
77
75
|
- The `uncovered` lines are always correctly reported by the deploy command.
|
|
78
76
|
- Once Salesforce resolves the issue with the API that affects deploy command coverage reports, the re-numbering function will be removed in a future **breaking** release.
|
|
@@ -89,7 +87,7 @@ The `apex-code-coverage-transformer` has 1 command:
|
|
|
89
87
|
|
|
90
88
|
```
|
|
91
89
|
USAGE
|
|
92
|
-
$ sf acc-transformer transform -j <value> -r <value> -f <value> -i <value> [--json]
|
|
90
|
+
$ sf acc-transformer transform -j <value> [-r <value>] [-f <value>] [-i <value>] [--json]
|
|
93
91
|
|
|
94
92
|
FLAGS
|
|
95
93
|
-j, --coverage-json=<value> Path to the code coverage JSON file created by the Salesforce CLI deploy or test command.
|
|
@@ -104,9 +102,6 @@ FLAGS
|
|
|
104
102
|
GLOBAL FLAGS
|
|
105
103
|
--json Format output as json.
|
|
106
104
|
|
|
107
|
-
DESCRIPTION
|
|
108
|
-
Transform the Apex code coverage JSON file created by the Salesforce CLI deploy and test command into other formats accepted by SonarQube, GitHub, GitLab, Azure, Bitbucket, etc.
|
|
109
|
-
|
|
110
105
|
EXAMPLES
|
|
111
106
|
Transform the JSON into Sonar format:
|
|
112
107
|
|
|
@@ -133,17 +128,17 @@ EXAMPLES
|
|
|
133
128
|
|
|
134
129
|
The `-f`/`--format` flag allows you to specify the format of the transformed coverage report.
|
|
135
130
|
|
|
136
|
-
| Flag Option
|
|
137
|
-
|
|
|
138
|
-
|
|
|
139
|
-
|
|
|
140
|
-
|
|
|
141
|
-
|
|
|
142
|
-
|
|
|
131
|
+
| Flag Option | Description |
|
|
132
|
+
| ----------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------- |
|
|
133
|
+
| [sonar](https://raw.githubusercontent.com/mcarvin8/apex-code-coverage-transformer/main/test/sonar_baseline.xml) | Generates a SonarQube-compatible coverage report. This is the default option. |
|
|
134
|
+
| [clover](https://raw.githubusercontent.com/mcarvin8/apex-code-coverage-transformer/main/test/clover_baseline.xml) | Produces a Clover XML report format, commonly used with Atlassian tools. |
|
|
135
|
+
| [lcovonly](https://raw.githubusercontent.com/mcarvin8/apex-code-coverage-transformer/main/test/lcov_baseline.info) | Outputs coverage data in LCOV format, useful for integrating with LCOV-based tools. |
|
|
136
|
+
| [cobertura](https://raw.githubusercontent.com/mcarvin8/apex-code-coverage-transformer/main/test/cobertura_baseline.xml) | Creates a Cobertura XML report, a widely used format for coverage reporting. |
|
|
137
|
+
| [jacoco](https://raw.githubusercontent.com/mcarvin8/apex-code-coverage-transformer/main/test/jacoco_baseline.xml) | Creates a JaCoCo XML report, the standard for Java projects. |
|
|
143
138
|
|
|
144
139
|
## Hook
|
|
145
140
|
|
|
146
|
-
To enable automatic transformation after the below `sf` commands complete, create `.apexcodecovtransformer.config.json` in your project’s root directory.
|
|
141
|
+
To enable automatic transformation after the below `sf` commands complete, create a `.apexcodecovtransformer.config.json` in your project’s root directory.
|
|
147
142
|
|
|
148
143
|
- `sf project deploy [start/validate/report/resume]`
|
|
149
144
|
- `sf apex run test`
|
|
@@ -154,29 +149,29 @@ To enable automatic transformation after the below `sf` commands complete, creat
|
|
|
154
149
|
- `sf hardis org test apex`
|
|
155
150
|
- only if `sfdx-hardis` is installed
|
|
156
151
|
|
|
157
|
-
You can copy the sample [Salesforce CLI .apexcodecovtransformer.config.json](https://raw.githubusercontent.com/mcarvin8/apex-code-coverage-transformer/main/defaults/salesforce-cli/.apexcodecovtransformer.config.json), which assumes you are running the Salesforce CLI commands and specifying the `--results-dir`/`--output-dir` directory as "coverage".
|
|
158
|
-
|
|
159
|
-
You can copy the sample [SFDX Hardis .apexcodecovtransformer.config.json](https://raw.githubusercontent.com/mcarvin8/apex-code-coverage-transformer/main/defaults/sfdx-hardis/.apexcodecovtransformer.config.json), which assumes you are running the SFDX Hardis commands. Update this sample with your desired output report path and format.
|
|
152
|
+
You can copy & update the sample [Salesforce CLI .apexcodecovtransformer.config.json](https://raw.githubusercontent.com/mcarvin8/apex-code-coverage-transformer/main/defaults/salesforce-cli/.apexcodecovtransformer.config.json), which assumes you are running the Salesforce CLI commands and specifying the `--results-dir`/`--output-dir` directory as "coverage".
|
|
160
153
|
|
|
161
|
-
|
|
154
|
+
You can copy & update the sample [SFDX Hardis .apexcodecovtransformer.config.json](https://raw.githubusercontent.com/mcarvin8/apex-code-coverage-transformer/main/defaults/sfdx-hardis/.apexcodecovtransformer.config.json), which assumes you are running the SFDX Hardis commands.
|
|
162
155
|
|
|
163
|
-
|
|
164
|
-
- `testCoverageJsonPath` is required to use the hook after test commands and should be the path to the code coverage JSON created by the Salesforce CLI/SFDX Hardis test command. Recommend using a relative path.
|
|
165
|
-
- `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.
|
|
166
|
-
- `format` is optional and should be the intended coverage report [format](#coverage-report-formats) created by this plugin. If this isn't provided, it will default to "sonar".
|
|
167
|
-
- `ignorePackageDirectories` is optional and should be a comma-separated string of package directories to ignore when looking for matching files in the coverage report. Package directories should match how they appear in the `sfdx-project.json` file.
|
|
156
|
+
**`.apexcodecovtransformer.config.json` structure**
|
|
168
157
|
|
|
169
|
-
|
|
158
|
+
| JSON Key | Required | Description |
|
|
159
|
+
| -------------------------- | -------------------------------------- | --------------------------------------------------------------------------------------------- |
|
|
160
|
+
| `deployCoverageJsonPath` | Yes (for deploy command) | Code coverage JSON created by the Salesforce CLI deploy commands. |
|
|
161
|
+
| `testCoverageJsonPath` | Yes (for test command) | Code coverage JSON created by the Salesforce CLI test commands. |
|
|
162
|
+
| `outputReportPath` | No (defaults to `coverage.[xml/info]`) | Transformed code coverage report path. |
|
|
163
|
+
| `format` | No (defaults to `sonar`) | Transformed code coverage report [format](#coverage-report-formats). |
|
|
164
|
+
| `ignorePackageDirectories` | No | Comma-separated string of package directories to ignore when looking for matching Apex files. |
|
|
170
165
|
|
|
171
166
|
## Troubleshooting
|
|
172
167
|
|
|
173
|
-
|
|
168
|
+
If a file listed in the coverage JSON cannot be found in any package directory, a warning is displayed, and the file will not be included in the transformed report:
|
|
174
169
|
|
|
175
170
|
```
|
|
176
171
|
Warning: The file name AccountTrigger was not found in any package directory.
|
|
177
172
|
```
|
|
178
173
|
|
|
179
|
-
If none of the files
|
|
174
|
+
If **none** of the files in the coverage JSON are found in a package directory, the plugin will print an additional warning, and the generated report will be empty:
|
|
180
175
|
|
|
181
176
|
```
|
|
182
177
|
Warning: The file name AccountTrigger was not found in any package directory.
|
|
@@ -184,22 +179,22 @@ Warning: The file name AccountProfile was not found in any package directory.
|
|
|
184
179
|
Warning: None of the files listed in the coverage JSON were processed. The coverage report will be empty.
|
|
185
180
|
```
|
|
186
181
|
|
|
187
|
-
|
|
182
|
+
Salesforce CLI generates code coverage JSONs in two different structures (deploy and test command formats). If the provided coverage JSON does not match one of these expected structures, the plugin will fail with:
|
|
188
183
|
|
|
189
184
|
```
|
|
190
185
|
Error (1): The provided JSON does not match a known coverage data format from the Salesforce deploy or test command.
|
|
191
186
|
```
|
|
192
187
|
|
|
193
|
-
If
|
|
188
|
+
If `sfdx-project.json` file is missing from the project root, the plugin will fail with:
|
|
194
189
|
|
|
195
190
|
```
|
|
196
191
|
Error (1): sfdx-project.json not found in any parent directory.
|
|
197
192
|
```
|
|
198
193
|
|
|
199
|
-
|
|
194
|
+
If a package directory listed in `sfdx-project.json` cannot be found, the plugin will encounter a **ENOENT** error:
|
|
200
195
|
|
|
201
196
|
```
|
|
202
|
-
Error (1): ENOENT: no such file or directory: {
|
|
197
|
+
Error (1): ENOENT: no such file or directory: {packageDir}
|
|
203
198
|
```
|
|
204
199
|
|
|
205
200
|
## Issues
|