net.sourceforge.pmd

## Interface Rule

- All Superinterfaces:
    PropertySource
  All Known Subinterfaces:
    StatisticalRule
  All Known Implementing Classes:
    AbstractCommentRule, AbstractDelegateRule, AbstractDomXmlRule, AbstractEcmascriptRule, AbstractInefficientZeroCheck, AbstractJavaRule, AbstractJspRule, AbstractJUnitRule, AbstractNcssCountRule, AbstractOptimizationRule, AbstractPoorMethodCall, AbstractRule, AbstractStatisticalJavaRule, AbstractSunSecureRule, AbstractXmlRule, AccessorClassGenerationRule, AppendCharacterWithCharRule, ArrayIsStoredDirectlyRule, AssignmentInOperandRule, AssignmentToNonFinalStaticRule, AvoidBranchingStatementAsLastInLoopRule, AvoidCallingFinalizeRule, AvoidCatchingThrowableRule, AvoidDeeplyNestedIfStmtsRule, AvoidDollarSignsRule, AvoidDuplicateLiteralsRule, AvoidFieldNameMatchingMethodNameRule, AvoidFieldNameMatchingTypeNameRule, AvoidInstantiatingObjectsInLoopsRule, AvoidMultipleUnaryOperatorsRule, AvoidReassigningParametersRule, AvoidUsingHardCodedIPRule, AvoidUsingOctalValuesRule, BeanMembersShouldSerializeRule, BigIntegerInstantiationRule, BooleanInstantiationRule, BrokenNullCheckRule, CheckResultSetRule, CheckSkipResultRule, ClassNamingConventionsRule, CloneMethodMustImplementCloneable, CloseResourceRule, CodeInCommentsRule, CommentContentRule, CommentRequiredRule, CommentSizeRule, CompareObjectsWithEqualsRule, ConfusingTernaryRule, ConsecutiveLiteralAppendsRule, ConsistentReturnRule, ConstructorCallsOverridableMethodRule, CouplingBetweenObjectsRule, CyclomaticComplexityRule, DataflowAnomalyAnalysisRule, DFAGraphRule, DontImportJavaLangRule, DontImportSunRule, DoubleCheckedLockingRule, DuplicateImportsRule, DuplicateJspImportsRule, EcmascriptXPathRule, ExceptionAsFlowControlRule, ExcessiveClassLengthRule, ExcessiveImportsRule, ExcessiveLengthRule, ExcessiveMethodLengthRule, ExcessiveNodeCountRule, ExcessiveParameterListRule, ExcessivePublicCountRule, GenericClassCounterRule, GenericLiteralCheckerRule, GodClassRule, HeaderCommentsRule, IdempotentOperationsRule, ImmutableFieldRule, ImportFromSamePackageRule, InefficientEmptyStringCheckRule, InefficientStringBufferingRule, InsufficientStringBufferDeclarationRule, JavadocRule, JUnitAssertionsShouldIncludeMessageRule, JUnitTestsShouldIncludeAssertRule, JUnitUseExpectedRule, LawOfDemeterRule, LocalVariableCouldBeFinalRule, LooseCoupling, LooseCouplingRule, LoosePackageCouplingRule, MethodArgumentCouldBeFinalRule, MethodNamingConventionsRule, MethodReturnsInternalArrayRule, MethodWithSameNameAsEnclosingClassRule, MockRule, MoreThanOneLoggerRule, NcssConstructorCountRule, NcssMethodCountRule, NcssTypeCountRule, NoInlineStyleInformationRule, NonThreadSafeSingletonRule, NPathComplexityRule, NullAssignmentRule, OnlyOneReturnRule, OverrideBothEqualsAndHashcodeRule, PositionalIteratorRule, PrematureDeclarationRule, PreserveStackTraceRule, RedundantFieldInitializerRule, RuleReference, SignatureDeclareThrowsException, SignatureDeclareThrowsExceptionRule, SimplifyBooleanReturnsRule, SingularFieldRule, StringConcatenationRule, StringInstantiationRule, StringToStringRule, SuspiciousHashcodeMethodNameRule, SuspiciousOctalEscapeRule, SwitchDensityRule, SymbolTableTestRule, TestClassWithoutTestCasesRule, TooManyFieldsRule, UnnecessaryCaseChangeRule, UnnecessaryCastRule, UnnecessaryConversionTemporaryRule, UnnecessaryFullyQualifiedNameRule, UnnecessaryLocalBeforeReturnRule, UnnecessaryReturnRule, UnnecessaryWrapperObjectCreationRule, UnsynchronizedStaticDateFormatterRule, UnusedFormalParameterRule, UnusedImports, UnusedImportsRule, UnusedLocalVariableRule, UnusedModifierRule, UnusedPrivateFieldRule, UnusedPrivateMethodRule, UseCollectionIsEmptyRule, UseIndexOfCharRule, UselessAssignment, UselessOperationOnImmutableRule, UselessOverridingMethodRule, UselessStringValueOfRule, UseSingletonRule, UseStringBufferForStringAppendsRule, UseStringBufferLengthRule, VariableNamingConventionsRule, XmlXPathRule, XPathRule

      public interface Rule
      extends PropertySource

  This is the basic Rule interface for PMD rules.

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static StringProperty` | `VIOLATION_SUPPRESS_REGEX_DESCRIPTOR` The property descriptor to universally suppress violations with messages matching a regular expression.
    `static StringProperty` | `VIOLATION_SUPPRESS_XPATH_DESCRIPTOR` Name of the property to universally suppress violations on nodes which match a given relative XPath expression.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `addExample(String example)` Add a single example for this Rule.
    `void` | `addRuleChainVisit(Class<? extends Node> nodeClass)` Adds an AST node by class to be visited by the Rule on the RuleChain.
    `void` | `addRuleChainVisit(String astNodeName)` Adds an AST node by name to be visited by the Rule on the RuleChain.
    `void` | `apply(List<? extends Node> nodes, RuleContext ctx)` Apply this rule to the given collection of nodes, using the given context.
    `void` | `end(RuleContext ctx)` End processing.
    `String` | `getDescription()` Get the description of this Rule.
    `List<String>` | `getExamples()` Get the list of examples for this Rule.
    `String` | `getExternalInfoUrl()` Get a URL for external information about this Rule.
    `Language` | `getLanguage()` Get the Language of this Rule.
    `LanguageVersion` | `getMaximumLanguageVersion()` Get the maximum LanguageVersion to which this Rule applies.
    `String` | `getMessage()` Get the message to show when this Rule identifies a violation.
    `LanguageVersion` | `getMinimumLanguageVersion()` Get the minimum LanguageVersion to which this Rule applies.
    `String` | `getName()` Get the name of this Rule.
    `ParserOptions` | `getParserOptions()` Get the parser options for this Rule.
    `RulePriority` | `getPriority()` Get the priority of this Rule.
    `List<String>` | `getRuleChainVisits()` Gets the collection of AST node names visited by the Rule on the RuleChain.
    `String` | `getRuleClass()` Get the class of this Rule.
    `String` | `getRuleSetName()` Get the name of the RuleSet containing this Rule.
    `String` | `getSince()` Get the version of PMD in which this Rule was added.
    `boolean` | `isDeprecated()` Gets whether this Rule is deprecated.
    `void` | `setDeprecated(boolean deprecated)` Sets whether this Rule is deprecated.
    `void` | `setDescription(String description)` Set the description of this Rule.
    `void` | `setExternalInfoUrl(String externalInfoUrl)` Set a URL for external information about this Rule.
    `void` | `setLanguage(Language language)` Set the Language of this Rule.
    `void` | `setMaximumLanguageVersion(LanguageVersion maximumLanguageVersion)` Set the maximum LanguageVersion to which this Rule applies.
    `void` | `setMessage(String message)` Set the message to show when this Rule identifies a violation.
    `void` | `setMinimumLanguageVersion(LanguageVersion minimumLanguageVersion)` Set the minimum LanguageVersion to which this Rule applies.
    `void` | `setName(String name)` Set the name of this Rule.
    `void` | `setPriority(RulePriority priority)` Set the priority of this Rule.
    `void` | `setRuleClass(String ruleClass)` Set the class of this Rule.
    `void` | `setRuleSetName(String name)` Set the name of the RuleSet containing this Rule.
    `void` | `setSince(String since)` Set the version of PMD in which this Rule was added.
    `void` | `setUsesDFA()` Sets whether this Rule uses Data Flow Analysis.
    `void` | `setUsesTypeResolution()` Sets whether this Rule uses Type Resolution.
    `void` | `start(RuleContext ctx)` Start processing.
    `boolean` | `usesDFA()` Gets whether this Rule uses Data Flow Analysis.
    `boolean` | `usesRuleChain()` Gets whether this Rule uses the RuleChain.
    `boolean` | `usesTypeResolution()` Gets whether this Rule uses Type Resolution.

    - ### Methods inherited from interface net.sourceforge.pmd.PropertySource

      `definePropertyDescriptor, dysfunctionReason, getPropertiesByPropertyDescriptor, getProperty, getPropertyDescriptor, getPropertyDescriptors, hasDescriptor, ignoredProperties, setProperty, useDefaultValueFor, usesDefaultValues`

- - ### Field Detail

    - #### VIOLATION_SUPPRESS_REGEX_DESCRIPTOR

          static final StringProperty VIOLATION_SUPPRESS_REGEX_DESCRIPTOR

      The property descriptor to universally suppress violations with messages matching a regular expression.

    - #### VIOLATION_SUPPRESS_XPATH_DESCRIPTOR

          static final StringProperty VIOLATION_SUPPRESS_XPATH_DESCRIPTOR

      Name of the property to universally suppress violations on nodes which match a given relative XPath expression.

  - ### Method Detail

    - #### getLanguage

          Language getLanguage()

      Get the Language of this Rule.

    - #### setLanguage

          void setLanguage(Language language)

      Set the Language of this Rule.

    - #### getMinimumLanguageVersion

          LanguageVersion getMinimumLanguageVersion()

      Get the minimum LanguageVersion to which this Rule applies. If this value is `null` it indicates there is no minimum bound.

    - #### setMinimumLanguageVersion

          void setMinimumLanguageVersion(LanguageVersion minimumLanguageVersion)

      Set the minimum LanguageVersion to which this Rule applies.

    - #### getMaximumLanguageVersion

          LanguageVersion getMaximumLanguageVersion()

      Get the maximum LanguageVersion to which this Rule applies. If this value is `null` it indicates there is no maximum bound.

    - #### setMaximumLanguageVersion

          void setMaximumLanguageVersion(LanguageVersion maximumLanguageVersion)

      Set the maximum LanguageVersion to which this Rule applies.

    - #### isDeprecated

          boolean isDeprecated()

      Gets whether this Rule is deprecated. A deprecated Rule is one which:
      - is scheduled for removal in a future version of PMD
      - or, has been removed and replaced with a non-functioning place-holder and will be completely removed in a future version of PMD
      - or, has been renamed/moved and the old name will be completely removed in a future version of PMD

    - #### setDeprecated

          void setDeprecated(boolean deprecated)

      Sets whether this Rule is deprecated.

    - #### getName

          String getName()

      Get the name of this Rule.

    - #### setName

          void setName(String name)

      Set the name of this Rule.

    - #### getSince

          String getSince()

      Get the version of PMD in which this Rule was added. Return `null` if not applicable.

    - #### setSince

          void setSince(String since)

      Set the version of PMD in which this Rule was added.

    - #### getRuleClass

          String getRuleClass()

      Get the class of this Rule.

    - #### setRuleClass

          void setRuleClass(String ruleClass)

      Set the class of this Rule.

    - #### getRuleSetName

          String getRuleSetName()

      Get the name of the RuleSet containing this Rule.
      See Also:
        `RuleSet`

    - #### setRuleSetName

          void setRuleSetName(String name)

      Set the name of the RuleSet containing this Rule.
      See Also:
        `RuleSet`

    - #### getMessage

          String getMessage()

      Get the message to show when this Rule identifies a violation.

    - #### setMessage

          void setMessage(String message)

      Set the message to show when this Rule identifies a violation.

    - #### getDescription

          String getDescription()

      Get the description of this Rule.

    - #### setDescription

          void setDescription(String description)

      Set the description of this Rule.

    - #### getExamples

          List<String> getExamples()

      Get the list of examples for this Rule.

    - #### addExample

          void addExample(String example)

      Add a single example for this Rule.

    - #### getExternalInfoUrl

          String getExternalInfoUrl()

      Get a URL for external information about this Rule.

    - #### setExternalInfoUrl

          void setExternalInfoUrl(String externalInfoUrl)

      Set a URL for external information about this Rule.

    - #### getPriority

          RulePriority getPriority()

      Get the priority of this Rule.

    - #### setPriority

          void setPriority(RulePriority priority)

      Set the priority of this Rule.

    - #### getParserOptions

          ParserOptions getParserOptions()

      Get the parser options for this Rule. Parser options are used to configure the `Parser` to create an AST in the form the Rule is expecting. Because ParserOptions are mutable, a Rule should return a new instance on each call.

    - #### setUsesDFA

          void setUsesDFA()

      Sets whether this Rule uses Data Flow Analysis.

    - #### usesDFA

          boolean usesDFA()

      Gets whether this Rule uses Data Flow Analysis.

    - #### setUsesTypeResolution

          void setUsesTypeResolution()

      Sets whether this Rule uses Type Resolution.

    - #### usesTypeResolution

          boolean usesTypeResolution()

      Gets whether this Rule uses Type Resolution.

    - #### usesRuleChain

          boolean usesRuleChain()

      Gets whether this Rule uses the RuleChain.

    - #### getRuleChainVisits

          List<String> getRuleChainVisits()

      Gets the collection of AST node names visited by the Rule on the RuleChain.

    - #### addRuleChainVisit

          void addRuleChainVisit(Class<? extends Node> nodeClass)

      Adds an AST node by class to be visited by the Rule on the RuleChain.

    - #### addRuleChainVisit

          void addRuleChainVisit(String astNodeName)

      Adds an AST node by name to be visited by the Rule on the RuleChain.

    - #### start

          void start(RuleContext ctx)

      Start processing. Called once, before apply() is first called.

    - #### apply

          void apply(List<? extends Node> nodes,
                   RuleContext ctx)

      Apply this rule to the given collection of nodes, using the given context.

    - #### end

          void end(RuleContext ctx)

      End processing. Called once, after apply() is last called.

Copyright © 2002-2013 InfoEther. All Rights Reserved.