Klasse IssueBuilder

java.lang.Object
edu.hm.hafner.analysis.IssueBuilder
Alle implementierten Schnittstellen:
AutoCloseable

public class IssueBuilder extends Object implements 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);
 
Autor:
Ullrich Hafner
  • Konstruktordetails

    • IssueBuilder

      public IssueBuilder()
  • Methodendetails

    • setId

      public IssueBuilder setId(UUID id)
      Sets the unique ID of the issue. If not set then an ID will be generated.
      Parameter:
      id - the ID
      Gibt zurück:
      this
    • setAdditionalProperties

      public IssueBuilder setAdditionalProperties(@CheckForNull Serializable additionalProperties)
      Sets additional properties from the statical analysis tool. This object could be used to store tool specific information.
      Parameter:
      additionalProperties - the instance
      Gibt zurück:
      this
    • setFingerprint

      public IssueBuilder setFingerprint(@CheckForNull String fingerprint)
      Sets the fingerprint for this issue. Used to decide if two issues are equal even if the equals method returns false since some of the properties differ due to code refactorings. The fingerprint is created by analyzing the content of the affected file.
      Parameter:
      fingerprint - the fingerprint to set
      Gibt zurück:
      this
    • setFileName

      public IssueBuilder setFileName(@CheckForNull String fileName)
      Sets the name of the affected file. This file name is a path relative to the path of the affected files (see setPathName(String)).
      Parameter:
      fileName - the file name
      Gibt zurück:
      this
    • setDirectory

      public IssueBuilder setDirectory(@CheckForNull String directory)
      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 of path, directory, and fileName. Note that this directory is not visible later on, the issue does only store the path in the path and fileName properties. I.e., the created issue will get a new file name that is composed of directory and fileName.
      Parameter:
      directory - the directory that contains all affected files
      Gibt zurück:
      this
    • setPathName

      public IssueBuilder setPathName(@CheckForNull String pathName)
      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 a Report. The path of an affected file is stored in the path and fileName properties so that issues can be tracked even if the root folder changes (due to different build environments).
      Parameter:
      pathName - the path that contains all affected files
      Gibt zurück:
      this
    • setLineStart

      public IssueBuilder setLineStart(int lineStart)
      Sets the first line of this issue (lines start at 1; 0 indicates the whole file).
      Parameter:
      lineStart - the first line
      Gibt zurück:
      this
    • setLineStart

      public IssueBuilder setLineStart(@CheckForNull String lineStart)
      Sets the first line of this issue (lines start at 1; 0 indicates the whole file).
      Parameter:
      lineStart - the first line
      Gibt zurück:
      this
    • setLineEnd

      public IssueBuilder setLineEnd(int lineEnd)
      Sets the last line of this issue (lines start at 1).
      Parameter:
      lineEnd - the last line
      Gibt zurück:
      this
    • setLineEnd

      public IssueBuilder setLineEnd(@CheckForNull String lineEnd)
      Sets the last line of this issue (lines start at 1).
      Parameter:
      lineEnd - the last line
      Gibt zurück:
      this
    • setColumnStart

      public IssueBuilder setColumnStart(int columnStart)
      Sets the first column of this issue (columns start at 1, 0 indicates the whole line).
      Parameter:
      columnStart - the first column
      Gibt zurück:
      this
    • setColumnStart

      public IssueBuilder setColumnStart(@CheckForNull String columnStart)
      Sets the first column of this issue (columns start at 1, 0 indicates the whole line).
      Parameter:
      columnStart - the first column
      Gibt zurück:
      this
    • setColumnEnd

      public IssueBuilder setColumnEnd(int columnEnd)
      Sets the the last column of this issue (columns start at 1).
      Parameter:
      columnEnd - the last column
      Gibt zurück:
      this
    • setColumnEnd

      public IssueBuilder setColumnEnd(@CheckForNull String columnEnd)
      Sets the the last column of this issue (columns start at 1).
      Parameter:
      columnEnd - the last column
      Gibt zurück:
      this
    • setCategory

      public IssueBuilder setCategory(@CheckForNull String category)
      Sets the category of this issue (depends on the available categories of the static analysis tool). Examples for categories are "Deprecation", "Design", or "JavaDoc".
      Parameter:
      category - the category
      Gibt zurück:
      this
    • setType

      public IssueBuilder setType(@CheckForNull String type)
      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.
      Parameter:
      type - the type
      Gibt zurück:
      this
    • setPackageName

      public IssueBuilder setPackageName(@CheckForNull String packageName)
      Sets the name of the package or name space (or similar concept) that contains this issue.
      Parameter:
      packageName - the package or namespace name
      Gibt zurück:
      this
    • setModuleName

      public IssueBuilder setModuleName(@CheckForNull String moduleName)
      Sets the name of the module or project (or similar concept) that contains this issue.
      Parameter:
      moduleName - the module name
      Gibt zurück:
      this
    • setOrigin

      public IssueBuilder setOrigin(@CheckForNull String origin)
      Sets the ID of the tool that did report this issue.
      Parameter:
      origin - the ID of the originating tool
      Gibt zurück:
      this
    • setOriginName

      public IssueBuilder setOriginName(@CheckForNull String originName)
      Sets the name of the tool that did report this issue.
      Parameter:
      originName - the ID of the originating tool
      Gibt zurück:
      this
    • setReference

      public IssueBuilder setReference(@CheckForNull String reference)
      Sets a reference to the execution of the static analysis tool (build ID, timestamp, etc.).
      Parameter:
      reference - the reference
      Gibt zurück:
      this
    • setSeverity

      public IssueBuilder setSeverity(@CheckForNull Severity severity)
      Sets the severity of this issue.
      Parameter:
      severity - the severity
      Gibt zurück:
      this
    • guessSeverity

      public IssueBuilder guessSeverity(@CheckForNull String severityString)
      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.
      Parameter:
      severityString - the severity given as a string representation
      Gibt zurück:
      this
    • setMessage

      public IssueBuilder setMessage(@CheckForNull String message)
      Sets the detailed message for this issue.
      Parameter:
      message - the message
      Gibt zurück:
      this
    • setDescription

      public IssueBuilder setDescription(@CheckForNull String description)
      Sets an additional description for this issue. Static analysis tools might provide some additional information about this issue. This description may contain valid HTML.
      Parameter:
      description - the description (as HTML content)
      Gibt zurück:
      this
    • setLineRanges

      public IssueBuilder setLineRanges(LineRangeList lineRanges)
      Sets additional line ranges for this issue. Not that the primary range given by lineStart and * lineEnd is not included.
      Parameter:
      lineRanges - the additional line ranges
      Gibt zurück:
      this
    • copy

      public IssueBuilder copy(Issue copy)
      Initializes this builder with an exact copy of all properties of the specified issue.
      Parameter:
      copy - the issue to copy the properties from
      Gibt zurück:
      the initialized builder
    • build

      public Issue build()
      Creates a new Issue based on the specified properties. After building the issue, this IssueBuilder creates a new ID, but all other Issue properties will remain unchanged.
      Gibt zurück:
      the created issue
    • buildAndClean

      public Issue buildAndClean()
      Creates a new Issue based on the specified properties. After building the issue, this IssueBuilder will be reset to its defaults.
      Gibt zurück:
      the created issue
    • buildOptional

      public Optional<Issue> buildOptional()
      Creates a new Issue based on the specified properties. The returned issue is wrapped in an Optional. After building the issue, this IssueBuilder will be reset to its defaults.
      Gibt zurück:
      the created issue
      Siehe auch:
    • close

      public void close()
      Reduce the memory print of internal string instances.
      Angegeben von:
      close in Schnittstelle AutoCloseable