apex-code-coverage-transformer 3.1.12 → 4.1.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 +18 -0
- package/README.md +15 -22
- package/lib/handlers/html.js +32 -13
- package/lib/handlers/html.js.map +1 -1
- package/lib/transformers/coverageProcessor.js +15 -12
- package/lib/transformers/coverageProcessor.js.map +1 -1
- package/lib/transformers/generators/generateHtml.js +11 -1
- package/lib/transformers/generators/generateHtml.js.map +1 -1
- package/lib/utils/types.d.ts +14 -6
- package/oclif.manifest.json +1 -1
- package/package.json +24 -21
- package/lib/utils/getTotalLines.d.ts +0 -5
- package/lib/utils/getTotalLines.js +0 -8
- package/lib/utils/getTotalLines.js.map +0 -1
- package/lib/utils/setCoveredLines.d.ts +0 -5
- package/lib/utils/setCoveredLines.js +0 -38
- package/lib/utils/setCoveredLines.js.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,24 @@
|
|
|
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
|
+
## [4.1.0](https://github.com/mcarvin8/apex-code-coverage-transformer/compare/v4.0.0...v4.1.0) (2026-11-05)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Features
|
|
12
|
+
|
|
13
|
+
* **html:** render full source file with coverage overlay ([#435](https://github.com/mcarvin8/apex-code-coverage-transformer/issues/435)) ([6cdc757](https://github.com/mcarvin8/apex-code-coverage-transformer/commit/6cdc757aeee44dbb58d7fb2546951357626be55b))
|
|
14
|
+
|
|
15
|
+
## [4.0.0](https://github.com/mcarvin8/apex-code-coverage-transformer/compare/v3.1.12...v4.0.0) (2026-11-05)
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
### ⚠ BREAKING CHANGES
|
|
19
|
+
|
|
20
|
+
* remove deploy coverage line renumbering ([#429](https://github.com/mcarvin8/apex-code-coverage-transformer/issues/429))
|
|
21
|
+
|
|
22
|
+
### Features
|
|
23
|
+
|
|
24
|
+
* remove deploy coverage line renumbering ([#429](https://github.com/mcarvin8/apex-code-coverage-transformer/issues/429)) ([0c15717](https://github.com/mcarvin8/apex-code-coverage-transformer/commit/0c157176edb7a9e0513f8558960f47bd97558a4a))
|
|
25
|
+
|
|
8
26
|
## [3.1.12](https://github.com/mcarvin8/apex-code-coverage-transformer/compare/v3.1.11...v3.1.12) (2026-10-28)
|
|
9
27
|
|
|
10
28
|
|
package/README.md
CHANGED
|
@@ -6,11 +6,13 @@
|
|
|
6
6
|
[](https://raw.githubusercontent.com/mcarvin8/apex-code-coverage-transformer/main/LICENSE.md)
|
|
7
7
|
[](https://codecov.io/gh/mcarvin8/apex-code-coverage-transformer)
|
|
8
8
|
[](https://dashboard.stryker-mutator.io/reports/github.com/mcarvin8/apex-code-coverage-transformer/main)
|
|
9
|
+
<!-- gh-dependents-info-used-by-start -->
|
|
10
|
+
[](https://github.com/mcarvin8/apex-code-coverage-transformer/blob/main/docs/github-dependents-info.md)<!-- gh-dependents-info-used-by-end -->
|
|
9
11
|
|
|
10
12
|
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
13
|
|
|
12
14
|
> [!WARNING]
|
|
13
|
-
> **
|
|
15
|
+
> **v4 breaking change:** v3 and earlier automatically re-numbered deploy command coverage lines that Salesforce reported beyond the end of a file. Salesforce fixed this bug server-side in Winter '27 (API v68.0), regardless of the `--api-version` used on the deploy, so v4 removes the re-numbering and passes deploy coverage lines through exactly as reported. Test-command coverage is unaffected. See [Troubleshooting](#troubleshooting) for details.
|
|
14
16
|
|
|
15
17
|
<details>
|
|
16
18
|
<summary>Table of Contents</summary>
|
|
@@ -49,7 +51,7 @@ For GitHub Actions, this is also available as a [native Action](https://github.c
|
|
|
49
51
|
|
|
50
52
|
```yaml
|
|
51
53
|
- name: Transform Coverage
|
|
52
|
-
uses: mcarvin8/apex-code-coverage-transformer@
|
|
54
|
+
uses: mcarvin8/apex-code-coverage-transformer@v4
|
|
53
55
|
with:
|
|
54
56
|
coverage-json: coverage/test-result-codecoverage.json
|
|
55
57
|
output-report: coverage.xml
|
|
@@ -128,6 +130,7 @@ Works with [sfdx-hardis](https://github.com/hardisgroupcom/sfdx-hardis):
|
|
|
128
130
|
|
|
129
131
|
## Command Reference
|
|
130
132
|
|
|
133
|
+
<!-- biome-ignore format: oclif readme writes this list with `*` bullets -->
|
|
131
134
|
<!-- commands -->
|
|
132
135
|
* [`sf acc-transformer transform`](#sf-acc-transformer-transform)
|
|
133
136
|
|
|
@@ -194,7 +197,7 @@ EXAMPLES
|
|
|
194
197
|
`sf acc-transformer transform -j "coverage1.json" -j "coverage2.json" -r "coverage.xml" -f "sonar"`
|
|
195
198
|
```
|
|
196
199
|
|
|
197
|
-
_See code: [src/commands/acc-transformer/transform.ts](https://github.com/mcarvin8/apex-code-coverage-transformer/blob/
|
|
200
|
+
_See code: [src/commands/acc-transformer/transform.ts](https://github.com/mcarvin8/apex-code-coverage-transformer/blob/v4.1.0/src/commands/acc-transformer/transform.ts)_
|
|
198
201
|
<!-- commandsstop -->
|
|
199
202
|
|
|
200
203
|
## Coverage Report Formats
|
|
@@ -202,7 +205,7 @@ _See code: [src/commands/acc-transformer/transform.ts](https://github.com/mcarvi
|
|
|
202
205
|
Use `-f` / `--format` to choose the output format. Multiple `-f` values produce multiple files with the format in the name (e.g. `coverage-sonar.xml`, `coverage-cobertura.xml`).
|
|
203
206
|
|
|
204
207
|
| Format | Description | Typical use | Example |
|
|
205
|
-
|
|
208
|
+
| -------------- | -------------------------- | --------------------------------------- | --------------------------------------------------------------------------------------- |
|
|
206
209
|
| sonar | SonarQube generic coverage | SonarQube, SonarCloud | `sf acc-transformer transform -j "coverage.json" -r "coverage.xml" -f "sonar"` |
|
|
207
210
|
| cobertura | Cobertura XML | Codecov, Azure, Jenkins, GitLab, GitHub | `sf acc-transformer transform -j "coverage.json" -r "coverage.xml" -f "cobertura"` |
|
|
208
211
|
| jacoco | JaCoCo XML | Codecov, Jenkins, Maven, Gradle | `sf acc-transformer transform -j "coverage.json" -r "coverage.xml" -f "jacoco"` |
|
|
@@ -212,7 +215,7 @@ Use `-f` / `--format` to choose the output format. Multiple `-f` values produce
|
|
|
212
215
|
| json-summary | JSON summary | Badges, PR comments | `sf acc-transformer transform -j "coverage.json" -r "coverage.json" -f "json-summary"` |
|
|
213
216
|
| simplecov | SimpleCov JSON | Codecov, Ruby tools | `sf acc-transformer transform -j "coverage.json" -r "coverage.json" -f "simplecov"` |
|
|
214
217
|
| opencover | OpenCover XML | Azure DevOps, VS, Codecov | `sf acc-transformer transform -j "coverage.json" -r "coverage.xml" -f "opencover"` |
|
|
215
|
-
| html | HTML report
|
|
218
|
+
| html | Full-source HTML report | Browsers, CI artifacts | `sf acc-transformer transform -j "coverage.json" -r "coverage.html" -f "html"` |
|
|
216
219
|
| markdown | Markdown summary | PR/MR comments, CI job summaries | `sf acc-transformer transform -j "coverage.json" -r "coverage.md" -f "markdown"` |
|
|
217
220
|
| github-actions | GitHub Actions annotations | GitHub Actions PR diff annotations | `sf acc-transformer transform -j "coverage.json" -r "coverage.txt" -f "github-actions"` |
|
|
218
221
|
|
|
@@ -235,7 +238,7 @@ jobs:
|
|
|
235
238
|
- name: Set up Node.js
|
|
236
239
|
uses: actions/setup-node@v4
|
|
237
240
|
with:
|
|
238
|
-
node-version:
|
|
241
|
+
node-version: "20"
|
|
239
242
|
|
|
240
243
|
- name: Install Salesforce CLI
|
|
241
244
|
run: npm install -g @salesforce/cli@latest
|
|
@@ -304,7 +307,7 @@ For GitHub Actions specifically, the transform step can run as a native Action i
|
|
|
304
307
|
|
|
305
308
|
```yaml
|
|
306
309
|
- name: Transform Coverage
|
|
307
|
-
uses: mcarvin8/apex-code-coverage-transformer@
|
|
310
|
+
uses: mcarvin8/apex-code-coverage-transformer@v4
|
|
308
311
|
with:
|
|
309
312
|
coverage-json: coverage/test-result-codecoverage.json
|
|
310
313
|
output-report: coverage.xml
|
|
@@ -316,7 +319,7 @@ Repeatable inputs (`coverage-json`, `format`, `ignore-package-directory`, `exclu
|
|
|
316
319
|
```yaml
|
|
317
320
|
- name: Transform Coverage
|
|
318
321
|
id: transform
|
|
319
|
-
uses: mcarvin8/apex-code-coverage-transformer@
|
|
322
|
+
uses: mcarvin8/apex-code-coverage-transformer@v4
|
|
320
323
|
with:
|
|
321
324
|
coverage-json: coverage/test-result-codecoverage.json
|
|
322
325
|
format: |
|
|
@@ -407,7 +410,7 @@ jobs:
|
|
|
407
410
|
fetch-depth: 0
|
|
408
411
|
- uses: actions/setup-node@v4
|
|
409
412
|
with:
|
|
410
|
-
node-version:
|
|
413
|
+
node-version: "20"
|
|
411
414
|
- run: npm install -g @salesforce/cli@latest
|
|
412
415
|
- run: echo y | sf plugins install apex-code-coverage-transformer
|
|
413
416
|
- name: Download Suite A coverage
|
|
@@ -491,7 +494,7 @@ pool:
|
|
|
491
494
|
steps:
|
|
492
495
|
- task: NodeTool@0
|
|
493
496
|
inputs:
|
|
494
|
-
versionSpec:
|
|
497
|
+
versionSpec: "20.x"
|
|
495
498
|
displayName: Set up Node.js
|
|
496
499
|
|
|
497
500
|
- script: npm install -g @salesforce/cli@latest
|
|
@@ -533,7 +536,7 @@ Create `.apexcodecovtransformer.config.json` in the project root to transform co
|
|
|
533
536
|
Sample configs: [Salesforce CLI](https://raw.githubusercontent.com/mcarvin8/apex-code-coverage-transformer/main/defaults/salesforce-cli/.apexcodecovtransformer.config.json), [SFDX Hardis](https://raw.githubusercontent.com/mcarvin8/apex-code-coverage-transformer/main/defaults/sfdx-hardis/.apexcodecovtransformer.config.json).
|
|
534
537
|
|
|
535
538
|
| Key | Required | Description |
|
|
536
|
-
|
|
539
|
+
| -------------------------- | ---------- | -------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
537
540
|
| `deployCoverageJsonPath` | For deploy | Path to deploy coverage JSON. |
|
|
538
541
|
| `testCoverageJsonPath` | For test | Path to test coverage JSON. |
|
|
539
542
|
| `outputReportPath` | No | Output path (default: `coverage.[xml/info/json]` by format). |
|
|
@@ -589,17 +592,7 @@ Error (1): sfdx-project.json not found in any parent directory.
|
|
|
589
592
|
Error (1): ENOENT: no such file or directory: {packageDir}
|
|
590
593
|
```
|
|
591
594
|
|
|
592
|
-
**Deploy coverage line numbers** — Salesforce deploy command coverage reports contain
|
|
593
|
-
|
|
594
|
-
Salesforce API v68.0 is expected to resolve the out-of-range line numbers in deploy coverage. The re-numbering logic is kept intact for compatibility with API v67.0 and earlier. It only acts on covered lines beyond the end of a file, so when deploy coverage contains no out-of-range lines, it makes no changes.
|
|
595
|
-
|
|
596
|
-
To see each remapping, set `SF_LOG_LEVEL=debug` before running the command - each remapped line prints directly to the terminal:
|
|
597
|
-
|
|
598
|
-
```bash
|
|
599
|
-
$ SF_LOG_LEVEL=debug sf acc-transformer transform -j "coverage/coverage/coverage.json" -r "coverage.xml" -f "sonar"
|
|
600
|
-
[DEBUG] setCoveredLines: Remapping out-of-range covered line 512 to line 47 in force-app/main/default/classes/AccountHandler.cls (file has 98 lines)
|
|
601
|
-
The coverage report has been written to: coverage.xml
|
|
602
|
-
```
|
|
595
|
+
**Deploy coverage line numbers** — Older Salesforce deploy command coverage reports could contain covered lines numbered past the end of a file ([forcedotcom/salesforcedx-vscode#5511](https://github.com/forcedotcom/salesforcedx-vscode/issues/5511), [forcedotcom/cli#1568](https://github.com/forcedotcom/cli/issues/1568)). Salesforce fixed this server-side in Winter '27 (API v68.0), and the fix applies regardless of the `--api-version` requested on the deploy. Versions 3.x and earlier of this plugin re-numbered those lines; starting with v4, deploy coverage lines are passed through as reported by Salesforce. If you still see out-of-range lines in deploy coverage, please [open an issue](https://github.com/mcarvin8/apex-code-coverage-transformer/issues).
|
|
603
596
|
|
|
604
597
|
## Questions or Issues?
|
|
605
598
|
|
package/lib/handlers/html.js
CHANGED
|
@@ -1,6 +1,37 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
import { BaseHandler } from './BaseHandler.js';
|
|
3
3
|
import { HandlerRegistry } from './HandlerRegistry.js';
|
|
4
|
+
function toExecutableLine(lineNumber, hitCount, content) {
|
|
5
|
+
return { lineNumber, hitCount, covered: hitCount > 0, content, executable: true };
|
|
6
|
+
}
|
|
7
|
+
/** Rows for coverage-data lines only. Used when the source file could not be read. */
|
|
8
|
+
function buildCoverageOnlyLines(lines) {
|
|
9
|
+
return Object.entries(lines)
|
|
10
|
+
.map(([lineNumber, hitCount]) => toExecutableLine(Number(lineNumber), hitCount, ''))
|
|
11
|
+
.sort((a, b) => a.lineNumber - b.lineNumber);
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Rows for every line of the source file, with coverage overlaid on executable lines.
|
|
15
|
+
* Coverage lines numbered past the end of the file are still listed (with empty content)
|
|
16
|
+
* so no reported coverage is dropped from the view.
|
|
17
|
+
*/
|
|
18
|
+
function buildFullSourceLines(lines, sourceContent) {
|
|
19
|
+
const sourceLines = sourceContent.split(/\r\n|\r|\n/);
|
|
20
|
+
if (sourceLines.at(-1) === '') {
|
|
21
|
+
sourceLines.pop();
|
|
22
|
+
}
|
|
23
|
+
const lastCoverageLine = Object.keys(lines).reduce((max, key) => Math.max(max, Number(key) || 0), 0);
|
|
24
|
+
const lineCount = Math.max(sourceLines.length, lastCoverageLine);
|
|
25
|
+
const rows = [];
|
|
26
|
+
for (let lineNumber = 1; lineNumber <= lineCount; lineNumber++) {
|
|
27
|
+
const content = sourceLines[lineNumber - 1] ?? '';
|
|
28
|
+
const hitCount = lines[String(lineNumber)];
|
|
29
|
+
rows.push(hitCount === undefined
|
|
30
|
+
? { lineNumber, hitCount: 0, covered: false, content, executable: false }
|
|
31
|
+
: toExecutableLine(lineNumber, hitCount, content));
|
|
32
|
+
}
|
|
33
|
+
return rows;
|
|
34
|
+
}
|
|
4
35
|
/**
|
|
5
36
|
* Handler for generating HTML coverage reports.
|
|
6
37
|
*
|
|
@@ -39,19 +70,7 @@ export class HtmlCoverageHandler extends BaseHandler {
|
|
|
39
70
|
}
|
|
40
71
|
processFile(filePath, fileName, lines, sourceContent) {
|
|
41
72
|
const { totalLines, coveredLines, uncoveredLines, lineRate } = this.calculateCoverage(lines);
|
|
42
|
-
const
|
|
43
|
-
const fileLines = Object.entries(lines)
|
|
44
|
-
.map(([lineNumber, hitCount]) => {
|
|
45
|
-
const num = Number(lineNumber);
|
|
46
|
-
const content = sourceLines[num - 1] ?? '';
|
|
47
|
-
return {
|
|
48
|
-
lineNumber: num,
|
|
49
|
-
hitCount,
|
|
50
|
-
covered: hitCount > 0,
|
|
51
|
-
content,
|
|
52
|
-
};
|
|
53
|
-
})
|
|
54
|
-
.sort((a, b) => a.lineNumber - b.lineNumber);
|
|
73
|
+
const fileLines = sourceContent === undefined ? buildCoverageOnlyLines(lines) : buildFullSourceLines(lines, sourceContent);
|
|
55
74
|
const fileCoverage = {
|
|
56
75
|
filePath,
|
|
57
76
|
fileName,
|
package/lib/handlers/html.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"html.js","sourceRoot":"","sources":["../../src/handlers/html.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAGb,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAKvD
|
|
1
|
+
{"version":3,"file":"html.js","sourceRoot":"","sources":["../../src/handlers/html.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAGb,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAKvD,SAAS,gBAAgB,CAAC,UAAkB,EAAE,QAAgB,EAA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,CAAC,CAAC;QAE1D,OAAO,IAAI,CAAC,WAAW,CAAC;IAC1B,CAAC;CACF;AAED,6BAA6B;AAC7B,eAAe,CAAC,QAAQ,CAAC;IACvB,IAAI,EAAE,MAAM;IACZ,WAAW,EAAE,iDAAiD;IAC9D,aAAa,EAAE,OAAO;IACtB,OAAO,EAAE,GAAG,EAAE,CAAC,IAAI,mBAAmB,EAAE;IACxC,cAAc,EAAE,CAAC,cAAc,EAAE,iBAAiB,EAAE,mBAAmB,CAAC;CACzE,CAAC,CAAC"}
|
|
@@ -6,7 +6,6 @@ import { getCoverageHandler } from '../handlers/getHandler.js';
|
|
|
6
6
|
import { findFilePath } from '../utils/findFilePath.js';
|
|
7
7
|
import { matchesGlob } from '../utils/globMatcher.js';
|
|
8
8
|
import { mapLimit } from '../utils/mapLimit.js';
|
|
9
|
-
import { setCoveredLines } from '../utils/setCoveredLines.js';
|
|
10
9
|
export function createHandlers(formats) {
|
|
11
10
|
const handlers = new Map();
|
|
12
11
|
for (const format of formats) {
|
|
@@ -14,9 +13,6 @@ export function createHandlers(formats) {
|
|
|
14
13
|
}
|
|
15
14
|
return handlers;
|
|
16
15
|
}
|
|
17
|
-
function hasSourceContent(result) {
|
|
18
|
-
return typeof result === 'object' && result !== null && 'sourceContent' in result;
|
|
19
|
-
}
|
|
20
16
|
async function readSourceFile(absolutePath) {
|
|
21
17
|
try {
|
|
22
18
|
return await readFile(absolutePath, 'utf-8');
|
|
@@ -25,6 +21,16 @@ async function readSourceFile(absolutePath) {
|
|
|
25
21
|
return undefined;
|
|
26
22
|
}
|
|
27
23
|
}
|
|
24
|
+
async function loadSourceContent(path, context) {
|
|
25
|
+
if (!context.handlers.has('html')) {
|
|
26
|
+
return undefined;
|
|
27
|
+
}
|
|
28
|
+
const content = await readSourceFile(join(context.repoRoot, path));
|
|
29
|
+
if (content === undefined) {
|
|
30
|
+
context.warnings.push(`Could not read source file ${path}; the HTML report will show coverage for this file without line contents.`);
|
|
31
|
+
}
|
|
32
|
+
return content;
|
|
33
|
+
}
|
|
28
34
|
export function countLines(lines) {
|
|
29
35
|
const totalLines = Object.keys(lines).length;
|
|
30
36
|
const coveredLines = Object.values(lines).filter((v) => v === 1).length;
|
|
@@ -56,18 +62,15 @@ async function processEntries(items, context, getName, resolveLines) {
|
|
|
56
62
|
return { processed, totalLines, coveredLines };
|
|
57
63
|
}
|
|
58
64
|
export function processDeployCoverage(data, context) {
|
|
59
|
-
return processEntries(Object.keys(data), context, (fileName) => fileName, async (fileName, path) => {
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
fileInfo.s = updatedLines;
|
|
64
|
-
return { lines: updatedLines, sourceContent: hasSourceContent(result) ? result.sourceContent : undefined };
|
|
65
|
-
});
|
|
65
|
+
return processEntries(Object.keys(data), context, (fileName) => fileName, async (fileName, path) => ({
|
|
66
|
+
lines: data[fileName].s,
|
|
67
|
+
sourceContent: await loadSourceContent(path, context),
|
|
68
|
+
}));
|
|
66
69
|
}
|
|
67
70
|
export function processTestCoverage(data, context) {
|
|
68
71
|
return processEntries(data, context, (entry) => entry.name, async (entry, path) => ({
|
|
69
72
|
lines: entry.lines,
|
|
70
|
-
sourceContent:
|
|
73
|
+
sourceContent: await loadSourceContent(path, context),
|
|
71
74
|
}));
|
|
72
75
|
}
|
|
73
76
|
//# sourceMappingURL=coverageProcessor.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"coverageProcessor.js","sourceRoot":"","sources":["../../src/transformers/coverageProcessor.ts"],"names":[],"mappings":"AAAA,qCAAqC;AACrC,YAAY,CAAC;AAEb,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAC/D,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AACxD,OAAO,EAAE,WAAW,EAAE,MAAM,yBA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AI,EAAE,OAAO,CAAC;KACtD,CAAC,CACH,CAAC;AACJ,CAAC"}
|
|
@@ -48,9 +48,16 @@ function groupFilesByDir(files) {
|
|
|
48
48
|
return filesByDir;
|
|
49
49
|
}
|
|
50
50
|
function buildLineRow(line) {
|
|
51
|
+
const codeContent = line.content !== undefined ? escapeHtml(line.content) : '';
|
|
52
|
+
if (line.executable === false) {
|
|
53
|
+
return `<tr class="neutral">
|
|
54
|
+
<td class="line-number">${line.lineNumber}</td>
|
|
55
|
+
<td class="hit-count"></td>
|
|
56
|
+
<td class="line-content">${codeContent}</td>
|
|
57
|
+
</tr>`;
|
|
58
|
+
}
|
|
51
59
|
const lineClass = line.covered ? 'covered' : 'uncovered';
|
|
52
60
|
const lineColor = line.covered ? '#c8e6c9' : '#ffcdd2';
|
|
53
|
-
const codeContent = line.content !== undefined ? escapeHtml(line.content) : '';
|
|
54
61
|
return `<tr class="${lineClass}" style="background-color: ${lineColor}">
|
|
55
62
|
<td class="line-number">${line.lineNumber}</td>
|
|
56
63
|
<td class="hit-count">${line.hitCount}</td>
|
|
@@ -267,6 +274,9 @@ export function generateHtml(coverageObj) {
|
|
|
267
274
|
.uncovered {
|
|
268
275
|
background-color: #ffcdd2 !important;
|
|
269
276
|
}
|
|
277
|
+
.neutral .line-content {
|
|
278
|
+
color: #666;
|
|
279
|
+
}
|
|
270
280
|
.package-summary {
|
|
271
281
|
margin-bottom: 30px;
|
|
272
282
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generateHtml.js","sourceRoot":"","sources":["../../../src/transformers/generators/generateHtml.ts"],"names":[],"mappings":"AAEA,SAAS,gBAAgB,CAAC,QAAgB;IACxC,IAAI,QAAQ,IAAI,GAAG;QAAE,OAAO,SAAS,CAAC;IACtC,IAAI,QAAQ,IAAI,GAAG;QAAE,OAAO,SAAS,CAAC;IACtC,OAAO,SAAS,CAAC;AACnB,CAAC;AAED,SAAS,aAAa,CAAC,QAAgB;IACrC,OAAO,CAA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lFileCoverage = {
|
|
|
334
334
|
coveredLines: number;
|
|
335
335
|
uncoveredLines: number;
|
|
336
336
|
lineRate: number;
|
|
337
|
-
lines:
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
337
|
+
lines: HtmlLineCoverage[];
|
|
338
|
+
};
|
|
339
|
+
/**
|
|
340
|
+
* One row in the HTML line view. When source content is available, every
|
|
341
|
+
* line of the file is listed; lines absent from the coverage data are marked
|
|
342
|
+
* `executable: false` (comments, signatures, braces, blank lines).
|
|
343
|
+
*/
|
|
344
|
+
export type HtmlLineCoverage = {
|
|
345
|
+
lineNumber: number;
|
|
346
|
+
hitCount: number;
|
|
347
|
+
covered: boolean;
|
|
348
|
+
content?: string;
|
|
349
|
+
/** False for non-executable lines. Omitted or true for lines in the coverage data. */
|
|
350
|
+
executable?: boolean;
|
|
343
351
|
};
|
|
344
352
|
/** Summary for a package directory (e.g. force-app) in the HTML report */
|
|
345
353
|
export type HtmlPackageSummary = {
|
package/oclif.manifest.json
CHANGED
package/package.json
CHANGED
|
@@ -1,34 +1,34 @@
|
|
|
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": "
|
|
4
|
+
"version": "4.1.0",
|
|
5
5
|
"dependencies": {
|
|
6
|
-
"@oclif/core": "5.1.
|
|
7
|
-
"@salesforce/core": "9.
|
|
8
|
-
"@salesforce/sf-plugins-core": "13.0.
|
|
6
|
+
"@oclif/core": "5.1.10",
|
|
7
|
+
"@salesforce/core": "9.4.4",
|
|
8
|
+
"@salesforce/sf-plugins-core": "13.0.8"
|
|
9
9
|
},
|
|
10
10
|
"devDependencies": {
|
|
11
11
|
"@actions/core": "3.0.1",
|
|
12
|
-
"@biomejs/biome": "2.5
|
|
13
|
-
"@commitlint/cli": "21.2.
|
|
14
|
-
"@commitlint/config-conventional": "21.2.
|
|
15
|
-
"@salesforce/cli-plugins-testkit": "5.3.
|
|
12
|
+
"@biomejs/biome": "2.6.5",
|
|
13
|
+
"@commitlint/cli": "21.2.4",
|
|
14
|
+
"@commitlint/config-conventional": "21.2.4",
|
|
15
|
+
"@salesforce/cli-plugins-testkit": "5.3.83",
|
|
16
16
|
"@salesforce/dev-config": "4.3.3",
|
|
17
|
-
"@stryker-mutator/core": "10.
|
|
18
|
-
"@stryker-mutator/vitest-runner": "10.
|
|
19
|
-
"@types/node": "26.6.
|
|
20
|
-
"@vitest/coverage-v8": "5.0.
|
|
17
|
+
"@stryker-mutator/core": "10.1.1",
|
|
18
|
+
"@stryker-mutator/vitest-runner": "10.1.1",
|
|
19
|
+
"@types/node": "26.6.6",
|
|
20
|
+
"@vitest/coverage-v8": "5.0.5",
|
|
21
21
|
"esbuild": "0.28.2",
|
|
22
22
|
"husky": "9.1.7",
|
|
23
|
-
"knip": "6.
|
|
23
|
+
"knip": "6.44.1",
|
|
24
24
|
"lint-staged": "17.6.0",
|
|
25
25
|
"ls-engines": "0.10.1",
|
|
26
|
-
"oclif": "6.0.
|
|
26
|
+
"oclif": "6.0.15",
|
|
27
27
|
"shx": "0.4.0",
|
|
28
28
|
"tsx": "4.23.15",
|
|
29
29
|
"typescript": "7.0.2",
|
|
30
|
-
"vitest": "5.0.
|
|
31
|
-
"wireit": "0.
|
|
30
|
+
"vitest": "5.0.5",
|
|
31
|
+
"wireit": "0.15.0"
|
|
32
32
|
},
|
|
33
33
|
"engines": {
|
|
34
34
|
"node": ">=22.19.0"
|
|
@@ -92,6 +92,7 @@
|
|
|
92
92
|
"clean:build": "wireit",
|
|
93
93
|
"clean:package-manager": "wireit",
|
|
94
94
|
"compile": "wireit",
|
|
95
|
+
"dependencies:upgrade": "npx npm-check-updates -u && npm install && npm audit fix",
|
|
95
96
|
"format": "wireit",
|
|
96
97
|
"lint": "wireit",
|
|
97
98
|
"lint:dependencies": "wireit",
|
|
@@ -175,22 +176,24 @@
|
|
|
175
176
|
"clean": "if-file-deleted"
|
|
176
177
|
},
|
|
177
178
|
"format": {
|
|
178
|
-
"command": "biome format --write src test",
|
|
179
|
+
"command": "biome format --write src test README.md CONTRIBUTING.md",
|
|
179
180
|
"files": [
|
|
180
181
|
"src/**/*.ts",
|
|
181
182
|
"test/**/*.ts",
|
|
182
|
-
"biome.json"
|
|
183
|
+
"biome.json",
|
|
184
|
+
"*.md"
|
|
183
185
|
],
|
|
184
186
|
"output": []
|
|
185
187
|
},
|
|
186
188
|
"lint": {
|
|
187
|
-
"command": "biome check src test",
|
|
189
|
+
"command": "biome check src test README.md CONTRIBUTING.md",
|
|
188
190
|
"files": [
|
|
189
191
|
"src/**/*.ts",
|
|
190
192
|
"test/**/*.ts",
|
|
191
193
|
"messages/**",
|
|
192
194
|
"biome.json",
|
|
193
|
-
"**/tsconfig.json"
|
|
195
|
+
"**/tsconfig.json",
|
|
196
|
+
"*.md"
|
|
194
197
|
],
|
|
195
198
|
"output": []
|
|
196
199
|
},
|
|
@@ -332,6 +335,6 @@
|
|
|
332
335
|
"url": "https://github.com/mcarvin8/apex-code-coverage-transformer/issues"
|
|
333
336
|
},
|
|
334
337
|
"allowScripts": {
|
|
335
|
-
"esbuild@0.28.
|
|
338
|
+
"esbuild@0.28.2": true
|
|
336
339
|
}
|
|
337
340
|
}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
import { readFile } from 'node:fs/promises';
|
|
3
|
-
export async function getTotalLines(filePath, returnContent = false) {
|
|
4
|
-
const content = await readFile(filePath, 'utf8');
|
|
5
|
-
const totalLines = content.split(/\r\n|\r|\n/).length;
|
|
6
|
-
return returnContent ? { totalLines, content } : totalLines;
|
|
7
|
-
}
|
|
8
|
-
//# sourceMappingURL=getTotalLines.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"getTotalLines.js","sourceRoot":"","sources":["../../src/utils/getTotalLines.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAEb,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAI5C,MAAM,CAAC,KAAK,UAAU,aAAa,CAAC,QAAgB,EAAE,aAAa,GAAG,KAAK;IACzE,MAAM,OAAO,GAAG,MAAM,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;IACjD,MAAM,UAAU,GAAG,OAAO,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC,MAAM,CAAC;IACtD,OAAO,aAAa,CAAC,CAAC,CAAC,EAAE,UAAU,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC,UAAU,CAAC;AAC9D,CAAC"}
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
export type SetCoveredLinesResult = Record<string, number> | {
|
|
2
|
-
updatedLines: Record<string, number>;
|
|
3
|
-
sourceContent: string;
|
|
4
|
-
};
|
|
5
|
-
export declare function setCoveredLines(filePath: string, repoRoot: string, lines: Record<string, number>, returnSourceContent?: boolean): Promise<SetCoveredLinesResult>;
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
import { join } from 'node:path';
|
|
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
|
-
}
|
|
10
|
-
export async function setCoveredLines(filePath, repoRoot, lines, returnSourceContent = false) {
|
|
11
|
-
const result = await getTotalLines(join(repoRoot, filePath), returnSourceContent);
|
|
12
|
-
const totalLines = typeof result === 'number' ? result : result.totalLines;
|
|
13
|
-
const updatedLines = {};
|
|
14
|
-
const usedLines = new Set();
|
|
15
|
-
const sortedLines = Object.entries(lines).sort(([lineA], [lineB]) => parseInt(lineA, 10) - parseInt(lineB, 10));
|
|
16
|
-
for (const [line, status] of sortedLines) {
|
|
17
|
-
const lineNumber = parseInt(line, 10);
|
|
18
|
-
if (status === 1 && lineNumber > totalLines) {
|
|
19
|
-
for (let randomLine = 1; randomLine <= totalLines; randomLine++) {
|
|
20
|
-
if (!usedLines.has(randomLine)) {
|
|
21
|
-
debugLog(`Remapping out-of-range covered line ${lineNumber} to line ${randomLine} in ${filePath} (file has ${totalLines} lines)`);
|
|
22
|
-
updatedLines[randomLine.toString()] = status;
|
|
23
|
-
usedLines.add(randomLine);
|
|
24
|
-
break;
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
else {
|
|
29
|
-
updatedLines[line] = status;
|
|
30
|
-
usedLines.add(lineNumber);
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
if (returnSourceContent && typeof result !== 'number') {
|
|
34
|
-
return { updatedLines, sourceContent: result.content };
|
|
35
|
-
}
|
|
36
|
-
return updatedLines;
|
|
37
|
-
}
|
|
38
|
-
//# sourceMappingURL=setCoveredLines.js.map
|
|
@@ -1 +0,0 @@
|
|
|
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,C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