java.lang.Object
edu.hm.hafner.analysis.Issue
All Implemented Interfaces:
Serializable

public class Issue extends Object implements Serializable
An issue reported by a static analysis tool. Use the provided builder to create new instances.
Author:
Ullrich Hafner
See Also:
  • Method Details

    • getPropertyValueAsString

      public static String getPropertyValueAsString(Issue issue, String propertyName)
      Returns the value of the property with the specified name for a given issue instance.
      Parameters:
      issue - the issue to get the property for
      propertyName - the name of the property
      Returns:
      the function that obtains the value
    • getPropertyValueGetter

      public static Function<Issue,String> getPropertyValueGetter(String propertyName)
      Returns a function that can dynamically obtain the value of the property with the specified name of an issue instance.
      Parameters:
      propertyName - the name of the property
      Returns:
      the function that obtains the value
    • byPackageName

      public static Predicate<Issue> byPackageName(String packageName)
      Returns a predicate that checks if the package name of an issue is equal to the specified package name.
      Parameters:
      packageName - the package name to match
      Returns:
      the predicate
    • byModuleName

      public static Predicate<Issue> byModuleName(String moduleName)
      Returns a predicate that checks if the module name of an issue is equal to the specified module name.
      Parameters:
      moduleName - the module name to match
      Returns:
      the predicate
    • byFileName

      public static Predicate<Issue> byFileName(String fileName)
      Returns a predicate that checks if the file name of an issue is equal to the specified file name.
      Parameters:
      fileName - the file name to match
      Returns:
      the predicate
    • byFolder

      public static Predicate<Issue> byFolder(String folder)
      Returns a predicate that checks if the folder of an issue is equal to the specified folder.
      Parameters:
      folder - the folder to match
      Returns:
      the predicate
    • bySeverity

      public static Predicate<Issue> bySeverity(Severity severity)
      Returns a predicate that checks if the severity of an issue is equal to the specified severity.
      Parameters:
      severity - the severity to match
      Returns:
      the predicate
    • byCategory

      public static Predicate<Issue> byCategory(String category)
      Returns a predicate that checks if the category of an issue is equal to the specified category.
      Parameters:
      category - the category to match
      Returns:
      the predicate
    • byOrigin

      public static Predicate<Issue> byOrigin(String origin)
      Returns a predicate that checks if the origin of an issue is equal to the specified origin.
      Parameters:
      origin - the origin to match
      Returns:
      the predicate
    • byType

      public static Predicate<Issue> byType(String type)
      Returns a predicate that checks if the type of an issue is equal to the specified type.
      Parameters:
      type - the type to match
      Returns:
      the predicate
    • readResolve

      protected Object readResolve()
      Called after de-serialization to improve the memory usage.
      Returns:
      this
    • getId

      public UUID getId()
      Returns the unique ID of this issue.
      Returns:
      the unique ID
    • getFileName

      public String getFileName()
      Returns the name of the affected file. This file name is a path relative to the path of the affected files (returned by getPath()).
      Returns:
      the name of the file that contains this issue
      See Also:
    • getFolder

      public String getFolder()
      Returns the folder that contains the affected file of this issue. Note that this path is not an absolute path, it is relative to the path of the affected files (returned by getPath()).
      Returns:
      the folder of the file that contains this issue
    • getBaseName

      public String getBaseName()
      Returns the base name of the file that contains this issue (i.e. the file name without the full path).
      Returns:
      the base name of the file that contains this issue
    • getAbsolutePath

      public String getAbsolutePath()
      Returns the absolute path of the affected file.
      Returns:
      the base name of the file that contains this issue
    • getPath

      public String getPath()
      Returns 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. If this path is not defined, then the default value UNDEFINED is returned.
      Returns:
      the base name of the file that contains this issue
    • hasFileName

      public boolean hasFileName()
      Returns whether this issue has a file name set.
      Returns:
      true if this issue has a file name set
      See Also:
    • getCategory

      public String getCategory()
      Returns the category of this issue (depends on the available categories of the static analysis tool). Examples for categories are "Deprecation", "Design", or "JavaDoc".
      Returns:
      the category
    • getType

      public String getType()
      Returns 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.
      Returns:
      the type
    • getSeverity

      public Severity getSeverity()
      Returns the severity of this issue.
      Returns:
      the severity
    • getMessage

      public String getMessage()
      Returns the detailed message for this issue.
      Returns:
      the message
    • getDescription

      public String getDescription()
      Returns an additional description for this issue. Static analysis tools might provide some additional information about this issue. This description may contain valid HTML.
      Returns:
      the description
    • getLineStart

      public int getLineStart()
      Returns the first line of this issue (lines start at 1; 0 indicates the whole file).
      Returns:
      the first line
    • getLineEnd

      public int getLineEnd()
      Returns the last line of this issue (lines start at 1).
      Returns:
      the last line
    • getLineRanges

      public Iterable<? extends LineRange> getLineRanges()
      Returns additional line ranges for this issue. Not that the primary range given by lineStart and lineEnd is not included.
      Returns:
      the last line
    • getColumnStart

      public int getColumnStart()
      Returns the first column of this issue (columns start at 1, 0 indicates the whole line).
      Returns:
      the first column
    • getColumnEnd

      public int getColumnEnd()
      Returns the last column of this issue (columns start at 1).
      Returns:
      the last column
    • getPackageName

      public String getPackageName()
      Returns the name of the package or name space (or similar concept) that contains this issue.
      Returns:
      the package name
    • hasPackageName

      public boolean hasPackageName()
      Returns whether this issue has a package name set.
      Returns:
      true if this issue has a package name set
      See Also:
    • getModuleName

      public String getModuleName()
      Returns the name of the module or project (or similar concept) that contains this issue.
      Returns:
      the module
    • hasModuleName

      public boolean hasModuleName()
      Returns whether this issue has a module name set.
      Returns:
      true if this issue has a module name set
      See Also:
    • getOrigin

      public String getOrigin()
      Returns the ID of the tool that did report this issue.
      Returns:
      the ID of the origin
    • getOriginName

      public String getOriginName()
      Returns the name of the tool that did report this issue.
      Returns:
      the name of the origin
    • setOrigin

      public void setOrigin(String origin)
      Sets the ID of the tool that did report this issue.
      Parameters:
      origin - the origin
    • setOrigin

      public void setOrigin(String originId, String name)
      Sets the ID and the name of the tool that did report this issue.
      Parameters:
      originId - the ID of the origin
      name - the name of the origin
    • getReference

      public String getReference()
      Returns a reference to the execution of the static analysis tool (build ID, timestamp, etc.).
      Returns:
      the reference
    • setReference

      public void setReference(@CheckForNull String reference)
      Sets a reference to the execution of the static analysis tool (build ID, timestamp, etc.). This property should not be set by parsers as it is overwritten by the differencing engine while computing new and fixed issues.
      Parameters:
      reference - the reference
    • getFingerprint

      public String getFingerprint()
      Returns 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.

      Note: the fingerprint is not part of the equals method since the fingerprint might change due to an unrelated refactoring of the source code.

      Returns:
      the fingerprint of this issue
    • hasFingerprint

      public boolean hasFingerprint()
      Returns whether this issue already has a fingerprint set.
      Returns:
      true if this issue already has a fingerprint set
    • getAdditionalProperties

      @CheckForNull public Serializable getAdditionalProperties()
      Returns additional properties for this issue. A static analysis tool may store additional properties in this untyped object. This object will be serialized and is used in equals and hashCode.
      Returns:
      the additional properties
    • equals

      public boolean equals(@CheckForNull Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object