1
0
forked from phoedos/pmd

Adds fullDescription and tags in SARIF report

This commit is contained in:
Clint Chester
2021-06-01 12:13:35 +00:00
committed by GitHub
parent 93237c293b
commit 1fa94f4860
5 changed files with 83 additions and 9 deletions
docs/report-examples
pmd-core/src
main/java/net/sourceforge/pmd/renderers/internal/sarif
test/resources/net/sourceforge/pmd/renderers/sarif

@ -14,10 +14,16 @@
"shortDescription": {
"text": "Apex classes should declare a sharing model if DML or SOQL/SOSL is used"
},
"fullDescription": {
"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",
"properties": {
"ruleset": "Security",
"priority": 3
"priority": 3,
"tags":[
"Security"
]
}
},
{
@ -25,10 +31,16 @@
"shortDescription": {
"text": "Missing ApexDoc comment"
},
"fullDescription": {
"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",
"properties": {
"ruleset": "Documentation",
"priority": 3
"priority": 3,
"tags": [
"Documentation"
]
}
}
]

@ -549,11 +549,16 @@ public class SarifLog {
* The pmd priority of the rule.
*/
private Integer priority;
/**
* A set of distinct strings that provide additional information. This is SARIF 2.1.0 Schema.
*/
private String[] tags;
@java.lang.SuppressWarnings("all")
PropertyBag(final String ruleset, final Integer priority) {
PropertyBag(final String ruleset, final Integer priority, final String[] tags) {
this.ruleset = ruleset;
this.priority = priority;
this.tags = tags;
}
@ -563,6 +568,8 @@ public class SarifLog {
private String ruleset;
@java.lang.SuppressWarnings("all")
private Integer priority;
@java.lang.SuppressWarnings("all")
private String[] tags;
@java.lang.SuppressWarnings("all")
PropertyBagBuilder() {
@ -588,15 +595,25 @@ public class SarifLog {
return this;
}
/**
* A set of distinct strings that provide additional information. This is SARIF 2.1.0 Schema.
* @return {@code this}.
*/
@java.lang.SuppressWarnings("all")
public SarifLog.PropertyBag.PropertyBagBuilder tags(final String[] tags) {
this.tags = tags;
return this;
}
@java.lang.SuppressWarnings("all")
public SarifLog.PropertyBag build() {
return new SarifLog.PropertyBag(this.ruleset, this.priority);
return new SarifLog.PropertyBag(this.ruleset, this.priority, this.tags);
}
@java.lang.Override
@java.lang.SuppressWarnings("all")
public java.lang.String toString() {
return "SarifLog.PropertyBag.PropertyBagBuilder(ruleset=" + this.ruleset + ", priority=" + this.priority + ")";
return "SarifLog.PropertyBag.PropertyBagBuilder(ruleset=" + this.ruleset + ", priority=" + this.priority + ", tags=" + this.tags + ")";
}
}
@ -621,6 +638,14 @@ public class SarifLog {
return this.priority;
}
/**
* A set of distinct strings that provide additional information. This is SARIF 2.1.0 Schema.
*/
@java.lang.SuppressWarnings("all")
public String[] getTags() {
return this.tags;
}
/**
* The name of the rule set.
* @return {@code this}.
@ -641,6 +666,16 @@ public class SarifLog {
return this;
}
/**
* The set of distinct strings that provide additional information. This is SARIF 2.1.0 Schema.
* @return {@code this}.
*/
@java.lang.SuppressWarnings("all")
public SarifLog.PropertyBag setTags(final String[] tags) {
this.tags = tags;
return this;
}
@java.lang.Override
@java.lang.SuppressWarnings("all")
public boolean equals(final java.lang.Object o) {
@ -664,6 +699,11 @@ public class SarifLog {
if (this$priority == null ? other$priority != null : !this$priority.equals(other$priority)) {
return false;
}
final java.lang.Object this$tags = this.getTags();
final java.lang.Object other$tags = other.getTags();
if (this$tags == null ? other$tags != null : !this$tags.equals(other$tags)) {
return false;
}
return true;
}
@ -681,13 +721,15 @@ public class SarifLog {
result = result * PRIME + ($ruleset == null ? 43 : $ruleset.hashCode());
final java.lang.Object $priority = this.getPriority();
result = result * PRIME + ($priority == null ? 43 : $priority.hashCode());
final java.lang.Object $tags = this.getTags();
result = result * PRIME + ($tags == null ? 43 : $tags.hashCode());
return result;
}
@java.lang.Override
@java.lang.SuppressWarnings("all")
public java.lang.String toString() {
return "SarifLog.PropertyBag(ruleset=" + this.getRuleset() + ", priority=" + this.getPriority() + ")";
return "SarifLog.PropertyBag(ruleset=" + this.getRuleset() + ", priority=" + this.getPriority() + ", tags=" + this.getTags() + ")";
}
}

@ -176,6 +176,7 @@ public class SarifLogBuilder {
return ReportingDescriptor.builder()
.id(rv.getRule().getName())
.shortDescription(new MultiformatMessage(rv.getDescription()))
.fullDescription(new MultiformatMessage(rv.getRule().getDescription()))
.helpUri(rv.getRule().getExternalInfoUrl())
.properties(getRuleProperties(rv))
.build();
@ -185,6 +186,7 @@ public class SarifLogBuilder {
return PropertyBag.builder()
.ruleset(rv.getRule().getRuleSetName())
.priority(rv.getRule().getPriority().getPriority())
.tags(new String[] { rv.getRule().getRuleSetName() })
.build();
}

@ -14,9 +14,15 @@
"shortDescription": {
"text": "blah"
},
"fullDescription": {
"text": "desc"
},
"properties": {
"ruleset": "RuleSet",
"priority": 1
"priority": 1,
"tags": [
"RuleSet"
]
}
},
{
@ -24,9 +30,15 @@
"shortDescription": {
"text": "blah"
},
"fullDescription": {
"text": "desc"
},
"properties": {
"ruleset": "RuleSet",
"priority": 5
"priority": 5,
"tags": [
"RuleSet"
]
}
}
]

@ -14,9 +14,15 @@
"shortDescription": {
"text": "blah"
},
"fullDescription": {
"text": "desc"
},
"properties": {
"ruleset": "RuleSet",
"priority": 5
"priority": 5,
"tags": [
"RuleSet"
]
}
}
]