apex-code-coverage-transformer 2.2.0 → 2.2.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 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.2.1](https://github.com/mcarvin8/apex-code-coverage-transformer/compare/v2.2.0...v2.2.1) (2024-12-14)
9
+
10
+
11
+ ### Bug Fixes
12
+
13
+ * upgrade all dependencies ([7addc5d](https://github.com/mcarvin8/apex-code-coverage-transformer/commit/7addc5dc6ec72f75a26bc1306ae42eee74daea25))
14
+
8
15
  ## [2.2.0](https://github.com/mcarvin8/apex-code-coverage-transformer/compare/v2.1.0...v2.2.0) (2024-10-28)
9
16
 
10
17
 
package/README.md CHANGED
@@ -7,6 +7,8 @@
7
7
  <summary>Table of Contents</summary>
8
8
 
9
9
  - [Install](#install)
10
+ - [Who is the Plugin For?](#who-is-the-plugin-for)
11
+ - [Creating Code Coverage Files with the Salesforce CLI](#creating-code-coverage-files-with-the-salesforce-cli)
10
12
  - [Command](#command)
11
13
  - [`sf acc-transformer transform`](#sf-acc-transformer-transform)
12
14
  - [Hook](#hook)
@@ -16,13 +18,23 @@
16
18
  - [License](#license)
17
19
  </details>
18
20
 
19
- The `apex-code-coverage-transformer` is a Salesforce CLI plugin to transform the Apex Code Coverage JSON files created during deployments and test runs into the Generic Test Coverage Format (XML). This format is accepted by static code analysis tools like SonarQube.
21
+ A Salesforce CLI plugin to transform the Apex code coverage JSON files created during deployments and test runs into the generic test coverage format (XML) accepted by SonarQube.
20
22
 
21
- This plugin supports code coverage metrics created for Apex Classes and Apex Triggers. This also supports multiple package directories as listed in your project's `sfdx-project.json` configuration, assuming unique file-names are used in your package directories.
23
+ ## Install
24
+
25
+ ```bash
26
+ sf plugins install apex-code-coverage-transformer@x.y.z
27
+ ```
28
+
29
+ ## Who is the Plugin For?
30
+
31
+ This plugin is intended for users who deploy their Apex codebase (Apex classes and triggers) from any Salesforce DX repository (`sfdx-project.json` file), not just git-based ones. You should be running this plugin somewhere inside your Salesforce DX repository (root folder preferred). This plugin searches for your repository's `sfdx-project.json` file to know which package directories to search into. Since SonarQube relies on file-paths to map code coverage to the files in their explorer interface, the Apex files must be found in one of your package directories.
32
+
33
+ This plugin will work if you run local tests or run all tests in an org, including tests that originate from installed managed and unlocked packages. Since files from managed and unlocked packages aren't retrieved into Salesforce DX repositories, these files cannot be included in your SonarQube scans.
22
34
 
23
- This plugin is intended for users who deploy their Apex codebase from a Salesforce DX repository and use SonarQube for code quality. This plugin is intended to work for any Salesforce DX repository with a `sfdx-project.json` file, not just git-based repositories. This plugin will work if you run local tests or run all tests in an org, including tests that originate from installed managed and unlocked packages.
35
+ When the plugin is unable to find the Apex file from the coverage report in your repository, it will print a warning and not add that file's coverage data to the coverage XML created by this plugin. A warning will be printed for each file not found in a package directory in your repository. See [Errors and Warnings](https://github.com/mcarvin8/apex-code-coverage-transformer?tab=readme-ov-file#errors-and-warnings) for more information.
24
36
 
25
- SonarQube relies on file-paths to map code coverage to the files in their file explorer interface. Since files from managed and unlocked packages aren't retrieved into Salesforce DX repositories, these files cannot be included in your SonarQube scans. If your Apex code coverage JSON output includes managed/unlocked package files, they will not be added to the coverage XML created by this plugin. A warning will be printed for each file not found in a package directory in your repository. See [Errors and Warnings](https://github.com/mcarvin8/apex-code-coverage-transformer?tab=readme-ov-file#errors-and-warnings) for more information.
37
+ ## Creating Code Coverage Files with the Salesforce CLI
26
38
 
27
39
  To create the code coverage JSON during a Salesforce CLI deployment/validation, 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`.
28
40
 
@@ -41,20 +53,12 @@ The code coverage JSONs created by the Salesforce CLI aren't accepted by SonarQu
41
53
 
42
54
  **Disclaimer**: Due to existing bugs with how the Salesforce CLI reports covered lines during deployments (see [5511](https://github.com/forcedotcom/salesforcedx-vscode/issues/5511) and [1568](https://github.com/forcedotcom/cli/issues/1568)), to add support for covered lines in this plugin for deployment coverage files, I had to add a function to re-number out-of-range covered lines the CLI may report (ex: line 100 in a 98-line Apex Class is reported back as covered by the Salesforce CLI deploy command). Salesforce's coverage result may also include extra lines as covered (ex: 120 lines are included in the coverage report for a 100 line file), so the coverage percentage may vary based on how many lines the API returns in the coverage report. Once Salesforce fixes the API to correctly return covered lines in the deploy command, this function will be removed.
43
55
 
44
- ## Install
45
-
46
- ```bash
47
- sf plugins install apex-code-coverage-transformer@x.y.z
48
- ```
49
-
50
56
  ## Command
51
57
 
52
58
  The `apex-code-coverage-transformer` has 1 command:
53
59
 
54
60
  - `sf acc-transformer transform`
55
61
 
56
- This command needs to be ran somewhere inside your Salesforce DX repository, whether in the root folder (recommended) or in a subfolder. This plugin will determine the root folder of this repository and read the `sfdx-project.json` file in the root folder. All package directories listed in the `sfdx-project.json` file will be processed when running this plugin.
57
-
58
62
  ## `sf acc-transformer transform`
59
63
 
60
64
  ```
@@ -5,8 +5,8 @@ export default class TransformerTransform extends SfCommand<TransformerTransform
5
5
  static readonly description: string;
6
6
  static readonly examples: string[];
7
7
  static readonly flags: {
8
- 'coverage-json': import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
9
- xml: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
8
+ 'coverage-json': import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
9
+ xml: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
10
10
  };
11
11
  run(): Promise<TransformerTransformResult>;
12
12
  }