Skip to content

Commit 0da8025

Browse files
committed
Merge pull request #45 from smetanink:main
Add an option to disable GitHub annotations (createGitHubAnnotations) #45 * pr-45: Add an option to disable GitHub annotations
2 parents dbd774c + 40819f1 commit 0da8025

File tree

4 files changed

+14
-4
lines changed

4 files changed

+14
-4
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ See also [Uploading a SARIF file to GitHub](https://docs.github.com/en/code-secu
7979
|`sourcePath`|no |"." |Root directory for sources. Uses by default the current directory|
8080
|`rulesets` |yes| |Comma separated list of ruleset names to use.|
8181
|`analyzeModifiedFilesOnly`|no|"true"|Instead of analyze all files under "sourcePath", only the files that have been touched in a pull request or push will be analyzed. This makes the analysis faster and helps especially bigger projects which gradually want to introduce PMD. This helps in enforcing that no new code violation is introduced.<br>Depending on the analyzed language, the results might be less accurate results. At the moment, this is not a problem, as PMD mostly analyzes each file individually, but that might change in the future.<br>If the change is very big, not all files might be analyzed. Currently the maximum number of modified files is 300.<br>Note: When using PMD as a code scanner in order to create "Code scanning alerts" on GitHub, all files should be analyzed in order to produce a complete picture of the project. Otherwise alerts might get closed soo soon.|
82+
|`createGitHubAnnotations`|no|"true"|By default, all detected violations are added as annotations to the pull request. You can disable this by setting FALSE. This can be useful if you are using another tool for this purpose.|
8283

8384
## Outputs
8485

action.yml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,14 @@ inputs:
4949
complete picture of the project. Otherwise alerts might get closed soo
5050
soon.
5151
required: false
52-
default: true
52+
default: 'true'
53+
createGitHubAnnotations:
54+
description: >-
55+
By default, all detected violations are added as annotations to the pull
56+
request. You can disable this by setting FALSE. This can be useful if you
57+
are using another tool for this purpose.
58+
required: false
59+
default: 'true'
5360
outputs:
5461
violations:
5562
description: Number of violations found

dist/index.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/index.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,10 @@ async function main() {
4141
core.setOutput('violations', violations);
4242
core.info(`PMD detected ${violations} violations.`);
4343

44-
const report = sarif.loadReport(reportFile);
45-
annotations.processSarifReport(report);
44+
if (core.getInput('createGitHubAnnotations', { required: true}) === 'true') {
45+
const report = sarif.loadReport(reportFile);
46+
annotations.processSarifReport(report);
47+
}
4648

4749
const artifactClient = artifact.create();
4850
await artifactClient.uploadArtifact('PMD Report', [reportFile], '.', {

0 commit comments

Comments
 (0)