apex-code-coverage-transformer 2.8.0 → 2.8.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 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.2](https://github.com/mcarvin8/apex-code-coverage-transformer/compare/v2.8.1...v2.8.2) (2025-02-07)
9
+
10
+
11
+ ### Bug Fixes
12
+
13
+ * include file path in jacoco sourcefile ([c3df27e](https://github.com/mcarvin8/apex-code-coverage-transformer/commit/c3df27ed3544bd7145267b3cdde617f2719bd034))
14
+
15
+ ## [2.8.1](https://github.com/mcarvin8/apex-code-coverage-transformer/compare/v2.8.0...v2.8.1) (2025-02-07)
16
+
17
+
18
+ ### Bug Fixes
19
+
20
+ * jacoco sourcefile structure ([0a1275f](https://github.com/mcarvin8/apex-code-coverage-transformer/commit/0a1275f2d6ef5732c06568d183e4aa8e5def8951))
21
+
8
22
  ## [2.8.0](https://github.com/mcarvin8/apex-code-coverage-transformer/compare/v2.7.2...v2.8.0) (2025-02-07)
9
23
 
10
24
 
package/README.md CHANGED
@@ -56,7 +56,7 @@ sf apex run test --code-coverage --output-dir "coverage"
56
56
  sf apex get test --test-run-id <test run id> --code-coverage --output-dir "coverage"
57
57
  ```
58
58
 
59
- 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.
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.
60
60
 
61
61
  ## Creating Code Coverage Files with SFDX Hardis
62
62
 
@@ -66,7 +66,7 @@ Both hardis commands will create the code coverage JSON to transform here: `hard
66
66
 
67
67
  ## What this Plugin fixes in the Salesforce CLI Coverage Reports
68
68
 
69
- - 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.
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
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
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
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".
@@ -174,7 +174,7 @@ The code coverage JSON files created by the Salesforce CLI deploy and test comma
174
174
  Error (1): The provided JSON does not match a known coverage data format from the Salesforce deploy or test command.
175
175
  ```
176
176
 
177
- If the `sfdx-project.json` file was not found in your repository's root folder, the plugin will fail with:
177
+ If the `sfdx-project.json` file was not found in your project's root folder, the plugin will fail with:
178
178
 
179
179
  ```
180
180
  Error (1): sfdx-project.json not found in any parent directory.
@@ -192,7 +192,7 @@ Contributions are welcome! See [Contributing](https://github.com/mcarvin8/apex-c
192
192
 
193
193
  ## Issues
194
194
 
195
- 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.
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.
196
196
 
197
197
  ## License
198
198
 
@@ -17,9 +17,8 @@ export class JaCoCoCoverageHandler {
17
17
  this.coverageObj.report.packages.package.push(this.packageObj);
18
18
  }
19
19
  processFile(filePath, fileName, lines) {
20
- const classObj = {
21
- '@name': fileName,
22
- '@sourcefile': filePath,
20
+ const sourceFileObj = {
21
+ '@name': filePath,
23
22
  lines: { line: [] },
24
23
  counters: { counter: [] },
25
24
  };
@@ -34,13 +33,17 @@ export class JaCoCoCoverageHandler {
34
33
  '@mi': isCovered === 0 ? 1 : 0,
35
34
  '@ci': isCovered === 1 ? 1 : 0,
36
35
  };
37
- classObj.lines.line.push(lineObj);
36
+ sourceFileObj.lines.line.push(lineObj);
38
37
  }
39
- classObj.counters.counter.push({
38
+ sourceFileObj.counters.counter.push({
40
39
  '@type': 'LINE',
41
40
  '@missed': totalLines - coveredLines,
42
41
  '@covered': coveredLines,
43
42
  });
43
+ const classObj = {
44
+ '@name': fileName,
45
+ sourcefile: sourceFileObj,
46
+ };
44
47
  this.packageObj.classes.class.push(classObj);
45
48
  }
46
49
  finalize() {
@@ -48,7 +51,7 @@ export class JaCoCoCoverageHandler {
48
51
  this.coverageObj.report.packages.package.sort((a, b) => a['@name'].localeCompare(b['@name']));
49
52
  for (const pkg of this.coverageObj.report.packages.package) {
50
53
  if (pkg.classes?.class) {
51
- pkg.classes.class.sort((a, b) => a['@sourcefile'].localeCompare(b['@sourcefile']));
54
+ pkg.classes.class.sort((a, b) => a.sourcefile['@name'].localeCompare(b.sourcefile['@name']));
52
55
  }
53
56
  }
54
57
  }
@@ -1 +1 @@
1
- {"version":3,"file":"jacocoCoverageHandler.js","sourceRoot":"","sources":["../../src/handlers/jacocoCoverageHandler.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAIb,MAAM,OAAO,qBAAqB;IACf,WAAW,CAAuB;IAC3C,UAAU,CAAgB;IAElC;QACE,IAAI,CAAC,WAAW,GAAG;YACjB,MAAM,EAAE;gBACN,OAAO,EAAE,wBAAwB;gBACjC,WAAW,EAAE,EAAE;gBACf,QAAQ,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE;aAC1B;SACF,CAAC;QACF,IAAI,CAAC,UAAU,GAAG;Y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,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IAC/C,CAAC;IAEM,QAAQ;QACb,IAAI,IAAI,CAAC,WAAW,CAAC,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAE,CAAC;YAC/C,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;YAC9F,KAAK,MAAM,GAAG,IAAI,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,QAAQ,CAAC,OAAO,EAAE,CAAC;gBAC3D,IAAI,GAAG,CAAC,OAAO,EAAE,KAAK,EAAE,CAAC;oBACvB,GAAG,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;gBAC/F,CAAC;YACH,CAAC;QACH,CAAC;QACD,OAAO,IAAI,CAAC,WAAW,CAAC;IAC1B,CAAC;CACF"}
@@ -160,7 +160,7 @@ export type LcovFile = {
160
160
  export type LcovCoverageObject = {
161
161
  files: LcovFile[];
162
162
  };
163
- export type JaCoCoCounter = {
163
+ type JaCoCoCounter = {
164
164
  '@type': 'INSTRUCTION' | 'BRANCH' | 'LINE' | 'METHOD' | 'CLASS';
165
165
  '@missed': number;
166
166
  '@covered': number;
@@ -170,9 +170,8 @@ export type JaCoCoLine = {
170
170
  '@mi': number;
171
171
  '@ci': number;
172
172
  };
173
- export type JaCoCoClass = {
173
+ export type JaCoCoSourceFile = {
174
174
  '@name': string;
175
- '@sourcefile': string;
176
175
  lines: {
177
176
  line: JaCoCoLine[];
178
177
  };
@@ -180,13 +179,17 @@ export type JaCoCoClass = {
180
179
  counter: JaCoCoCounter[];
181
180
  };
182
181
  };
182
+ export type JaCoCoClass = {
183
+ '@name': string;
184
+ sourcefile: JaCoCoSourceFile;
185
+ };
183
186
  export type JaCoCoPackage = {
184
187
  '@name': string;
185
188
  classes: {
186
189
  class: JaCoCoClass[];
187
190
  };
188
191
  };
189
- export type JaCoCoSessionInfo = {
192
+ type JaCoCoSessionInfo = {
190
193
  '@id': string;
191
194
  '@start': number;
192
195
  '@dump': number;
@@ -86,5 +86,5 @@
86
86
  ]
87
87
  }
88
88
  },
89
- "version": "2.8.0"
89
+ "version": "2.8.2"
90
90
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "apex-code-coverage-transformer",
3
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.0",
4
+ "version": "2.8.2",
5
5
  "dependencies": {
6
6
  "@oclif/core": "^4.0.37",
7
7
  "@salesforce/core": "^8.8.0",