apex-code-coverage-transformer 3.1.1 → 3.1.3
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 +22 -17
- package/lib/utils/setCoveredLines.js +7 -3
- package/lib/utils/setCoveredLines.js.map +1 -1
- package/oclif.manifest.json +1 -1
- package/package.json +1 -1
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
|
+
## [3.1.3](https://github.com/mcarvin8/apex-code-coverage-transformer/compare/v3.1.2...v3.1.3) (2026-08-21)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Bug Fixes
|
|
12
|
+
|
|
13
|
+
* **action:** remove @salesforce/core Logger call breaking the bundled Action ([#386](https://github.com/mcarvin8/apex-code-coverage-transformer/issues/386)) ([ae14d34](https://github.com/mcarvin8/apex-code-coverage-transformer/commit/ae14d349058fe9a3ef3e3cff59ec2cfad06a8338))
|
|
14
|
+
|
|
15
|
+
## [3.1.2](https://github.com/mcarvin8/apex-code-coverage-transformer/compare/v3.1.1...v3.1.2) (2026-08-21)
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
### Bug Fixes
|
|
19
|
+
|
|
20
|
+
* **action:** shorten description for Marketplace's 125-char limit ([#380](https://github.com/mcarvin8/apex-code-coverage-transformer/issues/380)) ([ff75703](https://github.com/mcarvin8/apex-code-coverage-transformer/commit/ff75703c18133714d430c1959dead12615c0958c))
|
|
21
|
+
|
|
8
22
|
## [3.1.1](https://github.com/mcarvin8/apex-code-coverage-transformer/compare/v3.1.0...v3.1.1) (2026-08-21)
|
|
9
23
|
|
|
10
24
|
|
package/README.md
CHANGED
|
@@ -2,18 +2,20 @@
|
|
|
2
2
|
|
|
3
3
|
[](https://www.npmjs.com/package/apex-code-coverage-transformer)
|
|
4
4
|
[](https://npmjs.org/package/apex-code-coverage-transformer)
|
|
5
|
+
[](https://github.com/marketplace/actions/apex-code-coverage-transformer)
|
|
5
6
|
[](https://raw.githubusercontent.com/mcarvin8/apex-code-coverage-transformer/main/LICENSE.md)
|
|
6
7
|
[](https://qlty.sh/gh/mcarvin8/projects/apex-code-coverage-transformer)
|
|
7
8
|
[](https://codecov.io/gh/mcarvin8/apex-code-coverage-transformer)
|
|
8
9
|
[](https://dashboard.stryker-mutator.io/reports/github.com/mcarvin8/apex-code-coverage-transformer/main)
|
|
9
10
|
|
|
10
|
-
|
|
11
|
+
Transforms (and optionally merges) Apex code coverage JSON from Salesforce deployments or test runs into formats used by SonarQube, Codecov, GitHub, GitLab, Azure DevOps, Bitbucket, and other tools, keeping coverage visible across pull requests, CI/CD pipelines, and code quality platforms. Available as a **Salesforce CLI plugin** for any provider, and as a **native GitHub Action** for GitHub Actions users who want to skip installing the CLI.
|
|
11
12
|
|
|
12
13
|
<details>
|
|
13
14
|
<summary>Table of Contents</summary>
|
|
14
15
|
|
|
15
16
|
- [Prerequisites](#prerequisites)
|
|
16
17
|
- [Install](#install)
|
|
18
|
+
- [GitHub Action](#github-action)
|
|
17
19
|
- [Quick Start](#quick-start)
|
|
18
20
|
- [Usage](#usage)
|
|
19
21
|
- [Command Reference](#command-reference)
|
|
@@ -39,6 +41,21 @@ A Salesforce CLI plugin that transforms (and optionally merges) Apex code covera
|
|
|
39
41
|
sf plugins install apex-code-coverage-transformer@latest
|
|
40
42
|
```
|
|
41
43
|
|
|
44
|
+
## GitHub Action
|
|
45
|
+
|
|
46
|
+
For GitHub Actions, this is also available as a [native Action](https://github.com/marketplace/actions/apex-code-coverage-transformer) - no `sf` CLI or plugin install required:
|
|
47
|
+
|
|
48
|
+
```yaml
|
|
49
|
+
- name: Transform Coverage
|
|
50
|
+
uses: mcarvin8/apex-code-coverage-transformer@v3
|
|
51
|
+
with:
|
|
52
|
+
coverage-json: coverage/test-result-codecoverage.json
|
|
53
|
+
output-report: coverage.xml
|
|
54
|
+
format: sonar
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
It still needs the checkout to contain `sfdx-project.json` (same as the CLI's [Prerequisites](#prerequisites) above) - use `actions/checkout` first. See [GitHub Actions](#github-actions) under CI/CD Integration for the full input/output reference and more examples.
|
|
58
|
+
|
|
42
59
|
## Quick Start
|
|
43
60
|
|
|
44
61
|
1. **Generate Apex code coverage (JSON)**
|
|
@@ -176,7 +193,7 @@ EXAMPLES
|
|
|
176
193
|
`sf acc-transformer transform -j "coverage1.json" -j "coverage2.json" -r "coverage.xml" -f "sonar"`
|
|
177
194
|
```
|
|
178
195
|
|
|
179
|
-
_See code: [src/commands/acc-transformer/transform.ts](https://github.com/mcarvin8/apex-code-coverage-transformer/blob/v3.1.
|
|
196
|
+
_See code: [src/commands/acc-transformer/transform.ts](https://github.com/mcarvin8/apex-code-coverage-transformer/blob/v3.1.3/src/commands/acc-transformer/transform.ts)_
|
|
180
197
|
<!-- commandsstop -->
|
|
181
198
|
|
|
182
199
|
## Coverage Report Formats
|
|
@@ -573,24 +590,12 @@ Error (1): ENOENT: no such file or directory: {packageDir}
|
|
|
573
590
|
|
|
574
591
|
**Deploy coverage line numbers** — The Salesforce CLI deploy coverage JSON contains known out-of-range line numbers. This plugin corrects them automatically by re-numbering covered lines; uncovered lines are unaffected. Test-command coverage is unaffected. See [forcedotcom/salesforcedx-vscode#5511](https://github.com/forcedotcom/salesforcedx-vscode/issues/5511) and [forcedotcom/cli#1568](https://github.com/forcedotcom/cli/issues/1568).
|
|
575
592
|
|
|
576
|
-
To see each remapping, set `SF_LOG_LEVEL=debug` before running the command:
|
|
577
|
-
|
|
578
|
-
```bash
|
|
579
|
-
SF_LOG_LEVEL=debug sf acc-transformer transform -j "coverage/coverage/coverage.json" -r "coverage.xml" -f "sonar"
|
|
580
|
-
```
|
|
581
|
-
|
|
582
|
-
Each remapped line emits a log entry like:
|
|
583
|
-
|
|
584
|
-
```
|
|
585
|
-
Remapping out-of-range covered line 512 to line 47 in force-app/main/default/classes/AccountHandler.cls (file has 98 lines)
|
|
586
|
-
```
|
|
587
|
-
|
|
588
|
-
Logs are written to `~/.sf/sf-YYYY-MM-DD.log` by default. To print them to the terminal as well, set `DEBUG=sf:setCoveredLines`.
|
|
593
|
+
To see each remapping, set `SF_LOG_LEVEL=debug` before running the command - each remapped line prints directly to the terminal:
|
|
589
594
|
|
|
590
595
|
```bash
|
|
591
|
-
$ SF_LOG_LEVEL=debug
|
|
596
|
+
$ SF_LOG_LEVEL=debug sf acc-transformer transform -j "coverage/coverage/coverage.json" -r "coverage.xml" -f "sonar"
|
|
597
|
+
[DEBUG] setCoveredLines: Remapping out-of-range covered line 512 to line 47 in force-app/main/default/classes/AccountHandler.cls (file has 98 lines)
|
|
592
598
|
The coverage report has been written to: coverage.xml
|
|
593
|
-
[16:10:20.826] DEBUG (sf:setCoveredLines): Remapping out-of-range covered line 190 to line 1 in force-app/main/default/triggers/AccountTrigger.trigger (file has 105 lines)
|
|
594
599
|
```
|
|
595
600
|
|
|
596
601
|
## Questions or Issues?
|
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
import { join } from 'node:path';
|
|
3
|
-
import { Logger } from '@salesforce/core';
|
|
4
3
|
import { getTotalLines } from './getTotalLines.js';
|
|
4
|
+
function debugLog(message) {
|
|
5
|
+
if (process.env.SF_LOG_LEVEL === 'debug') {
|
|
6
|
+
// eslint-disable-next-line no-console
|
|
7
|
+
console.debug(`[DEBUG] setCoveredLines: ${message}`);
|
|
8
|
+
}
|
|
9
|
+
}
|
|
5
10
|
export async function setCoveredLines(filePath, repoRoot, lines, returnSourceContent = false) {
|
|
6
|
-
const logger = await Logger.child('setCoveredLines');
|
|
7
11
|
const result = await getTotalLines(join(repoRoot, filePath), returnSourceContent);
|
|
8
12
|
const totalLines = typeof result === 'number' ? result : result.totalLines;
|
|
9
13
|
const updatedLines = {};
|
|
@@ -14,7 +18,7 @@ export async function setCoveredLines(filePath, repoRoot, lines, returnSourceCon
|
|
|
14
18
|
if (status === 1 && lineNumber > totalLines) {
|
|
15
19
|
for (let randomLine = 1; randomLine <= totalLines; randomLine++) {
|
|
16
20
|
if (!usedLines.has(randomLine)) {
|
|
17
|
-
|
|
21
|
+
debugLog(`Remapping out-of-range covered line ${lineNumber} to line ${randomLine} in ${filePath} (file has ${totalLines} lines)`);
|
|
18
22
|
updatedLines[randomLine.toString()] = status;
|
|
19
23
|
usedLines.add(randomLine);
|
|
20
24
|
break;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"setCoveredLines.js","sourceRoot":"","sources":["../../src/utils/setCoveredLines.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAEb,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"setCoveredLines.js","sourceRoot":"","sources":["../../src/utils/setCoveredLines.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAEb,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAMnD,SAAS,QAAQ,CAAC,OAAe;IAC/B,IAAI,OAAO,CAAC,GAAG,CAAC,YAAY,KAAK,OAAO,EAAE,CAAC;QACzC,sCAAsC;QACtC,OAAO,CAAC,KAAK,CAAC,4BAA4B,OAAO,EAAE,CAAC,CAAC;IACvD,CAAC;AACH,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,eAAe,CACnC,QAAgB,EAChB,QAAgB,EAChB,KAA6B,EAC7B,mBAAmB,GAAG,KAAK;IAE3B,MAAM,MAAM,GAAG,MAAM,aAAa,CAAC,IAAI,CAAC,QAAQ,EAAE,QAAQ,CAAC,EAAE,mBAAmB,CAAC,CAAC;IAClF,MAAM,UAAU,GAAG,OAAO,MAAM,KAAK,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,M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CAAC;IACzD,CAAC;IACD,OAAO,YAAY,CAAC;AACtB,CAAC"}
|
package/oclif.manifest.json
CHANGED
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 JSON for SonarQube, SonarCloud, GitHub, GitLab, Azure, and Bitbucket",
|
|
4
|
-
"version": "3.1.
|
|
4
|
+
"version": "3.1.3",
|
|
5
5
|
"dependencies": {
|
|
6
6
|
"@oclif/core": "4.13.3",
|
|
7
7
|
"@salesforce/core": "9.1.2",
|