You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* Specifies the arguments passed to the `run` command.
19
-
* For a full list of acceptable arguments for the `run` command, see the [code-analyzer Command Reference](https://developer.salesforce.com/docs/atlas.en-us.sfdx_cli_reference.meta/sfdx_cli_reference/cli_reference_code-analyzer_commands_unified.htm).
20
-
* The stdout text from the `run` command is written to the [GitHub workflow run logs](https://docs.github.com/en/actions/monitoring-and-troubleshooting-workflows/monitoring-workflows/using-workflow-run-logs).
18
+
* Specifies the flags passed to the `code-analyzer run` command.
19
+
* For a full list of valid flags for the `code-analyzer run` command, see the [code-analyzer Command Reference](https://developer.salesforce.com/docs/atlas.en-us.sfdx_cli_reference.meta/sfdx_cli_reference/cli_reference_code-analyzer_commands_unified.htm).
20
+
* The stdout text from the `code-analyzer run` command is written to the [GitHub workflow run logs](https://docs.github.com/en/actions/monitoring-and-troubleshooting-workflows/monitoring-workflows/using-workflow-run-logs).
21
21
* Each output file specified by a `--output-file` (or `-f`) flag is included in the ZIP archive [GitHub workflow run artifact](https://docs.github.com/en/actions/managing-workflow-runs-and-deployments/managing-workflow-runs/downloading-workflow-artifacts) for you to download.
* Specifies the name of the ZIP archive [GitHub workflow run artifact](https://docs.github.com/en/actions/managing-workflow-runs-and-deployments/managing-workflow-runs/downloading-workflow-artifacts) where the results output files are uploaded.
24
+
* <b>`github-token`</b>
25
+
* When this action is run against a pull request, you can provide a GitHub token, which is used to create a review of the pull request. The review specifies how many violations were found (both in the project as a whole and in changed files) and links to the action summary page.
26
+
* This token must have write permissions for pull requests.
27
+
* You can use the default GitHub token stored as the `GITHUB_TOKEN` secret, as long as you also use the job-level `permissions` property to give that token write access for pull requests.
24
28
25
29
## v2 Outputs
26
30
*`exit-code`
@@ -37,11 +41,13 @@ The `forcedotcom/run-code-analyzer@v2` GitHub Action is based on [Salesforce Cod
37
41
* The number of Low (4) severity violations found.
38
42
*`num-sev5-violations`
39
43
* The number of Info (5) severity violations found.
44
+
*`review-id`
45
+
* If the action created a pull request review, this is its ID.
40
46
41
-
This `run-code-analyzer@v2` action won't exit your GitHub workflow when it finds violations. We recommend that you add a subsequent step to your workflow that uses the available outputs to determine how your workflow should proceed.
47
+
This `run-code-analyzer@v2` action doesn't exit your GitHub workflow when it finds violations. We recommend that you add a subsequent step to your workflow that uses the available outputs to determine how your workflow should proceed.
42
48
43
49
## Environment Prerequisites
44
-
The [Salesforce Code Analyzer v5.x](https://developer.salesforce.com/docs/platform/salesforce-code-analyzer/guide/code-analyzer.html) and its bundled engines can each have their own set of requirements in order to run successfully. So we recommend that you set up your GitHub runner(s) with this software:
50
+
The [Salesforce Code Analyzer v5.x](https://developer.salesforce.com/docs/platform/salesforce-code-analyzer/guide/code-analyzer.html) and its bundled engines can each have their own set of requirements in order to run successfully. We recommend that you set up your GitHub runner(s) with this software:
45
51
*`node` version 20.9.0 or greater
46
52
* Required by all engines.
47
53
*`java` version 11 or greater
@@ -52,15 +58,20 @@ The [Salesforce Code Analyzer v5.x](https://developer.salesforce.com/docs/platfo
52
58
## Example v2 Usage
53
59
54
60
name: Salesforce Code Analyzer Workflow
55
-
on: push
61
+
on:
62
+
pull_request:
56
63
jobs:
57
64
salesforce-code-analyzer-workflow:
65
+
permissions:
66
+
pull-requests: write # Grants permission to create a pull request review. Only necessary if running against pull requests.
67
+
contents: read # Grants permission to check out the repository. Only necessary for private repos.
68
+
actions: read # Grants permission to read the in-progress actions. Only necessary for private repos.
58
69
runs-on: ubuntu-latest
59
70
steps:
60
71
- name: Check out files
61
72
uses: actions/checkout@v4
62
73
63
-
# PREREQUISITES - Only needed if runner doesn't already satisfy these requirements
74
+
# PREREQUISITES - Only needed if the runner doesn't already satisfy these requirements.
64
75
- name: Ensure node v20.9.0 or greater
65
76
uses: actions/setup-node@v4
66
77
with:
@@ -87,8 +98,9 @@ The [Salesforce Code Analyzer v5.x](https://developer.salesforce.com/docs/platfo
"message": "Duplicate code detected for language 'apex'. Found 2 code locations containing the same block of code consisting of 123 tokens across 10 lines.",
<tr><td>:red_circle:</td><td><sup>force-app/main/default/aura/AccountRepeat/AccountRepeat.cmp-meta.xml:3:17</sup></td><td><sup>regex:AvoidOldSalesforceApiVersions</sup></td><td><sup>Found the use of a Salesforce API version that is 3 or more years old. Avoid using an API version that is <= 56.0.</sup></td></tr>
<tr><td>:white_circle:</td><td><sup>(main) force-app/main/default/classes/NameController.cls:1:1<br/>force-app/main/default/classes/SharingInnerClass.cls:15:1</sup></td><td><sup>cpd:<ahref="https://docs.pmd-code.org/latest/pmd_userdocs_cpd.html#refactoring-duplicates">DetectCopyPasteForApex</a></sup></td><td><sup>Duplicate code detected for language 'apex'. Found 2 code locations containing the same block of code consisting of 123 tokens across 10 lines.</sup></td></tr>
192
193
<tr><td>:white_circle:</td><td><sup>force-app/main/default/classes/NameController.cls:2:1</sup></td><td><sup>regex:NoTrailingWhitespace</sup></td><td><sup>Found trailing whitespace at the end of a line of code.</sup></td></tr>
193
194
<tr><td>:white_circle:</td><td><sup>force-app/main/default/classes/NameController.cls:8:1</sup></td><td><sup>regex:NoTrailingWhitespace</sup></td><td><sup>Found trailing whitespace at the end of a line of code.</sup></td></tr>
194
195
<tr><td>:white_circle:</td><td><sup>force-app/main/default/classes/SafeNoSharing.cls:11:1</sup></td><td><sup>regex:NoTrailingWhitespace</sup></td><td><sup>Found trailing whitespace at the end of a line of code.</sup></td></tr>
0 commit comments