-
Notifications
You must be signed in to change notification settings - Fork 180
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add missing descriptor and test case for Coverity.
- Loading branch information
Showing
4 changed files
with
121 additions
and
0 deletions.
There are no files selected for viewing
28 changes: 28 additions & 0 deletions
28
src/main/java/edu/hm/hafner/analysis/registry/CoverityDescriptor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package edu.hm.hafner.analysis.registry; | ||
|
||
import edu.hm.hafner.analysis.IssueParser; | ||
import edu.hm.hafner.analysis.parser.violations.CoverityAdapter; | ||
|
||
/** | ||
* A descriptor for Coverity. | ||
* | ||
* @author Ullrich Hafner | ||
*/ | ||
class CoverityDescriptor extends ParserDescriptor { | ||
private static final String ID = "coverity"; | ||
private static final String NAME = "Coverity Scan"; | ||
|
||
CoverityDescriptor() { | ||
super(ID, NAME); | ||
} | ||
|
||
@Override | ||
public IssueParser createParser(final Option... options) { | ||
return new CoverityAdapter(); | ||
} | ||
|
||
@Override | ||
public String getUrl() { | ||
return "https://scan.coverity.com/"; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
src/test/java/edu/hm/hafner/analysis/parser/violations/CoverityAdapterTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package edu.hm.hafner.analysis.parser.violations; | ||
|
||
import edu.hm.hafner.analysis.Report; | ||
import edu.hm.hafner.analysis.Severity; | ||
import edu.hm.hafner.analysis.assertions.SoftAssertions; | ||
import edu.hm.hafner.analysis.registry.AbstractParserTest; | ||
|
||
class CoverityAdapterTest extends AbstractParserTest { | ||
CoverityAdapterTest() { | ||
super("coverity.json"); | ||
} | ||
|
||
@Override | ||
protected void assertThatIssuesArePresent(final Report report, final SoftAssertions softly) { | ||
softly.assertThat(report).hasSize(1); | ||
var issue = report.get(0); | ||
softly.assertThat(issue) | ||
.hasFileName("C:/Workspace/workspace/Build_jenkins_development/somefile.cs") | ||
.hasCategory("Integer handling issues") | ||
.hasType("constant_expression_result/bit_and_with_zero") | ||
.hasLineStart(79) | ||
.hasSeverity(Severity.WARNING_NORMAL); | ||
softly.assertThat(issue.getMessage()).startsWith("Bitwise-and ('&') operation applied to zero always produces zero."); | ||
} | ||
|
||
@Override | ||
protected CoverityAdapter createParser() { | ||
return new CoverityAdapter(); | ||
} | ||
} |
62 changes: 62 additions & 0 deletions
62
src/test/resources/edu/hm/hafner/analysis/parser/violations/coverity.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
{ | ||
"type": "Coverity issues", | ||
"formatVersion": 7, | ||
"suppressedIssueCount": 0, | ||
"issues": [ | ||
{ | ||
"mergeKey": "884ed7531feed32eb916d9038a3b9bd6", | ||
"occurrenceCountForMK": 1, | ||
"occurrenceNumberInMK": 1, | ||
"referenceOccurrenceCountForMK": null, | ||
"checkerName": "CONSTANT_EXPRESSION_RESULT", | ||
"subcategory": "bit_and_with_zero", | ||
"type": "constant_expression_result", | ||
"subtype": "bit_and_with_zero", | ||
"code-language": "c#", | ||
"extra": "status", | ||
"domain": "STATIC_CS", | ||
"language": "C#", | ||
"mainEventFilePathname": "C:\\Workspace\\workspace\\Build_jenkins_development\\somefile.cs", | ||
"strippedMainEventFilePathname": "\\workspace\\Build_jenkins_development\\Architecture\\somefile.cs", | ||
"mainEventLineNumber": 79, | ||
"properties": {}, | ||
"functionDisplayName": "somename", | ||
"functionMangledName": "somename", | ||
"localStatus": null, | ||
"ordered": false, | ||
"events": [ | ||
{ | ||
"covLStrEventDescription": "{CovLStrv2{{t{{0} is always 0.}{{code{status & System.Printing.PrintJobStatus.None}}}}{t{ This occurs as a value.}}}}", | ||
"eventDescription": "\"status & System.Printing.PrintJobStatus.None\" is always 0. This occurs as a value.", | ||
"eventNumber": 1, | ||
"eventTreePosition": "1", | ||
"eventSet": 0, | ||
"eventTag": "bit_and_with_zero", | ||
"filePathname": "C:\\Workspace\\workspace\\Build_jenkins_development\\somefile.cs", | ||
"strippedFilePathname": "\\workspace\\Build_jenkins_development\\Architecture\\somefile.cs", | ||
"lineNumber": 79, | ||
"main": true, | ||
"moreInformationId": null, | ||
"remediation": false, | ||
"events": null | ||
} | ||
], | ||
"stateOnServer": null, | ||
"checkerProperties": { | ||
"category": "Integer handling issues", | ||
"categoryDescription": "Integer handling issues", | ||
"cweCategory": "569", | ||
"issueKinds": ["QUALITY"], | ||
"eventSetCaptions": [], | ||
"impact": "Medium", | ||
"impactDescription": "Medium", | ||
"subcategoryLocalEffect": "The expression's value is always zero; construct may indicate an inadvertent logic error.", | ||
"subcategoryShortDescription": "Bitwise-and with zero", | ||
"subcategoryLongDescription": "Bitwise-and ('&') operation applied to zero always produces zero" | ||
} | ||
} | ||
], | ||
"desktopAnalysisSettings": null, | ||
"error": null, | ||
"warnings": [] | ||
} |