Interface RuleViolation

  • All Known Implementing Classes:
    CachedRuleViolation, ParametricRuleViolation

    public interface RuleViolation
    A RuleViolation is created by a Rule when it identifies a violation of the Rule constraints. RuleViolations are simple data holders that are collected into a Report.

    Since PMD 6.21.0, implementations of this interface are considered internal API and hence deprecated. Clients should exclusively use this interface.

    See Also:
    Rule
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      int getBeginColumn()
      Get the column number of the begin line in the source file in which this violation was identified.
      int getBeginLine()
      Get the begin line number in the source file in which this violation was identified.
      String getClassName()
      Get the name of the Class in which this violation was identified.
      String getDescription()
      Get the description of this violation.
      int getEndColumn()
      Get the column number of the end line in the source file in which this violation was identified.
      int getEndLine()
      Get the end line number in the source file in which this violation was identified.
      String getFilename()
      Get the source file name in which this violation was identified.
      String getMethodName()
      Get the method name in which this violation was identified.
      String getPackageName()
      Get the package name of the Class in which this violation was identified.
      Rule getRule()
      Get the Rule which identified this violation.
      String getVariableName()
      Get the variable name on which this violation was identified.
      boolean isSuppressed()
      Indicates whether this violation has been suppressed.
    • Field Detail

      • DEFAULT_COMPARATOR

        static final Comparator<RuleViolation> DEFAULT_COMPARATOR
        A comparator for rule violations. This compares all exposed attributes of a violation, filename first. The remaining parameters are compared in an unspecified order.
    • Method Detail

      • getRule

        Rule getRule()
        Get the Rule which identified this violation.
        Returns:
        The identifying Rule.
      • getDescription

        String getDescription()
        Get the description of this violation.
        Returns:
        The description.
      • isSuppressed

        boolean isSuppressed()
        Indicates whether this violation has been suppressed.
        Returns:
        true if this violation is suppressed, false otherwise.
      • getFilename

        String getFilename()
        Get the source file name in which this violation was identified.
        Returns:
        The source file name.
      • getBeginLine

        int getBeginLine()
        Get the begin line number in the source file in which this violation was identified.
        Returns:
        Begin line number.
      • getBeginColumn

        int getBeginColumn()
        Get the column number of the begin line in the source file in which this violation was identified.
        Returns:
        Begin column number.
      • getEndLine

        int getEndLine()
        Get the end line number in the source file in which this violation was identified.
        Returns:
        End line number.
      • getEndColumn

        int getEndColumn()
        Get the column number of the end line in the source file in which this violation was identified.
        Returns:
        End column number.
      • getPackageName

        String getPackageName()
        Get the package name of the Class in which this violation was identified.
        Returns:
        The package name.
      • getClassName

        String getClassName()
        Get the name of the Class in which this violation was identified.
        Returns:
        The Class name.
      • getMethodName

        String getMethodName()
        Get the method name in which this violation was identified.
        Returns:
        The method name.
      • getVariableName

        String getVariableName()
        Get the variable name on which this violation was identified.
        Returns:
        The variable name.