From 92948470f4e94db96d723e52c222b39ef1ecea77 Mon Sep 17 00:00:00 2001 From: Clint Chester Date: Thu, 3 Jun 2021 15:30:48 +0000 Subject: [PATCH] Exposing the help field in the SARIF report --- docs/report-examples/pmd-report.sarif.json | 6 ++++++ .../pmd/renderers/internal/sarif/SarifLogBuilder.java | 1 + .../pmd/renderers/sarif/expected-multiple.sarif.json | 6 ++++++ .../net/sourceforge/pmd/renderers/sarif/expected.sarif.json | 3 +++ 4 files changed, 16 insertions(+) diff --git a/docs/report-examples/pmd-report.sarif.json b/docs/report-examples/pmd-report.sarif.json index cacf31ad39..e785af258d 100644 --- a/docs/report-examples/pmd-report.sarif.json +++ b/docs/report-examples/pmd-report.sarif.json @@ -18,6 +18,9 @@ "text": "Detect classes declared without explicit sharing mode if DML methods are used. This forces the developer to take access restrictions into account before modifying objects." }, "helpUri": "https://pmd.github.io/pmd/pmd_rules_apex_security.html#apexsharingviolations", + "help": { + "text": "Detect classes declared without explicit sharing mode if DML methods are used. This forces the developer to take access restrictions into account before modifying objects." + }, "properties": { "ruleset": "Security", "priority": 3, @@ -35,6 +38,9 @@ "text": "This rule validates that: ApexDoc comments are present for classes, methods, and properties that are public or global, excluding overrides and test classes (as well as the contents of test classes)." }, "helpUri": "https://pmd.github.io/pmd/pmd_rules_apex_documentation.html#apexdoc", + "help": { + "text": "This rule validates that: ApexDoc comments are present for classes, methods, and properties that are public or global, excluding overrides and test classes (as well as the contents of test classes)." + }, "properties": { "ruleset": "Documentation", "priority": 3, diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/renderers/internal/sarif/SarifLogBuilder.java b/pmd-core/src/main/java/net/sourceforge/pmd/renderers/internal/sarif/SarifLogBuilder.java index 3193078aef..a2b0826a4b 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/renderers/internal/sarif/SarifLogBuilder.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/renderers/internal/sarif/SarifLogBuilder.java @@ -180,6 +180,7 @@ public class SarifLogBuilder { .shortDescription(new MultiformatMessage(rv.getDescription())) .fullDescription(new MultiformatMessage(rv.getRule().getDescription())) .helpUri(rv.getRule().getExternalInfoUrl()) + .help(new MultiformatMessage(rv.getRule().getDescription())) .properties(getRuleProperties(rv)) .build(); } diff --git a/pmd-core/src/test/resources/net/sourceforge/pmd/renderers/sarif/expected-multiple.sarif.json b/pmd-core/src/test/resources/net/sourceforge/pmd/renderers/sarif/expected-multiple.sarif.json index a35483cf65..e89a3927df 100644 --- a/pmd-core/src/test/resources/net/sourceforge/pmd/renderers/sarif/expected-multiple.sarif.json +++ b/pmd-core/src/test/resources/net/sourceforge/pmd/renderers/sarif/expected-multiple.sarif.json @@ -17,6 +17,9 @@ "fullDescription": { "text": "desc" }, + "help": { + "text": "desc" + }, "properties": { "ruleset": "RuleSet", "priority": 1, @@ -33,6 +36,9 @@ "fullDescription": { "text": "desc" }, + "help": { + "text": "desc" + }, "properties": { "ruleset": "RuleSet", "priority": 5, diff --git a/pmd-core/src/test/resources/net/sourceforge/pmd/renderers/sarif/expected.sarif.json b/pmd-core/src/test/resources/net/sourceforge/pmd/renderers/sarif/expected.sarif.json index ff77f1dc34..a99c6eca1f 100644 --- a/pmd-core/src/test/resources/net/sourceforge/pmd/renderers/sarif/expected.sarif.json +++ b/pmd-core/src/test/resources/net/sourceforge/pmd/renderers/sarif/expected.sarif.json @@ -17,6 +17,9 @@ "fullDescription": { "text": "desc" }, + "help": { + "text": "desc" + }, "properties": { "ruleset": "RuleSet", "priority": 5,