checkstyle/config/pmd.xml

140 lines
6.8 KiB
XML

<?xml version="1.0"?>
<ruleset name="PMD ruleset for Checkstyle"
xmlns="http://pmd.sourceforge.net/ruleset/2.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://pmd.sourceforge.net/ruleset/2.0.0
http://pmd.sourceforge.net/ruleset_2_0_0.xsd">
<description>
PMD ruleset for Checkstyle
</description>
<rule ref="rulesets/java/basic.xml"/>
<rule ref="rulesets/java/braces.xml"/>
<rule ref="rulesets/java/clone.xml"/>
<rule ref="rulesets/java/codesize.xml">
<!-- till #954 -->
<exclude name="CyclomaticComplexity"/>
<exclude name="ModifiedCyclomaticComplexity"/>
<exclude name="StdCyclomaticComplexity"/>
<!-- till #953 -->
<exclude name="NPathComplexity"/>
</rule>
<rule ref="rulesets/java/codesize.xml/TooManyMethods">
<properties>
<property name="maxmethods" value="20"/>
</properties>
</rule>
<rule ref="rulesets/java/codesize.xml/ExcessiveClassLength">
<properties>
<!-- *TokenTypes are special classes that a big due to a lot of description comments -->
<!-- JavadocMethodCheck is depreaced class, till it is redone to use JabadocAst -->
<property name="violationSuppressXPath" value="//ClassOrInterfaceDeclaration[@Image='JavadocTokenTypes' or @Image='TokenTypes' or @Image='JavadocMethodCheck']"/>
</properties>
</rule>
<rule ref="rulesets/java/codesize.xml/ExcessiveMethodLength">
<properties>
<!-- JavadocMethodCheck is depreaced class, till it is redone to use JavadocAst -->
<property name="violationSuppressXPath" value="//ClassOrInterfaceDeclaration[@Image='JavadocMethodCheck']"/>
</properties>
</rule>
<rule ref="rulesets/java/comments.xml">
<!-- <exclude name="CommentRequired"/> -->
<!-- we use class comments as source for xdoc files, so sontent is big and that is by design -->
<exclude name="CommentSize"/>
</rule>
<rule ref="rulesets/java/comments.xml/CommentRequired">
<properties>
<!-- *TokenTypes are special class, comments are as traling comments -->
<property name="violationSuppressXPath" value="//ClassOrInterfaceDeclaration[@Image='JavadocTokenTypes'] | //Annotation/MarkerAnnotation//Name[@Image='Override']"/>
</properties>
</rule>
<rule ref="rulesets/java/comments.xml/CommentSize">
<properties>
<!-- we use class comments as source for xdoc files, so sontent is big and that is by design -->
<property name="violationSuppressXPath" value="//ClassOrInterfaceDeclaration | //PackageDeclaration | //ClassOrInterfaceDeclaration[@Image='JavadocTagInfo'] | //ClassOrInterfaceDeclaration[@Image='SeverityLevel'] | //ClassOrInterfaceDeclaration[@Image='LeftCurlyOption'] | //ClassOrInterfaceDeclaration[@Image='RightCurlyOption'] | //ClassOrInterfaceDeclaration[@Image='ImportOrderOption']"/>
<property name="maxLines" value="8"/>
<property name="maxLineLength" value="100"/>
</properties>
</rule>
<rule ref="rulesets/java/controversial.xml">
<!-- calling super() is completely pointless, no matter if class inherits anything or not; it is meaningful only if you do not call implicit constructor of base class -->
<exclude name="CallSuperInConstructor"/>
<!-- We reuse Check instances between java files, we need to clear state of class in beginTree() methods -->
<exclude name="NullAssignment"/>
<!-- it is possible only in functional languages and fanatically-pristine code, withot aditional option that are done at ReturnCountExtendedCheck it is not good rule -->
<exclude name="OnlyOneReturn"/>
<!-- oposite to UnnecessaryConstructor -->
<exclude name="AtLeastOneConstructor"/>
<!-- deprecated by PMD -->
<exclude name="BooleanInversion"/>
<!-- till #957 -->
<exclude name="DefaultPackage"/>
<!-- that rule is too buggy, too much false positives-->
<exclude name="DataflowAnomalyAnalysis"/>
<!-- turning local varibles to fields create design problems and extend scope of variable -->
<exclude name="AvoidFinalLocalVariable"/>
<!-- conflicts with names that does not mean in/out -->
<exclude name="AvoidPrefixingMethodParameters"/>
<!-- that is not practical, no options to allow some magic numbers, we will use our implementation -->
<exclude name="AvoidLiteralsInIfCondition"/>
<!-- Checkstyle is not thread safe -->
<exclude name="UseConcurrentHashMap"/>
</rule>
<rule ref="rulesets/java/controversial.xml/AvoidUsingShortType">
<properties>
<!-- that class integate checkstyle and antlr that is why it has a lot of imports -->
<property name="violationSuppressXPath" value="//ClassOrInterfaceDeclaration[@Image='AutomaticBean']"/>
</properties>
</rule>
<rule ref="rulesets/java/coupling.xml">
<!-- produce too much violations, suppresssed till we figure out how useful that metrics-->
<exclude name="LawOfDemeter"/>
<!-- this rule is for managing import, we have special Check for that -->
<exclude name="LoosePackageCoupling"/>
</rule>
<rule ref="rulesets/java/coupling.xml/ExcessiveImports">
<properties>
<!-- that class integate checkstyle and antlr that is why it has a lot of imports -->
<property name="violationSuppressXPath" value="//ClassOrInterfaceDeclaration[@Image='TreeWalker']"/>
</properties>
</rule>
<rule ref="rulesets/java/coupling.xml/CouplingBetweenObjects">
<properties>
<!-- I donot see any problem , looks like false positive -->
<property name="violationSuppressXPath" value="//ClassOrInterfaceDeclaration[@Image='HandlerFactory']"/>
</properties>
</rule>
<!--<rule ref="rulesets/java/design.xml"/>-->
<rule ref="rulesets/java/empty.xml"/>
<rule ref="rulesets/java/finalizers.xml"/>
<rule ref="rulesets/java/imports.xml"/>
<!--<rule ref="rulesets/java/javabeans.xml"/>-->
<rule ref="rulesets/java/junit.xml"/>
<rule ref="rulesets/java/logging-jakarta-commons.xml"/>
<!--<rule ref="rulesets/java/logging-java.xml"/>-->
<rule ref="rulesets/java/migrating.xml"/>
<!--<rule ref="rulesets/java/naming.xml"/>-->
<rule ref="rulesets/java/optimizations.xml">
<!--produces more false-positives than real problems-->
<exclude name="AvoidInstantiatingObjectsInLoops"/>
<!--pollutes code with modifiers-->
<exclude name="LocalVariableCouldBeFinal"/>
<!--pollutes code with modifiers-->
<exclude name="MethodArgumentCouldBeFinal"/>
<!--till #948-->
<exclude name="PrematureDeclaration"/>
<!--till #949-->
<exclude name="SimplifyStartsWith"/>
<!--not configurable, decreases readability-->
<exclude name="UseStringBufferForStringAppends"/>
</rule>
<!--<rule ref="rulesets/java/strictexception.xml"/>-->
<rule ref="rulesets/java/strings.xml"/>
<rule ref="rulesets/java/sunsecure.xml"/>
<rule ref="rulesets/java/typeresolution.xml"/>
<rule ref="rulesets/java/unnecessary.xml"/>
<rule ref="rulesets/java/unusedcode.xml"/>
</ruleset>