apex-code-coverage-transformer 2.7.2 → 2.8.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 +14 -0
- package/README.md +31 -24
- package/lib/handlers/getCoverageHandler.js +2 -0
- package/lib/handlers/getCoverageHandler.js.map +1 -1
- package/lib/handlers/jacocoCoverageHandler.d.ts +8 -0
- package/lib/handlers/jacocoCoverageHandler.js +61 -0
- package/lib/handlers/jacocoCoverageHandler.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 -2
- package/lib/helpers/generateReport.js.map +1 -1
- package/lib/helpers/types.d.ts +44 -1
- package/messages/transformer.transform.md +2 -2
- package/oclif.manifest.json +5 -4
- package/package.json +8 -3
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,20 @@
|
|
|
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.8.1](https://github.com/mcarvin8/apex-code-coverage-transformer/compare/v2.8.0...v2.8.1) (2025-02-07)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Bug Fixes
|
|
12
|
+
|
|
13
|
+
* jacoco sourcefile structure ([0a1275f](https://github.com/mcarvin8/apex-code-coverage-transformer/commit/0a1275f2d6ef5732c06568d183e4aa8e5def8951))
|
|
14
|
+
|
|
15
|
+
## [2.8.0](https://github.com/mcarvin8/apex-code-coverage-transformer/compare/v2.7.2...v2.8.0) (2025-02-07)
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
### Features
|
|
19
|
+
|
|
20
|
+
* add jacoco format ([ecd74f6](https://github.com/mcarvin8/apex-code-coverage-transformer/commit/ecd74f6cc79663b0a0a1bae024620eb69426de60))
|
|
21
|
+
|
|
8
22
|
## [2.7.2](https://github.com/mcarvin8/apex-code-coverage-transformer/compare/v2.7.1...v2.7.2) (2025-02-02)
|
|
9
23
|
|
|
10
24
|
|
package/README.md
CHANGED
|
@@ -16,11 +16,12 @@
|
|
|
16
16
|
- [Coverage Report Formats](#coverage-report-formats)
|
|
17
17
|
- [Hook](#hook)
|
|
18
18
|
- [Debugging](#debugging)
|
|
19
|
+
- [Contributing](#contributing)
|
|
19
20
|
- [Issues](#issues)
|
|
20
21
|
- [License](#license)
|
|
21
22
|
</details>
|
|
22
23
|
|
|
23
|
-
A Salesforce CLI plugin to transform the Apex code coverage JSON files created during deployments and test runs into
|
|
24
|
+
A Salesforce CLI plugin to transform the 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.
|
|
24
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
27
|
|
|
@@ -32,7 +33,7 @@ sf plugins install apex-code-coverage-transformer@x.y.z
|
|
|
32
33
|
|
|
33
34
|
## Who is the Plugin For?
|
|
34
35
|
|
|
35
|
-
This plugin is intended for users who deploy their Apex classes and triggers from any Salesforce DX project (`sfdx-project.json` file). You should be running this plugin somewhere inside your Salesforce DX project. This plugin searches for your
|
|
36
|
+
This plugin is intended for users who deploy their Apex classes and triggers from any Salesforce DX project (`sfdx-project.json` file). You should be running this plugin somewhere inside your Salesforce DX project. This plugin searches for your project's `sfdx-project.json` file to know which package directories to search into.
|
|
36
37
|
|
|
37
38
|
This plugin will work regardless of your testing strategy (running all tests, running specified tests, running all local tests). The files in the original coverage JSON has to be found in one of the package directories to be added to the final report. This ensures external tools like SonarQube can match files in the coverage report to a file in the project.
|
|
38
39
|
|
|
@@ -40,7 +41,8 @@ When the plugin is unable to find a matching Apex file in your project (i.e. Ape
|
|
|
40
41
|
|
|
41
42
|
## Creating Code Coverage Files with the Salesforce CLI
|
|
42
43
|
|
|
43
|
-
**This tool will only support the "json" coverage format from the Salesforce CLI. Do not use other coverage formats from the Salesforce CLI
|
|
44
|
+
**This tool will only support the "json" coverage format from the Salesforce CLI. Do not use other coverage formats from the Salesforce CLI.**
|
|
45
|
+
|
|
44
46
|
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`.
|
|
45
47
|
|
|
46
48
|
```
|
|
@@ -54,7 +56,7 @@ sf apex run test --code-coverage --output-dir "coverage"
|
|
|
54
56
|
sf apex get test --test-run-id <test run id> --code-coverage --output-dir "coverage"
|
|
55
57
|
```
|
|
56
58
|
|
|
57
|
-
The code coverage JSONs created by the Salesforce CLI aren't accepted automatically for Salesforce DX
|
|
59
|
+
The code coverage JSONs created by the Salesforce CLI aren't accepted automatically for Salesforce DX projects and needs to be converted using this plugin.
|
|
58
60
|
|
|
59
61
|
## Creating Code Coverage Files with SFDX Hardis
|
|
60
62
|
|
|
@@ -64,16 +66,16 @@ Both hardis commands will create the code coverage JSON to transform here: `hard
|
|
|
64
66
|
|
|
65
67
|
## What this Plugin fixes in the Salesforce CLI Coverage Reports
|
|
66
68
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
69
|
+
- The coverage reports created by this plugin will add correct file-paths per your Salesforce DX project. 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 project, allowing you to use these reports in external code quality tools like SonarQube.
|
|
70
|
+
- 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.
|
|
71
|
+
- 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.
|
|
72
|
+
- 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".
|
|
73
|
+
- 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.
|
|
74
|
+
- The coverage percentage may vary based on how many lines the API returns in the original deploy coverage report.
|
|
75
|
+
- 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.
|
|
76
|
+
- 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.
|
|
77
|
+
- See issues [5511](https://github.com/forcedotcom/salesforcedx-vscode/issues/5511) and [1568](https://github.com/forcedotcom/cli/issues/1568).
|
|
78
|
+
- **NOTE**: This does not affect coverage reports created by the Salesforce CLI test commands.
|
|
77
79
|
|
|
78
80
|
## Command
|
|
79
81
|
|
|
@@ -98,7 +100,7 @@ GLOBAL FLAGS
|
|
|
98
100
|
--json Format output as json.
|
|
99
101
|
|
|
100
102
|
DESCRIPTION
|
|
101
|
-
Transform the Apex code coverage JSON file created by the Salesforce CLI deploy and test command into SonarQube,
|
|
103
|
+
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.
|
|
102
104
|
|
|
103
105
|
EXAMPLES
|
|
104
106
|
$ sf acc-transformer transform -j "coverage.json" -r "coverage.xml" -f "sonar"
|
|
@@ -114,12 +116,13 @@ EXAMPLES
|
|
|
114
116
|
|
|
115
117
|
The `-f`/`--format` flag allows you to specify the format of the coverage report.
|
|
116
118
|
|
|
117
|
-
| Flag Option
|
|
118
|
-
|
|
119
|
-
| `sonar` | Generates a SonarQube-compatible coverage report. This is the default option.
|
|
120
|
-
| `clover` | Produces a Clover XML report format, commonly used with Atlassian tools.
|
|
121
|
-
| `lcovonly` | Outputs coverage data in LCOV format, useful for integrating with LCOV-based tools. | [LCovOnly example](https://raw.githubusercontent.com/mcarvin8/apex-code-coverage-transformer/main/test/
|
|
122
|
-
| `cobertura` | Creates a Cobertura XML report, a widely used format for coverage reporting.
|
|
119
|
+
| Flag Option | Description | Example |
|
|
120
|
+
| ----------- | ----------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------- |
|
|
121
|
+
| `sonar` | Generates a SonarQube-compatible coverage report. This is the default option. | [sonar example](https://raw.githubusercontent.com/mcarvin8/apex-code-coverage-transformer/main/test/sonar_baseline.xml) |
|
|
122
|
+
| `clover` | Produces a Clover XML report format, commonly used with Atlassian tools. | [Clover example](https://raw.githubusercontent.com/mcarvin8/apex-code-coverage-transformer/main/test/clover_baseline.xml) |
|
|
123
|
+
| `lcovonly` | Outputs coverage data in LCOV format, useful for integrating with LCOV-based tools. | [LCovOnly example](https://raw.githubusercontent.com/mcarvin8/apex-code-coverage-transformer/main/test/lcov_baseline.info) |
|
|
124
|
+
| `cobertura` | Creates a Cobertura XML report, a widely used format for coverage reporting. | [Cobertura example](https://raw.githubusercontent.com/mcarvin8/apex-code-coverage-transformer/main/test/cobertura_baseline.xml) |
|
|
125
|
+
| `jacoco` | Creates a JaCoCo XML report, a format for Java. | [JaCoCo example](https://raw.githubusercontent.com/mcarvin8/apex-code-coverage-transformer/main/test/jacoco_baseline.xml) |
|
|
123
126
|
|
|
124
127
|
## Hook
|
|
125
128
|
|
|
@@ -143,7 +146,7 @@ The `.apexcodecovtransformer.config.json` follows this structure:
|
|
|
143
146
|
- `deployCoverageJsonPath` is required to use the hook after deploy commands and should be the path to the code coverage JSON created by the Salesforce CLI/SFDX Hardis deploy command. Recommend using a relative path.
|
|
144
147
|
- `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.
|
|
145
148
|
- `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.
|
|
146
|
-
- `format` is optional and should be the intended
|
|
149
|
+
- `format` is optional and should be the intended coverage report format created by this plugin. If this isn't provided, it will default to "sonar".
|
|
147
150
|
|
|
148
151
|
If the `.apexcodecovtransformer.config.json` file isn't found, the hook will be skipped.
|
|
149
152
|
|
|
@@ -171,7 +174,7 @@ The code coverage JSON files created by the Salesforce CLI deploy and test comma
|
|
|
171
174
|
Error (1): The provided JSON does not match a known coverage data format from the Salesforce deploy or test command.
|
|
172
175
|
```
|
|
173
176
|
|
|
174
|
-
If the `sfdx-project.json` file was not found in your
|
|
177
|
+
If the `sfdx-project.json` file was not found in your project's root folder, the plugin will fail with:
|
|
175
178
|
|
|
176
179
|
```
|
|
177
180
|
Error (1): sfdx-project.json not found in any parent directory.
|
|
@@ -183,9 +186,13 @@ Any ENOENT failures indicate that the plugin had issues finding one of the packa
|
|
|
183
186
|
Error (1): ENOENT: no such file or directory: {packageDirPath}
|
|
184
187
|
```
|
|
185
188
|
|
|
189
|
+
## Contributing
|
|
190
|
+
|
|
191
|
+
Contributions are welcome! See [Contributing](https://github.com/mcarvin8/apex-code-coverage-transformer/blob/main/CONTRIBUTING.md).
|
|
192
|
+
|
|
186
193
|
## Issues
|
|
187
194
|
|
|
188
|
-
If you encounter any issues, please create an issue in the
|
|
195
|
+
If you encounter any issues, please create an issue in the [issue tracker](https://github.com/mcarvin8/apex-code-coverage-transformer/issues). Please also create issues to suggest any new features.
|
|
189
196
|
|
|
190
197
|
## License
|
|
191
198
|
|
|
@@ -3,12 +3,14 @@ import { CloverCoverageHandler } from './cloverCoverageHandler.js';
|
|
|
3
3
|
import { CoberturaCoverageHandler } from './coberturaCoverageHandler.js';
|
|
4
4
|
import { SonarCoverageHandler } from './sonarCoverageHandler.js';
|
|
5
5
|
import { LcovCoverageHandler } from './lcovCoverageHandler.js';
|
|
6
|
+
import { JaCoCoCoverageHandler } from './jacocoCoverageHandler.js';
|
|
6
7
|
export function getCoverageHandler(format) {
|
|
7
8
|
const handlers = {
|
|
8
9
|
sonar: new SonarCoverageHandler(),
|
|
9
10
|
cobertura: new CoberturaCoverageHandler(),
|
|
10
11
|
clover: new CloverCoverageHandler(),
|
|
11
12
|
lcovonly: new LcovCoverageHandler(),
|
|
13
|
+
jacoco: new JaCoCoCoverageHandler(),
|
|
12
14
|
};
|
|
13
15
|
const handler = handlers[format];
|
|
14
16
|
if (!handler) {
|
|
@@ -1 +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,0BAA0B,CAAC;
|
|
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,0BAA0B,CAAC;AAC/D,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,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;QACnC,MAAM,EAAE,IAAI,qBAAqB,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,8 @@
|
|
|
1
|
+
import { JaCoCoCoverageObject, CoverageHandler } from '../helpers/types.js';
|
|
2
|
+
export declare class JaCoCoCoverageHandler implements CoverageHandler {
|
|
3
|
+
private readonly coverageObj;
|
|
4
|
+
private packageObj;
|
|
5
|
+
constructor();
|
|
6
|
+
processFile(filePath: string, fileName: string, lines: Record<string, number>): void;
|
|
7
|
+
finalize(): JaCoCoCoverageObject;
|
|
8
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
export class JaCoCoCoverageHandler {
|
|
3
|
+
coverageObj;
|
|
4
|
+
packageObj;
|
|
5
|
+
constructor() {
|
|
6
|
+
this.coverageObj = {
|
|
7
|
+
report: {
|
|
8
|
+
'@name': 'JaCoCo Coverage Report',
|
|
9
|
+
sessionInfo: [],
|
|
10
|
+
packages: { package: [] },
|
|
11
|
+
},
|
|
12
|
+
};
|
|
13
|
+
this.packageObj = {
|
|
14
|
+
'@name': 'main',
|
|
15
|
+
classes: { class: [] },
|
|
16
|
+
};
|
|
17
|
+
this.coverageObj.report.packages.package.push(this.packageObj);
|
|
18
|
+
}
|
|
19
|
+
processFile(filePath, fileName, lines) {
|
|
20
|
+
const sourceFileObj = {
|
|
21
|
+
'@name': fileName,
|
|
22
|
+
lines: { line: [] },
|
|
23
|
+
counters: { counter: [] },
|
|
24
|
+
};
|
|
25
|
+
let coveredLines = 0;
|
|
26
|
+
let totalLines = 0;
|
|
27
|
+
for (const [lineNumber, isCovered] of Object.entries(lines)) {
|
|
28
|
+
totalLines++;
|
|
29
|
+
if (isCovered === 1)
|
|
30
|
+
coveredLines++;
|
|
31
|
+
const lineObj = {
|
|
32
|
+
'@nr': Number(lineNumber),
|
|
33
|
+
'@mi': isCovered === 0 ? 1 : 0,
|
|
34
|
+
'@ci': isCovered === 1 ? 1 : 0,
|
|
35
|
+
};
|
|
36
|
+
sourceFileObj.lines.line.push(lineObj);
|
|
37
|
+
}
|
|
38
|
+
sourceFileObj.counters.counter.push({
|
|
39
|
+
'@type': 'LINE',
|
|
40
|
+
'@missed': totalLines - coveredLines,
|
|
41
|
+
'@covered': coveredLines,
|
|
42
|
+
});
|
|
43
|
+
const classObj = {
|
|
44
|
+
'@name': fileName,
|
|
45
|
+
sourcefile: sourceFileObj,
|
|
46
|
+
};
|
|
47
|
+
this.packageObj.classes.class.push(classObj);
|
|
48
|
+
}
|
|
49
|
+
finalize() {
|
|
50
|
+
if (this.coverageObj.report?.packages?.package) {
|
|
51
|
+
this.coverageObj.report.packages.package.sort((a, b) => a['@name'].localeCompare(b['@name']));
|
|
52
|
+
for (const pkg of this.coverageObj.report.packages.package) {
|
|
53
|
+
if (pkg.classes?.class) {
|
|
54
|
+
pkg.classes.class.sort((a, b) => a.sourcefile['@name'].localeCompare(b.sourcefile['@name']));
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
return this.coverageObj;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
//# sourceMappingURL=jacocoCoverageHandler.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jacocoCoverageHandler.js","sourceRoot":"","sources":["../../src/handlers/jacocoCoverageHandler.ts"],"names":[],"mappings":"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"}
|
package/lib/helpers/constants.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export const formatOptions = ['sonar', 'cobertura', 'clover', 'lcovonly'];
|
|
1
|
+
export const formatOptions = ['sonar', 'cobertura', 'clover', 'lcovonly', 'jacoco'];
|
|
2
2
|
//# sourceMappingURL=constants.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/helpers/constants.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,aAAa,GAAa,CAAC,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,UAAU,CAAC,CAAC"}
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/helpers/constants.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,aAAa,GAAa,CAAC,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,UAAU,EAAE,QAAQ,CAAC,CAAC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { SonarCoverageObject, CoberturaCoverageObject, CloverCoverageObject, LcovCoverageObject } from './types.js';
|
|
2
|
-
export declare function generateReport(coverageObj: SonarCoverageObject | CoberturaCoverageObject | CloverCoverageObject | LcovCoverageObject, format: string): string;
|
|
1
|
+
import { SonarCoverageObject, CoberturaCoverageObject, CloverCoverageObject, LcovCoverageObject, JaCoCoCoverageObject } from './types.js';
|
|
2
|
+
export declare function generateReport(coverageObj: SonarCoverageObject | CoberturaCoverageObject | CloverCoverageObject | LcovCoverageObject | JaCoCoCoverageObject, format: string): string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generateReport.js","sourceRoot":"","sources":["../../src/helpers/generateReport.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAEb,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"generateReport.js","sourceRoot":"","sources":["../../src/helpers/generateReport.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAEb,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AASrC,MAAM,UAAU,cAAc,CAC5B,WAKwB,EACxB,MAAc;IAEd,IAAI,MAAM,KAAK,UAAU,EAAE,CAAC;QAC1B,IAAI,OAAO,IAAI,WAAW,EAAE,CAAC;YAC3B,IAAI,UAAU,GAAG,EAAE,CAAC;YACpB,KAAK,MAAM,IAAI,IAAI,WAAW,CAAC,KAAK,EAAE,CAAC;gBACrC,UAAU,IAAI,WAAW,IAAI,CAAC,UAAU,IAAI,CAAC;gBAC7C,UAAU,IAAI,gBAAgB,CAAC;gBAE/B,KAAK,MAAM,IAAI,IAAI,IAAI,CAAC,KAAK,EAAE,CAAC;oBAC9B,UAAU,IAAI,MAAM,IAAI,CAAC,UAAU,IAAI,IAAI,CAAC,QAAQ,IAAI,CAAC;gBAC3D,CAAC;gBAED,UAAU,IAAI,MAAM,IAAI,CAAC,UAAU,IAAI,CAAC;gBACxC,UAAU,IAAI,MAAM,IAAI,CAAC,YAAY,IAAI,CAAC;gBAC1C,UAAU,IAAI,gBAAgB,CAAC;gBAC/B,UAAU,IAAI,iBAAiB,CAAC;YAClC,CAAC;YACD,OAAO,UAAU,CAAC;QACpB,CAAC;IACH,CAAC;IAED,MAAM,UAAU,GAAG,MAAM,KAAK,WAAW,IAAI,MAAM,KAAK,QAAQ,CAAC;IACjE,IAAI,GAAG,GAAG,MAAM,CAAC,WAAW,CAAC,CAAC,GAAG,CAAC,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,UAAU,EAAE,CAAC,CAAC;IAE7F,IAAI,MAAM,KAAK,WAAW,EAAE,CAAC;QAC3B,GAAG,GAAG,8GAA8G,GAAG,EAAE,CAAC;IAC5H,CAAC;SAAM,IAAI,MAAM,KAAK,QAAQ,EAAE,CAAC;QAC/B,GAAG,GAAG,2CAA2C,GAAG,EAAE,CAAC;IACzD,CAAC;IAED,OAAO,GAAG,CAAC;AACb,CAAC"}
|
package/lib/helpers/types.d.ts
CHANGED
|
@@ -145,7 +145,7 @@ export type CloverCoverageObject = {
|
|
|
145
145
|
};
|
|
146
146
|
export type CoverageHandler = {
|
|
147
147
|
processFile(filePath: string, fileName: string, lines: Record<string, number>): void;
|
|
148
|
-
finalize(): SonarCoverageObject | CoberturaCoverageObject | CloverCoverageObject | LcovCoverageObject;
|
|
148
|
+
finalize(): SonarCoverageObject | CoberturaCoverageObject | CloverCoverageObject | LcovCoverageObject | JaCoCoCoverageObject;
|
|
149
149
|
};
|
|
150
150
|
type LcovLine = {
|
|
151
151
|
lineNumber: number;
|
|
@@ -160,4 +160,47 @@ export type LcovFile = {
|
|
|
160
160
|
export type LcovCoverageObject = {
|
|
161
161
|
files: LcovFile[];
|
|
162
162
|
};
|
|
163
|
+
type JaCoCoCounter = {
|
|
164
|
+
'@type': 'INSTRUCTION' | 'BRANCH' | 'LINE' | 'METHOD' | 'CLASS';
|
|
165
|
+
'@missed': number;
|
|
166
|
+
'@covered': number;
|
|
167
|
+
};
|
|
168
|
+
export type JaCoCoLine = {
|
|
169
|
+
'@nr': number;
|
|
170
|
+
'@mi': number;
|
|
171
|
+
'@ci': number;
|
|
172
|
+
};
|
|
173
|
+
export type JaCoCoSourceFile = {
|
|
174
|
+
'@name': string;
|
|
175
|
+
lines: {
|
|
176
|
+
line: JaCoCoLine[];
|
|
177
|
+
};
|
|
178
|
+
counters: {
|
|
179
|
+
counter: JaCoCoCounter[];
|
|
180
|
+
};
|
|
181
|
+
};
|
|
182
|
+
export type JaCoCoClass = {
|
|
183
|
+
'@name': string;
|
|
184
|
+
sourcefile: JaCoCoSourceFile;
|
|
185
|
+
};
|
|
186
|
+
export type JaCoCoPackage = {
|
|
187
|
+
'@name': string;
|
|
188
|
+
classes: {
|
|
189
|
+
class: JaCoCoClass[];
|
|
190
|
+
};
|
|
191
|
+
};
|
|
192
|
+
type JaCoCoSessionInfo = {
|
|
193
|
+
'@id': string;
|
|
194
|
+
'@start': number;
|
|
195
|
+
'@dump': number;
|
|
196
|
+
};
|
|
197
|
+
export type JaCoCoCoverageObject = {
|
|
198
|
+
report: {
|
|
199
|
+
'@name': string;
|
|
200
|
+
sessionInfo: JaCoCoSessionInfo[];
|
|
201
|
+
packages: {
|
|
202
|
+
package: JaCoCoPackage[];
|
|
203
|
+
};
|
|
204
|
+
};
|
|
205
|
+
};
|
|
163
206
|
export {};
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
# summary
|
|
2
2
|
|
|
3
|
-
Transform Salesforce Apex code coverage JSONs created during deployments and test runs into other formats accepted by SonarQube, GitHub, GitLab, etc.
|
|
3
|
+
Transform Salesforce Apex code coverage JSONs created during deployments and test runs into other formats accepted by SonarQube, GitHub, GitLab, Azure, Bitbucket, etc.
|
|
4
4
|
|
|
5
5
|
# description
|
|
6
6
|
|
|
7
|
-
Transform Salesforce Apex code coverage JSONs created during deployments and test runs into other formats accepted by SonarQube, GitHub, GitLab, etc.
|
|
7
|
+
Transform Salesforce Apex code coverage JSONs created during deployments and test runs into other formats accepted by SonarQube, GitHub, GitLab, Azure, Bitbucket, etc.
|
|
8
8
|
|
|
9
9
|
# examples
|
|
10
10
|
|
package/oclif.manifest.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"acc-transformer:transform": {
|
|
4
4
|
"aliases": [],
|
|
5
5
|
"args": {},
|
|
6
|
-
"description": "Transform Salesforce Apex code coverage JSONs created during deployments and test runs into other formats accepted by SonarQube, GitHub, GitLab, etc.",
|
|
6
|
+
"description": "Transform Salesforce Apex code coverage JSONs created during deployments and test runs into other formats accepted by SonarQube, GitHub, GitLab, Azure, Bitbucket, etc.",
|
|
7
7
|
"examples": [
|
|
8
8
|
"`sf acc-transformer transform -j \"coverage.json\" -r \"coverage.xml\" -f \"sonar\"`",
|
|
9
9
|
"`sf acc-transformer transform -j \"coverage.json\" -r \"coverage.xml\" -f \"cobertura\"`",
|
|
@@ -57,7 +57,8 @@
|
|
|
57
57
|
"sonar",
|
|
58
58
|
"cobertura",
|
|
59
59
|
"clover",
|
|
60
|
-
"lcovonly"
|
|
60
|
+
"lcovonly",
|
|
61
|
+
"jacoco"
|
|
61
62
|
],
|
|
62
63
|
"type": "option"
|
|
63
64
|
}
|
|
@@ -69,7 +70,7 @@
|
|
|
69
70
|
"pluginName": "apex-code-coverage-transformer",
|
|
70
71
|
"pluginType": "core",
|
|
71
72
|
"strict": true,
|
|
72
|
-
"summary": "Transform Salesforce Apex code coverage JSONs created during deployments and test runs into other formats accepted by SonarQube, GitHub, GitLab, etc.",
|
|
73
|
+
"summary": "Transform Salesforce Apex code coverage JSONs created during deployments and test runs into other formats accepted by SonarQube, GitHub, GitLab, Azure, Bitbucket, etc.",
|
|
73
74
|
"enableJsonFlag": true,
|
|
74
75
|
"isESM": true,
|
|
75
76
|
"relativePath": [
|
|
@@ -85,5 +86,5 @@
|
|
|
85
86
|
]
|
|
86
87
|
}
|
|
87
88
|
},
|
|
88
|
-
"version": "2.
|
|
89
|
+
"version": "2.8.1"
|
|
89
90
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "apex-code-coverage-transformer",
|
|
3
|
-
"description": "Transform Salesforce Apex code coverage JSONs created during deployments and test runs into other formats accepted by SonarQube, GitHub, GitLab, etc.",
|
|
4
|
-
"version": "2.
|
|
3
|
+
"description": "Transform Salesforce Apex code coverage JSONs created during deployments and test runs into other formats accepted by SonarQube, GitHub, GitLab, Azure, Bitbucket, etc.",
|
|
4
|
+
"version": "2.8.1",
|
|
5
5
|
"dependencies": {
|
|
6
6
|
"@oclif/core": "^4.0.37",
|
|
7
7
|
"@salesforce/core": "^8.8.0",
|
|
@@ -55,7 +55,12 @@
|
|
|
55
55
|
"code",
|
|
56
56
|
"quality",
|
|
57
57
|
"validation",
|
|
58
|
-
"deployment"
|
|
58
|
+
"deployment",
|
|
59
|
+
"gitlab",
|
|
60
|
+
"github",
|
|
61
|
+
"azure",
|
|
62
|
+
"bitbucket",
|
|
63
|
+
"jacoco"
|
|
59
64
|
],
|
|
60
65
|
"license": "MIT",
|
|
61
66
|
"oclif": {
|