Package edu.hm.hafner.analysis
Class IssueBuilder
java.lang.Object
edu.hm.hafner.analysis.IssueBuilder
- All Implemented Interfaces:
AutoCloseable
Creates new
issues using the builder pattern. All properties that have not been set in the builder will
be set to their default value.
Example:
Issue issue = new IssueBuilder()
.setFileName("affected.file")
.setLineStart(0)
.setCategory("JavaDoc")
.setMessage("Missing JavaDoc")
.setSeverity(Severity.WARNING_LOW);
- Author:
- Ullrich Hafner
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbuild()Creates a newIssuebased on the specified properties.Creates a newIssuebased on the specified properties.Creates a newIssuebased on the specified properties.voidclose()Reduce the memory print of internal string instances.Initializes this builder with an exact copy of all properties of the specified issue.guessSeverity(String severityString) Guesses a severity for the issues: converts a String severity to one of the predefined severities.setAdditionalProperties(Serializable additionalProperties) Sets additional properties from the statical analysis tool.setCategory(String category) Sets the category of this issue (depends on the available categories of the static analysis tool).setColumnEnd(int columnEnd) Sets the the last column of this issue (columns start at 1).setColumnEnd(String columnEnd) Sets the the last column of this issue (columns start at 1).setColumnStart(int columnStart) Sets the first column of this issue (columns start at 1, 0 indicates the whole line).setColumnStart(String columnStart) Sets the first column of this issue (columns start at 1, 0 indicates the whole line).setDescription(String description) Sets an additional description for this issue.setDirectory(String directory) Sets the current work directory.setFileName(String fileName) Sets the name of the affected file.setFingerprint(String fingerprint) Sets the fingerprint for this issue.Sets the unique ID of the issue.setLineEnd(int lineEnd) Sets the last line of this issue (lines start at 1).setLineEnd(String lineEnd) Sets the last line of this issue (lines start at 1).setLineRanges(LineRangeList lineRanges) Sets additional line ranges for this issue.setLineStart(int lineStart) Sets the first line of this issue (lines start at 1; 0 indicates the whole file).setLineStart(String lineStart) Sets the first line of this issue (lines start at 1; 0 indicates the whole file).setMessage(String message) Sets the detailed message for this issue.setModuleName(String moduleName) Sets the name of the module or project (or similar concept) that contains this issue.Sets the ID of the tool that did report this issue.setOriginName(String originName) Sets the name of the tool that did report this issue.setPackageName(String packageName) Sets the name of the package or name space (or similar concept) that contains this issue.setPathName(String pathName) Sets the path of the affected file.setReference(String reference) Sets a reference to the execution of the static analysis tool (build ID, timestamp, etc.).setSeverity(Severity severity) Sets the severity of this issue.Sets the type of this issue (depends on the available types of the static analysis tool).
-
Constructor Details
-
IssueBuilder
public IssueBuilder()
-
-
Method Details
-
setId
Sets the unique ID of the issue. If not set then an ID will be generated.- Parameters:
id- the ID- Returns:
- this
-
setAdditionalProperties
Sets additional properties from the statical analysis tool. This object could be used to store tool specific information.- Parameters:
additionalProperties- the instance- Returns:
- this
-
setFingerprint
Sets the fingerprint for this issue. Used to decide if two issues are equal even if the equals method returnsfalsesince some of the properties differ due to code refactorings. The fingerprint is created by analyzing the content of the affected file.- Parameters:
fingerprint- the fingerprint to set- Returns:
- this
-
setFileName
Sets the name of the affected file. This file name is a path relative to the path of the affected files (seesetPathName(String)).- Parameters:
fileName- the file name- Returns:
- this
-
setDirectory
Sets the current work directory. This directory is used as prefix for all subsequent issue file names. If the path is set as well, then the final path of an issue is the concatenation ofpath,directory, andfileName. Note that this directory is not visible later on, the issue does only store the path in thepathandfileNameproperties. I.e., the created issue will get a new file name that is composed ofdirectoryandfileName.- Parameters:
directory- the directory that contains all affected files- Returns:
- this
-
setPathName
Sets the path of the affected file. Note that this path is not the parent folder of the affected file. This path is the folder that contains all of the affected files of aReport. The path of an affected file is stored in thepathandfileNameproperties so that issues can be tracked even if the root folder changes (due to different build environments).- Parameters:
pathName- the path that contains all affected files- Returns:
- this
-
setLineStart
Sets the first line of this issue (lines start at 1; 0 indicates the whole file).- Parameters:
lineStart- the first line- Returns:
- this
-
setLineStart
Sets the first line of this issue (lines start at 1; 0 indicates the whole file).- Parameters:
lineStart- the first line- Returns:
- this
-
setLineEnd
Sets the last line of this issue (lines start at 1).- Parameters:
lineEnd- the last line- Returns:
- this
-
setLineEnd
Sets the last line of this issue (lines start at 1).- Parameters:
lineEnd- the last line- Returns:
- this
-
setColumnStart
Sets the first column of this issue (columns start at 1, 0 indicates the whole line).- Parameters:
columnStart- the first column- Returns:
- this
-
setColumnStart
Sets the first column of this issue (columns start at 1, 0 indicates the whole line).- Parameters:
columnStart- the first column- Returns:
- this
-
setColumnEnd
Sets the the last column of this issue (columns start at 1).- Parameters:
columnEnd- the last column- Returns:
- this
-
setColumnEnd
Sets the the last column of this issue (columns start at 1).- Parameters:
columnEnd- the last column- Returns:
- this
-
setCategory
Sets the category of this issue (depends on the available categories of the static analysis tool). Examples for categories are "Deprecation", "Design", or "JavaDoc".- Parameters:
category- the category- Returns:
- this
-
setType
Sets the type of this issue (depends on the available types of the static analysis tool). The type typically is the associated rule of the static analysis tool that reported this issue.- Parameters:
type- the type- Returns:
- this
-
setPackageName
Sets the name of the package or name space (or similar concept) that contains this issue.- Parameters:
packageName- the package or namespace name- Returns:
- this
-
setModuleName
Sets the name of the module or project (or similar concept) that contains this issue.- Parameters:
moduleName- the module name- Returns:
- this
-
setOrigin
Sets the ID of the tool that did report this issue.- Parameters:
origin- the ID of the originating tool- Returns:
- this
-
setOriginName
Sets the name of the tool that did report this issue.- Parameters:
originName- the ID of the originating tool- Returns:
- this
-
setReference
Sets a reference to the execution of the static analysis tool (build ID, timestamp, etc.).- Parameters:
reference- the reference- Returns:
- this
-
setSeverity
Sets the severity of this issue.- Parameters:
severity- the severity- Returns:
- this
-
guessSeverity
Guesses a severity for the issues: converts a String severity to one of the predefined severities. If the provided String does not match (even partly) then the default severity will be returned.- Parameters:
severityString- the severity given as a string representation- Returns:
- this
-
setMessage
Sets the detailed message for this issue.- Parameters:
message- the message- Returns:
- this
-
setDescription
Sets an additional description for this issue. Static analysis tools might provide some additional information about this issue. This description may contain valid HTML.- Parameters:
description- the description (as HTML content)- Returns:
- this
-
setLineRanges
Sets additional line ranges for this issue. Not that the primary range given bylineStartand* lineEndis not included.- Parameters:
lineRanges- the additional line ranges- Returns:
- this
-
copy
Initializes this builder with an exact copy of all properties of the specified issue.- Parameters:
copy- the issue to copy the properties from- Returns:
- the initialized builder
-
build
Creates a newIssuebased on the specified properties. After building the issue, thisIssueBuildercreates a new ID, but all otherIssueproperties will remain unchanged.- Returns:
- the created issue
-
buildAndClean
Creates a newIssuebased on the specified properties. After building the issue, thisIssueBuilderwill be reset to its defaults.- Returns:
- the created issue
-
buildOptional
Creates a newIssuebased on the specified properties. The returned issue is wrapped in anOptional. After building the issue, thisIssueBuilderwill be reset to its defaults.- Returns:
- the created issue
- See Also:
-
close
public void close()Reduce the memory print of internal string instances.- Specified by:
closein interfaceAutoCloseable
-