public abstract class WarningParser extends Object implements hudson.ExtensionPoint
Modifier and Type | Class and Description |
---|---|
protected static class |
WarningParser.CommentProperties |
static class |
WarningParser.MisraVersion |
protected static class |
WarningParser.Suppression |
protected static class |
WarningParser.Violation |
Modifier and Type | Field and Description |
---|---|
static int |
ERR_COULD_NOT_DETERMINE_SUPPRESSED_GUIDELINE |
static int |
ERR_GRP_ERROR |
static int |
ERR_GUIDELINE_NOT_FOUND |
static int |
ERR_ILLEGAL_DEVIATION |
static int |
ERR_READ_FILE |
static int |
ERR_WRITE_FILE |
protected int |
errorCode |
protected PrintStream |
out |
Constructor and Description |
---|
WarningParser() |
Modifier and Type | Method and Description |
---|---|
static hudson.ExtensionList<WarningParser> |
all()
This is how we get all subclasses, so you don't need to do anything but add a
new subclass to the project in order to create support for a new tool.
|
protected abstract List<String> |
findSuppressionComments(String fileContent)
Parse the contents of a source code file, and return a list of all
suppression comments in the file.
|
String |
getDeviationPattern() |
int |
getErrorCode()
Gets the errors produced by this warningparser
|
String |
getFalsePositivePattern() |
protected abstract Set<String> |
getGuidelineIdsFromComment(String comment)
For a single suppression comment, find each MISRA violation that is
suppressed by this comment.
|
String |
getGuidelinePattern() |
List<Guideline> |
getGuidelines() |
String |
getLogFilePath() |
protected static String |
getMisraLintFileContent(WarningParser.MisraVersion misraVersion)
These files are provided by Gimpel software as settings for PC-lint.
|
WarningParser.MisraVersion |
getMisraVersion() |
String |
getNonMisraPattern() |
hudson.FilePath |
getWorkspace() |
void |
initialize(WarningParser.MisraVersion misraVersion)
Initializes/resets this warning parser and sets the MISRA version.
|
boolean |
isCompliant() |
protected void |
log(String s) |
abstract String |
name() |
protected List<WarningParser.CommentProperties> |
parseSourceFile(String fileName) |
void |
parseSourceFiles(List<String> filesToParse) |
protected abstract List<WarningParser.Violation> |
parseWarningLine(String line)
Parse a line from the output of the MISRA checker tool (e.g.
|
void |
parseWarnings(List<String> lines) |
void |
readGrp(List<String> grpLines)
Reads in a guideline categorization plan (GRP) from a list of strings, each
containing a guideline to be recategorized and its new category separated by
a comma, e.g "Rule 1.1, mandatory" or "Directive 2.1, disapplied"
|
void |
setDeviationPattern(String regex) |
void |
setFalsePositivePattern(String regex) |
void |
setGuidelinePattern(String regex) |
protected void |
setGuidelines(List<Guideline> guidelines)
Method only meant for injection from tests to reduce test-refactoring effort
|
void |
setLogFilePath(String logFilePath) |
void |
setLogger(PrintStream logger) |
protected void |
setMisraVersion(WarningParser.MisraVersion misraVersion)
Resets this parser and sets a specific MISRA version.
|
void |
setNonMisraPattern(String regex) |
void |
setWorkspace(hudson.FilePath workspace) |
String |
summary() |
Set<WarningParser.MisraVersion> |
supportedMisraVersions()
Returns the set of all MISRA-guideline versions supported by this warning
parser.
|
public static final int ERR_GUIDELINE_NOT_FOUND
public static final int ERR_COULD_NOT_DETERMINE_SUPPRESSED_GUIDELINE
public static final int ERR_GRP_ERROR
public static final int ERR_ILLEGAL_DEVIATION
public static final int ERR_READ_FILE
public static final int ERR_WRITE_FILE
protected int errorCode
protected PrintStream out
protected abstract List<WarningParser.Violation> parseWarningLine(String line)
line
- A single line of text from the parser tools output. The parser
should be configured so that a violation does not cover more than
one line.protected abstract List<String> findSuppressionComments(String fileContent)
fileContent
- The full contents of the source file as a stringprotected abstract Set<String> getGuidelineIdsFromComment(String comment)
Note: This is likely the most difficult method to implement, since it may have to map tool error codes to MISRA guidelines. If this mapping is too complex, you can implement this method to always return null. This will force the user to always add a GUIDELINE(...) tag to suppression comments, or end up with an invalid report.
comment
- A suppression comment from the source filepublic abstract String name()
public Set<WarningParser.MisraVersion> supportedMisraVersions()
protected void setMisraVersion(WarningParser.MisraVersion misraVersion)
misraVersion
- Version of MISRA rules to use.public final void initialize(WarningParser.MisraVersion misraVersion)
misraVersion
- Version of the MISRA rules to usepublic final WarningParser.MisraVersion getMisraVersion()
protected void setGuidelines(List<Guideline> guidelines)
guidelines
- List of guidelinessprotected static final String getMisraLintFileContent(WarningParser.MisraVersion misraVersion)
misraVersion
- Version of MISRA guidelinespublic final int getErrorCode()
public final String getFalsePositivePattern()
public final void setFalsePositivePattern(String regex)
public final String getDeviationPattern()
public final void setDeviationPattern(String regex)
public final String getNonMisraPattern()
public final void setNonMisraPattern(String regex)
public final String getGuidelinePattern()
public final void setGuidelinePattern(String regex)
public final void setLogger(PrintStream logger)
protected List<WarningParser.CommentProperties> parseSourceFile(String fileName)
public final void readGrp(List<String> grpLines)
grpLines
- List of lines from the GRP fileprotected final void log(String s)
public final boolean isCompliant()
public final String summary()
public static final hudson.ExtensionList<WarningParser> all()
WarningParser
s.public final String getLogFilePath()
public final void setLogFilePath(String logFilePath)
public final hudson.FilePath getWorkspace()
public final void setWorkspace(hudson.FilePath workspace)
Copyright © 2016–2019. All rights reserved.