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 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.
      • getLocation

        FileLocation getLocation()
        Returns the location where the violation should be reported.
      • getFilename

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

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

        default 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

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

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

        Map<String,​String> getAdditionalInfo()
        A map of additional key-value pairs known about this violation. What data is in there is language specific. Common keys supported by several languages are defined as constants on this interface. The map is unmodifiable.
      • getPackageName

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

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

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

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