apex-code-coverage-transformer 2.20.0 → 2.21.0
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 +7 -0
- package/README.md +17 -8
- package/lib/utils/setCoveredLines.js +3 -0
- package/lib/utils/setCoveredLines.js.map +1 -1
- package/oclif.manifest.json +1 -1
- package/package.json +5 -1
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,13 @@
|
|
|
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.21.0](https://github.com/mcarvin8/apex-code-coverage-transformer/compare/v2.20.0...v2.21.0) (2026-06-02)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Features
|
|
12
|
+
|
|
13
|
+
* log out-of-range covered line remappings at debug level ([#300](https://github.com/mcarvin8/apex-code-coverage-transformer/issues/300)) ([e812869](https://github.com/mcarvin8/apex-code-coverage-transformer/commit/e812869eff4290af8d3e519ea59fd754475ac325))
|
|
14
|
+
|
|
8
15
|
## [2.20.0](https://github.com/mcarvin8/apex-code-coverage-transformer/compare/v2.19.2...v2.20.0) (2026-05-29)
|
|
9
16
|
|
|
10
17
|
|
package/README.md
CHANGED
|
@@ -5,10 +5,9 @@
|
|
|
5
5
|
[](https://raw.githubusercontent.com/mcarvin8/apex-code-coverage-transformer/main/LICENSE.md)
|
|
6
6
|
[](https://qlty.sh/gh/mcarvin8/projects/apex-code-coverage-transformer)
|
|
7
7
|
[](https://codecov.io/gh/mcarvin8/apex-code-coverage-transformer)
|
|
8
|
+
[](https://dashboard.stryker-mutator.io/reports/github.com/mcarvin8/apex-code-coverage-transformer/main)
|
|
8
9
|
|
|
9
|
-
A Salesforce CLI plugin that converts Apex code coverage JSON (from deploy or test runs) into formats used by SonarQube, Codecov, GitHub, GitLab, Azure DevOps, Bitbucket, and other tools
|
|
10
|
-
|
|
11
|
-
It also produces presentation-ready output for pull-request reviews: a Markdown summary for PR/MR comments and CI job summaries, and GitHub Actions workflow command annotations that surface uncovered lines inline on the PR diff. The GitHub Actions output pairs with the Apex code quality annotations from [sf-cat](https://www.npmjs.com/package/sf-cat), so a single PR can show coverage gaps and quality findings side-by-side.
|
|
10
|
+
A Salesforce CLI plugin that converts Apex code coverage JSON (from deploy 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.
|
|
12
11
|
|
|
13
12
|
> Missing an output format via `--format`? Open an [issue](https://github.com/mcarvin8/apex-code-coverage-transformer/issues) or submit a [pull request](https://github.com/mcarvin8/apex-code-coverage-transformer/blob/main/CONTRIBUTING.md).
|
|
14
13
|
|
|
@@ -245,11 +244,7 @@ The `github-actions` format emits one [`::warning`](https://docs.github.com/en/a
|
|
|
245
244
|
run: cat coverage.txt
|
|
246
245
|
```
|
|
247
246
|
|
|
248
|
-
Pairs with [`sf-cat`](https://www.
|
|
249
|
-
|
|
250
|
-
```bash
|
|
251
|
-
sf acc-transformer transform -j "coverage/test-result-codecoverage.json" -f "markdown" -f "github-actions" -f "sonar"
|
|
252
|
-
```
|
|
247
|
+
Pairs with [`sf-cat`](https://www.github.com/mcarvin8/sf-cat) for code quality annotations on the same diff if you use Salesforce Code Analyzer.
|
|
253
248
|
|
|
254
249
|
### GitLab CI
|
|
255
250
|
|
|
@@ -350,6 +345,20 @@ Error (1): ENOENT: no such file or directory: {packageDir}
|
|
|
350
345
|
|
|
351
346
|
**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).
|
|
352
347
|
|
|
348
|
+
To see each remapping, set `SF_LOG_LEVEL=debug` before running the command:
|
|
349
|
+
|
|
350
|
+
```bash
|
|
351
|
+
SF_LOG_LEVEL=debug sf acc-transformer transform -j "coverage/coverage/coverage.json" -r "coverage.xml" -f "sonar"
|
|
352
|
+
```
|
|
353
|
+
|
|
354
|
+
Each remapped line emits a log entry like:
|
|
355
|
+
|
|
356
|
+
```
|
|
357
|
+
Remapping out-of-range covered line 512 to line 47 in force-app/main/default/classes/AccountHandler.cls (file has 98 lines)
|
|
358
|
+
```
|
|
359
|
+
|
|
360
|
+
Logs are written to `~/.sf/sf-YYYY-MM-DD.log` by default. To print them to the terminal as well, set `DEBUG=sf:setCoveredLines`.
|
|
361
|
+
|
|
353
362
|
## License
|
|
354
363
|
|
|
355
364
|
[MIT](https://raw.githubusercontent.com/mcarvin8/apex-code-coverage-transformer/main/LICENSE.md)
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
import { join } from 'node:path';
|
|
3
|
+
import { Logger } from '@salesforce/core';
|
|
3
4
|
import { getTotalLines } from './getTotalLines.js';
|
|
4
5
|
export async function setCoveredLines(filePath, repoRoot, lines, returnSourceContent = false) {
|
|
6
|
+
const logger = await Logger.child('setCoveredLines');
|
|
5
7
|
const result = await getTotalLines(join(repoRoot, filePath), returnSourceContent);
|
|
6
8
|
const totalLines = typeof result === 'number' ? result : result.totalLines;
|
|
7
9
|
const updatedLines = {};
|
|
@@ -12,6 +14,7 @@ export async function setCoveredLines(filePath, repoRoot, lines, returnSourceCon
|
|
|
12
14
|
if (status === 1 && lineNumber > totalLines) {
|
|
13
15
|
for (let randomLine = 1; randomLine <= totalLines; randomLine++) {
|
|
14
16
|
if (!usedLines.has(randomLine)) {
|
|
17
|
+
logger.debug(`Remapping out-of-range covered line ${lineNumber} to line ${randomLine} in ${filePath} (file has ${totalLines} lines)`);
|
|
15
18
|
updatedLines[randomLine.toString()] = status;
|
|
16
19
|
usedLines.add(randomLine);
|
|
17
20
|
break;
|
|
@@ -1 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@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "apex-code-coverage-transformer",
|
|
3
3
|
"description": "Transform Salesforce Apex code coverage JSONs into other formats accepted by SonarQube, GitHub, GitLab, Azure, Bitbucket, etc.",
|
|
4
|
-
"version": "2.
|
|
4
|
+
"version": "2.21.0",
|
|
5
5
|
"dependencies": {
|
|
6
6
|
"@oclif/core": "4.8.3",
|
|
7
7
|
"@salesforce/core": "8.26.3",
|
|
@@ -15,6 +15,8 @@
|
|
|
15
15
|
"@salesforce/cli-plugins-testkit": "5.3.39",
|
|
16
16
|
"@salesforce/dev-config": "4.3.3",
|
|
17
17
|
"@salesforce/prettier-config": "0.0.4",
|
|
18
|
+
"@stryker-mutator/core": "9.6.1",
|
|
19
|
+
"@stryker-mutator/vitest-runner": "9.6.1",
|
|
18
20
|
"@types/node": "20.19.39",
|
|
19
21
|
"@vitest/coverage-v8": "4.1.5",
|
|
20
22
|
"eslint-config-salesforce-typescript": "4.0.1",
|
|
@@ -98,6 +100,8 @@
|
|
|
98
100
|
"prepack": "wireit",
|
|
99
101
|
"prepare": "husky install",
|
|
100
102
|
"test": "wireit",
|
|
103
|
+
"test:mutation": "stryker run",
|
|
104
|
+
"test:mutation:incremental": "node scripts/incremental-mutation.mjs",
|
|
101
105
|
"test:nuts": "oclif manifest && vitest run --config ./vitest.nut.config.ts",
|
|
102
106
|
"test:only": "wireit",
|
|
103
107
|
"version": "oclif readme"
|