- 浏览: 125967 次
最新评论
-
gaoxikun:
看起来很齐全,很完美,但是不知道从哪里下载 。
myeclipse插件简单介绍 -
gaoxikun:
亲,能把这个集成了插件的myeclipse 6.5给我一下吗, ...
myeclipse插件简单介绍 -
hotsmile:
不错!!!!!!!!!
myeclipse插件简单介绍
<?xml version="1.0" encoding="UTF-8"?>
<ruleset name="Favorites"
xmlns="http://pmd.sf.net/ruleset/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://pmd.sf.net/ruleset/1.0.0 http://pmd.sf.net/ruleset_xml_schema.xsd"
xsi:noNamespaceSchemaLocation="http://pmd.sf.net/ruleset_xml_schema.xsd">
<description>
规则版本号:V1.2(2008-11-04)
去除规则AvoidUsingHardCodedIP
增加规则-------级别为3----------------------------------
EmptyStaticInitializer、EmptyStatementNotInLoop、UnnecessaryFinalModifier、
ExcessiveParameterList、UnnecessaryConstructor、DontImportSun、UseSingleton、
AvoidDeeplyNestedIfStmts、DefaultLabelNotLastInSwitchStmt、NonCaseLabelInSwitchStatement、
AvoidInstanceofChecksInCatchClause、SimplifyConditional、AvoidCallingFinalize、
DontImportJavaLang、ImportFromSamePackage、BooleanGetMethodName、
SignatureDeclareThrowsException、AvoidThrowingRawExceptionTypes、DoNotExtendJavaLangError
-------级别为4----------------------------------
OverrideBothEqualsAndHashcode、EmptySynchronizedBlock、UselessOperationOnImmutable、
MisplacedNullCheck、BrokenNullCheck、IfStmtsMustUseBraces、WhileLoopsMustUseBraces、
IfElseStmtsMustUseBraces、ForLoopsMustUseBraces、AvoidAccessibilityAlteration、
DoNotCallGarbageCollectionExplicitly、BadComparison、InstantiationToGetClass、
UseNotifyAllInsteadOfNotify、ReturnEmptyArrayRatherThanNull、StringInstantiation、
StringToString、UseEqualsToCompareStrings、UnusedPrivateField、UnusedPrivateMethod
规则版本号:V1.1(2008-08-13)
去除规则ShortVariable
规则版本号:V1.0(2008-08-11)
推荐指数是4、5级的规则。
</description>
<!--====================Basic Rules begin(共33个)======================-->
<rule ref="rulesets/basic.xml/EmptyCatchBlock">
<properties>
<property name="allowCommentedBlocks" value="false"/>
</properties>
</rule>
<!--不允许出现空的catch块,避免屏蔽异常,不处理或不报告异常。(FindBugs不检查)-->
<rule ref="rulesets/basic.xml/EmptyIfStmt"/>
<!--不允许有空if语句块(或空else块)。(FindBugs不检查)-->
<rule ref="rulesets/basic.xml/EmptyWhileStmt"/>
<!--不允许有空while循环块。注意:不包括do循环。(FindBugs不检查)-->
<rule ref="rulesets/basic.xml/EmptyTryBlock"/>
<!--不允许有空try块。(FindBugs不检查)-->
<rule ref="rulesets/basic.xml/EmptyFinallyBlock"/>
<!--不允许有空finally块。(FindBugs不检查)-->
<rule ref="rulesets/basic.xml/EmptySwitchStatements"/>
<!--不允许有空switch块。与这个规则重复:rulesets/design.xml/SwitchStmtsShouldHaveDefault、MissingBreakInSwitch。(FindBugs不检查)-->
<rule ref="rulesets/basic.xml/JumbledIncrementer"/>
<!--避免混乱的循环变量赋值(避免在内循环里修改外循环变量)。与这个规则有点重复:rulesets/controversial.xml/DataflowAnomalyAnalysis。(FindBugs不检查)-->
<!--rule ref="rulesets/basic.xml/ForLoopShouldBeWhileLoop"/-->
<!--简单的for循环可以用while循环取代。(FindBugs不检查,注,FindBugs能发现死循环)-->
<!--rule ref="rulesets/basic.xml/UnnecessaryConversionTemporary"/-->
<!--当基本型数据转换成String时,避免不必要的临时对象。(FindBugs检查)-->
<rule ref="rulesets/basic.xml/OverrideBothEqualsAndHashcode"/>
<!--equals和hashcode同时定义。(FindBugs检查)-->
<!--rule ref="rulesets/basic.xml/DoubleCheckedLocking"/-->
<!--doublecheck问题。(FindBugs检查)-->
<rule ref="rulesets/basic.xml/ReturnFromFinallyBlock"/>
<!--禁止在finally块里return,避免屏蔽异常。(FindBugs不检查)-->
<rule ref="rulesets/basic.xml/EmptySynchronizedBlock"/>
<!--避免空的同步块。(FindBugs检查)-->
<!--rule ref="rulesets/basic.xml/UnnecessaryReturn"/-->
<!--方法返回值void,避免不必要的return。(FindBugs不检查)-->
<rule ref="rulesets/basic.xml/EmptyStaticInitializer"/>
<!--空的static初始化。(FindBugs不检查)-->
<rule ref="rulesets/basic.xml/UnconditionalIfStatement"/>
<!--if语句的条件始终是true或false。(FindBugs不检查)-->
<rule ref="rulesets/basic.xml/EmptyStatementNotInLoop"/>
<!--出现了空语句(就一个分号),如果在循环里则可以。(FindBugs不检查)-->
<rule ref="rulesets/basic.xml/BooleanInstantiation"/>
<!--避免实例化Boolean对象,而应用常量Boolean.TRUE, Boolean.FALSE。(FindBugs只检查构造方法生成对象的情况,不检查valueOf)-->
<rule ref="rulesets/basic.xml/UnnecessaryFinalModifier"/>
<!--当一个类定义成final后,它所有的方法自动final。(FindBugs不检查)-->
<!--rule ref="rulesets/basic.xml/CollapsibleIfStatements"/-->
<!--内嵌的if语句能够和外层的if语句合并成一个if语句。(FindBugs不检查)-->
<!--rule ref="rulesets/basic.xml/UselessOverridingMethod"/-->
<!--被覆盖的方法仅仅调用了基类的方法。(FindBugs检查)-->
<rule ref="rulesets/basic.xml/ClassCastExceptionWithToArray"/>
<!--Collection.toArray调用转换成数组,应主动传一个明确类型的数组对象,否则运行时会抛ClassCastException异常。相似规则:rulesets/design.xml/OptimizableToArrayCall。(FindBugs不检查)-->
<rule ref="rulesets/basic.xml/AvoidDecimalLiteralsInBigDecimalConstructor"/>
<!--new BigDecimal建议用String参数的构造方法,而不是十进制小数常量(整数除外)。(FindBugs不检查)-->
<rule ref="rulesets/basic.xml/UselessOperationOnImmutable"/>
<!--不可变对象(如BigDecimal、BigInteger)上的操作结果被忽略。(FindBugs检查)-->
<rule ref="rulesets/basic.xml/MisplacedNullCheck"/>
<!--空指针判断放错了位置。要么之前已报空指针,要么此处永远不可能是空指针。(FindBugs检查)-->
<!--rule ref="rulesets/basic.xml/UnusedNullCheckInEquals"/-->
<!--在判断了对象是否是空指针后,后面紧接着调用该对象的equals方法,而不是将对象作为另一个对象的equals参数。(FindBugs不检查)-->
<!--rule ref="rulesets/basic.xml/AvoidThreadGroup"/-->
<!--不建议用ThreadGroup,因为它的方法不是线程安全的。(FindBugs不检查)-->
<rule ref="rulesets/basic.xml/BrokenNullCheck"/>
<!--应该用&&取代||或反之。(FindBugs检查)-->
<rule ref="rulesets/basic.xml/BigIntegerInstantiation"/>
<!--不要再创建已经有的对象(BigDecimal.ZERO, BigDecimal.ONE, BigDecimal.TEN)。(FindBugs不检查)-->
<!--rule ref="rulesets/basic.xml/AvoidUsingOctalValues"/-->
<!--避免使用八进制值。(FindBugs不检查)-->
<!--
<rule ref="rulesets/basic.xml/AvoidUsingHardCodedIP">
<properties>
<property name="pattern" value=""/>
</properties>
</rule>
-->
<!--避免硬编码IPv4和IPv6,以免在某些情况下变的不可能布署。(FindBugs不检查)-->
<rule ref="rulesets/basic.xml/CheckResultSet"/>
<!--对ResultSet的方法(next,previous,first,last)调用结果要进行是否是真的判断。(FindBugs不检查)-->
<rule ref="rulesets/basic.xml/AvoidMultipleUnaryOperators"/>
<!--避免多个一元操作符,要么是一个错误,要么易引起混淆。(FindBugs不检查)-->
<!--====================Basic Rules end======================-->
<!--====================braces Rules begin(共4个)======================-->
<rule ref="rulesets/braces.xml/IfStmtsMustUseBraces"/>
<rule ref="rulesets/braces.xml/WhileLoopsMustUseBraces"/>
<rule ref="rulesets/braces.xml/IfElseStmtsMustUseBraces"/>
<rule ref="rulesets/braces.xml/ForLoopsMustUseBraces"/>
<!--====================braces Rules end======================-->
<!--====================clone Rules begin(共3个)======================-->
<rule ref="rulesets/clone.xml/ProperCloneImplementation"/>
<rule ref="rulesets/clone.xml/CloneThrowsCloneNotSupportedException"/>
<rule ref="rulesets/clone.xml/CloneMethodMustImplementCloneable"/>
<!--====================clone Rules end======================-->
<!--====================codesize Rules begin(共11个)======================-->
<!--
<rule ref="rulesets/codesize.xml/NPathComplexity">
<properties>
<property name="minimum" value="200"/>
</properties>
</rule>
-->
<!--
<rule ref="rulesets/codesize.xml/ExcessiveMethodLength">
<properties>
<property name="minimum" value="100"/>
</properties>
</rule>
-->
<rule ref="rulesets/codesize.xml/ExcessiveParameterList">
<properties>
<property name="minimum" value="6"/>
</properties>
</rule>
<!--
<rule ref="rulesets/codesize.xml/ExcessiveClassLength">
<properties>
<property name="minimum" value="1000"/>
</properties>
</rule>
-->
<!--
<rule ref="rulesets/codesize.xml/CyclomaticComplexity">
<properties>
<property name="reportLevel" value="10"/>
property name="showClassesComplexity" value="true"/>
property name="showMethodsComplexity" value="true"/>
</properties>
</rule>
-->
<!--
<rule ref="rulesets/codesize.xml/ExcessivePublicCount">
<properties>
<property name="minimum" value="45"/>
</properties>
</rule>
-->
<!--
<rule ref="rulesets/codesize.xml/TooManyFields">
<properties>
<property name="maxfields" value="15"/>
</properties>
</rule>
-->
<!--
<rule ref="rulesets/codesize.xml/NcssMethodCount">
<properties>
<property name="minimum" value="100"/>
</properties>
</rule>
-->
<!--
<rule ref="rulesets/codesize.xml/NcssTypeCount">
<properties>
<property name="minimum" value="1500"/>
</properties>
</rule>
-->
<!--
<rule ref="rulesets/codesize.xml/NcssConstructorCount">
<properties>
<property name="minimum" value="100"/>
</properties>
</rule>
-->
<!--
<rule ref="rulesets/codesize.xml/TooManyMethods">
<properties>
<property name="maxmethods" value="20"/>
</properties>
</rule>
-->
<!--====================codesize Rules end======================-->
<!--====================controversial Rules begin(共19个)======================-->
<rule ref="rulesets/controversial.xml/UnnecessaryConstructor"/>
<!--rule ref="rulesets/controversial.xml/NullAssignment"/-->
<!--rule ref="rulesets/controversial.xml/OnlyOneReturn"/-->
<!--rule ref="rulesets/controversial.xml/UnusedModifier"/-->
<!--rule ref="rulesets/controversial.xml/AssignmentInOperand"/-->
<!--rule ref="rulesets/controversial.xml/AtLeastOneConstructor"/-->
<rule ref="rulesets/controversial.xml/DontImportSun"/>
<!--rule ref="rulesets/controversial.xml/SuspiciousOctalEscape"/-->
<!--rule ref="rulesets/controversial.xml/CallSuperInConstructor"/-->
<!--rule ref="rulesets/controversial.xml/UnnecessaryParentheses"/-->
<!--rule ref="rulesets/controversial.xml/DefaultPackage"/-->
<!--rule ref="rulesets/controversial.xml/BooleanInversion"/-->
<!--
<rule ref="rulesets/controversial.xml/DataflowAnomalyAnalysis">
<properties>
<property name="maxviolations" value="100"/>
<property name="maxpaths" value="1000"/>
</properties>
</rule>
-->
<!--rule ref="rulesets/controversial.xml/AvoidFinalLocalVariable"/-->
<!--rule ref="rulesets/controversial.xml/AvoidUsingShortType"/-->
<!--rule ref="rulesets/controversial.xml/AvoidUsingVolatile"/-->
<!--rule ref="rulesets/controversial.xml/AvoidUsingNativeCode"/-->
<rule ref="rulesets/controversial.xml/AvoidAccessibilityAlteration"/>
<rule ref="rulesets/controversial.xml/DoNotCallGarbageCollectionExplicitly"/>
<!--====================controversial Rules end======================-->
<!--====================coupling Rules begin(共3个)======================-->
<!--
<rule ref="rulesets/coupling.xml/CouplingBetweenObjects">
<properties>
<property name="threshold" value="20"/>
</properties>
</rule>
-->
<!--
<rule ref="rulesets/coupling.xml/ExcessiveImports">
<properties>
<property name="minimum" value="30"/>
</properties>
</rule>
-->
<rule ref="rulesets/coupling.xml/LooseCoupling"/>
<!--====================coupling Rules end======================-->
<!--====================Design Rules begin(共48个)======================-->
<rule ref="rulesets/design.xml/UseSingleton"/>
<!--如果成员方法都是static,建议使用Singletom模式,或定义成abstract类。(FindBugs不检查)-->
<rule ref="rulesets/design.xml/SimplifyBooleanReturns"/>
<!--避免以下代码
if (bar == x) {
return true;
} else {
return false;
}(FindBugs不检查)
-->
<rule ref="rulesets/design.xml/SimplifyBooleanExpressions"/>
<!--避免以下代码
boolean bar = (isFoo() == true);(FindBugs不检查)
-->
<rule ref="rulesets/design.xml/SwitchStmtsShouldHaveDefault"/>
<!--switch语句应该有一个default。(FindBugs不检查)-->
<rule ref="rulesets/design.xml/AvoidDeeplyNestedIfStmts">
<properties>
<property name="problemDepth" value="5"/>
</properties>
</rule>
<!--避免较深的if语句,注意:有else的不算。(FindBugs不检查)-->
<!--
<rule ref="rulesets/design.xml/AvoidReassigningParameters"/>
-->
<!--避免方法参数未使用就被赋值。(FindBugs检查)-->
<!--不用
<rule ref="rulesets/design.xml/SwitchDensity">
<properties>
<property name="minimum" value="10"/>
</properties>
</rule>
-->
<!--label下的语句太多,建议优化重构。(FindBugs不检查)-->
<!--rule ref="rulesets/design.xml/ConstructorCallsOverridableMethod"/-->
<!-- 在构造方法中调用了可能会被覆盖的成员方法,后果:可能会有空指针错误。(FindBugs不检查) -->
<rule ref="rulesets/design.xml/AccessorClassGeneration"/>
<!-- 避免以下代码,私有构造方法类在类定义外生成实例,这会导致the generation of an accessor。(FindBugs不检查)
public class Outer {
void method(){
Inner ic = new Inner();//Causes generation of accessor class
}
public class Inner {
private Inner(){}
}
}
-->
<rule ref="rulesets/design.xml/FinalFieldCouldBeStatic"/>
<!-- final成员变量(field,类字段)建议定义成static,这样可以节省空间 。(FindBugs不检查)-->
<!--rule ref="rulesets/design.xml/CloseResource"/-->
<!-- Connection,Statement,ResultSet对象使用后要close。(FindBugs不检查) -->
<!--rule ref="rulesets/design.xml/NonStaticInitializer"/-->
<!-- 不建议使用非静态初始化块 ,易引起混乱。(FindBugs不检查)-->
<rule ref="rulesets/design.xml/DefaultLabelNotLastInSwitchStmt"/>
<!-- switch中的default应放在最后一个。(FindBugs不检查)-->
<rule ref="rulesets/design.xml/NonCaseLabelInSwitchStatement"/>
<!-- switch中有非case的label。(FindBugs不检查)-->
<!--rule ref="rulesets/design.xml/OptimizableToArrayCall"/-->
<!-- Collection.toArray(T[] a)调用中new a数组时要指定数组长度。(FindBugs检查)-->
<rule ref="rulesets/design.xml/BadComparison"/>
<!-- 避免与Double.NaN进行是否相等比较(==)。(FindBugs检查)-->
<rule ref="rulesets/design.xml/EqualsNull"/>
<!-- 避免与null比较,如x.equals(null) (FindBugs不检查)-->
<!--
<rule ref="rulesets/design.xml/ConfusingTernary"/>
-->
<!-- 避免if(x!=y),要先if(x==y) (FindBugs不检查)-->
<rule ref="rulesets/design.xml/InstantiationToGetClass"/>
<!-- 为了获得Class对象,请用类的class成员,而不要实例化对象然后getClass (FindBugs检查)-->
<!--rule ref="rulesets/design.xml/IdempotentOperations"/-->
<!-- 避免幂等操作,如变量赋值给它自己 (FindBugs检查)-->
<!--rule ref="rulesets/design.xml/SimpleDateFormatNeedsLocale"/-->
<!-- 生成SimpleDateFormat实例的时候要求指定Locale(FindBugs不检查) -->
<!--rule ref="rulesets/design.xml/ImmutableField"/-->
<!-- field在变量定义时或构造方法中赋值后就再也没有改变过,则可以定义成final的。(FindBugs不检查) -->
<!--rule ref="rulesets/design.xml/UseLocaleWithCaseConversions"/-->
<!-- 在进行大小字转换(String.toLowerCase()/toUpperCase() )的时候请使用Locale,可以避免某些Locale带来的问题(FindBugs检查)-->
<!--rule ref="rulesets/design.xml/AvoidProtectedFieldInFinalClass"/-->
<!-- final类不要出现protected字段(FindBugs检查)-->
<!--rule ref="rulesets/design.xml/AssignmentToNonFinalStatic"/-->
<!-- 赋值给静态非final变量,可能会不安全。在静态区赋值或定义时赋值则没问题。(FindBugs检查)-->
<rule ref="rulesets/design.xml/MissingStaticMethodInNonInstantiatableClass"/>
<!-- 在不能实例化的类里(定义了私有构造方法的类)没有静态方法,这样这个类不可用。(FindBugs不检查)-->
<!--rule ref="rulesets/design.xml/AvoidSynchronizedAtMethodLevel"/-->
<!-- 用块级别的同步代替方法级的同步,这样能够保证让真正需要的代码同步(FindBugs不检查)-->
<!--rule ref="rulesets/design.xml/MissingBreakInSwitch"/-->
<!-- case没有break(FindBugs检查)-->
<rule ref="rulesets/design.xml/UseNotifyAllInsteadOfNotify"/>
<!-- 用notifyAll取代notify(FindBugs检查)-->
<rule ref="rulesets/design.xml/AvoidInstanceofChecksInCatchClause"/>
<!-- 避免在catch子句里再判断具体的异常类型,就是用instanceof。(FindBugs不检查)-->
<!--rule ref="rulesets/design.xml/AbstractClassWithoutAbstractMethod"/-->
<!-- 抽象类没有定义任何抽象方法,如果类仅希望作为基类使用,但又不需要抽象方法,则建议提供一个protected构造方法。(FindBugs不检查)-->
<!--rule ref="rulesets/design.xml/SimplifyConditional"/-->
<!-- 条件表达式中没有必要在instanceof之前进行空指针判断。(FindBugs不检查)-->
<!--rule ref="rulesets/design.xml/CompareObjectsWithEquals"/-->
<!-- 建议用equals对象,而不是用==.(FindBugs检查)-->
<!--rule ref="rulesets/design.xml/PositionLiteralsFirstInComparisons"/-->
<!-- 字符串变量与常量比较时,先写常量,这样可以避免空指针异常。(FindBugs不检查)-->
<!--rule ref="rulesets/design.xml/UnnecessaryLocalBeforeReturn"/-->
<!-- 避免不必要的本地变量。(FindBugs不检查)-->
<!--
<rule ref="rulesets/design.xml/NonThreadSafeSingleton">
<properties>
<property name="checkNonStaticMethods" value="true"/>
<property name="checkNonStaticFields" value="true"/>
</properties>
</rule>
-->
<!-- 线程不安全的Singleton。(FindBugs不检查)-->
<!--rule ref="rulesets/design.xml/UncommentedEmptyMethod"/-->
<!-- 未加注释的空方法,在方法的花括弧之间未加注释。(FindBugs不检查)-->
<!--
<rule ref="rulesets/design.xml/UncommentedEmptyConstructor">
<properties>
<property name="ignoreExplicitConstructorInvocation" value="true"/>
</properties>
</rule>
-->
<!-- 未加注释的空构造方法,在方法的花括弧之间未加注释。注意,在super或this前的注释不算。(FindBugs不检查)-->
<!--rule ref="rulesets/design.xml/AvoidConstantsInterface"/-->
<!-- 避免只有常量的接口定义,可以考虑将其转换成类。(FindBugs不检查)-->
<!--rule ref="rulesets/design.xml/UnsynchronizedStaticDateFormatter"/-->
<!-- 静态SimpleDateFormat成员变量访问未加同步。(FindBugs检查,另外FindBugs不建议定义静态SimpleDateFormat成员变量)-->
<rule ref="rulesets/design.xml/PreserveStackTrace"/>
<!-- catch到了异常后又重新throw新的异常,未保留源异常,源异常的stack trace可能会丢失,不利于程序调试。(FindBugs不检查)-->
<rule ref="rulesets/design.xml/UseCollectionIsEmpty"/>
<!-- 对Collection对象,建议用isEmpty()取代size()与0的判断。(FindBugs不检查)-->
<rule ref="rulesets/design.xml/ClassWithOnlyPrivateConstructorsShouldBeFinal"/>
<!-- 只有私有构造方法的类应该申明为final的,除非构造方法被内部类调用。注,私有构造方法的类能够被它的内部类使用。(FindBugs不检查)-->
<!--
<rule ref="rulesets/design.xml/EmptyMethodInAbstractClassShouldBeAbstract"/>
-->
<!-- 抽象类里的空方法应该定义成abstract。(FindBugs不检查)-->
<!--
<rule ref="rulesets/design.xml/SingularField">
<properties>
<property name="CheckInnerClasses" value="true"/>
<property name="DisallowNotAssignment" value="true"/>
</properties>
</rule>
-->
<!-- 某个类字段仅在一个方法中使用,建议改用本地变量。构造方法中有赋值不算,但定义时有初始值算。(FindBugs不检查)-->
<rule ref="rulesets/design.xml/ReturnEmptyArrayRatherThanNull"/>
<!-- 返回空数组,而不是null。(FindBugs检查)-->
<!--rule ref="rulesets/design.xml/AbstractClassWithoutAnyMethod"/-->
<!-- 如果一个抽象类不包含任何方法,只有数据字段,则建议定义private或protected的构造方法以不允许实例化。(FindBugs不检查)-->
<rule ref="rulesets/design.xml/TooFewBranchesForASwitchStatement"/>
<!--
<properties>
<property name="minimumNumberCaseForASwitch" value="3"/>
</properties>
-->
<!-- switch的case语句如果太少的话建议用if取代,以增加代码可读性。(FindBugs不检查)-->
<!--====================Design Rules end======================-->
<!--====================finalizers Rules begin(共6个)======================-->
<rule ref="rulesets/finalizers.xml/EmptyFinalizer"/>
<rule ref="rulesets/finalizers.xml/FinalizeOnlyCallsSuperFinalize"/>
<rule ref="rulesets/finalizers.xml/FinalizeOverloaded"/>
<rule ref="rulesets/finalizers.xml/FinalizeDoesNotCallSuperFinalize"/>
<!--rule ref="rulesets/finalizers.xml/FinalizeShouldBeProtected"/-->
<rule ref="rulesets/finalizers.xml/AvoidCallingFinalize"/>
<!--====================finalizers Rules end======================-->
<!--====================imports Rules begin(共5个)======================-->
<rule ref="rulesets/imports.xml/DuplicateImports"/>
<rule ref="rulesets/imports.xml/DontImportJavaLang"/>
<rule ref="rulesets/imports.xml/UnusedImports"/>
<rule ref="rulesets/imports.xml/ImportFromSamePackage"/>
<!--
<rule ref="rulesets/imports.xml/TooManyStaticImports">
<properties>
<property name="maximumStaticImports" value="4"/>
</properties>
</rule>
-->
<!--====================imports Rules end======================-->
<!--====================j2ee Rules begin(共9个)======================-->
<!--rule ref="rulesets/j2ee.xml/UseProperClassLoader"/-->
<!--rule ref="rulesets/j2ee.xml/MDBAndSessionBeanNamingConvention"/-->
<!--rule ref="rulesets/j2ee.xml/RemoteSessionInterfaceNamingConvention"/-->
<!--rule ref="rulesets/j2ee.xml/LocalInterfaceSessionNamingConvention"/-->
<!--rule ref="rulesets/j2ee.xml/LocalHomeNamingConvention"/-->
<!--rule ref="rulesets/j2ee.xml/RemoteInterfaceNamingConvention"/-->
<!--rule ref="rulesets/j2ee.xml/DoNotCallSystemExit"/-->
<!--rule ref="rulesets/j2ee.xml/StaticEJBFieldShouldBeFinal"/-->
<!--rule ref="rulesets/j2ee.xml/DoNotUseThreads"/-->
<!--====================j2ee Rules end======================-->
<!--====================logging-jakarta-commons Rules begin(共2个)======================-->
<!--rule ref="rulesets/logging-jakarta-commons.xml/UseCorrectExceptionLogging"/-->
<!--
<rule ref="rulesets/logging-jakarta-commons.xml/ProperLogger">
<properties>
<property name="staticLoggerName" value="log"/>
</properties>
</rule>
-->
<!--====================logging-jakarta-commons Rules end======================-->
<!--====================logging-java Rules begin(共4个)======================-->
<rule ref="rulesets/logging-java.xml/MoreThanOneLogger"/>
<!--rule ref="rulesets/logging-java.xml/LoggerIsNotStaticFinal"/-->
<rule ref="rulesets/logging-java.xml/SystemPrintln"/>
<rule ref="rulesets/logging-java.xml/AvoidPrintStackTrace"/>
<!--====================logging-java Rules end======================-->
<!--====================naming Rules begin(共18个)======================-->
<!--rule ref="rulesets/naming.xml/ShortVariable"/-->
<!--
<rule ref="rulesets/naming.xml/LongVariable">
<properties>
<property name="minimum" value="40"/>
</properties>
</rule>
-->
<rule ref="rulesets/naming.xml/ShortMethodName"/>
<rule ref="rulesets/naming.xml/VariableNamingConventions"/>
<rule ref="rulesets/naming.xml/MethodNamingConventions"/>
<rule ref="rulesets/naming.xml/ClassNamingConventions"/>
<!--rule ref="rulesets/naming.xml/AbstractNaming"/-->
<rule ref="rulesets/naming.xml/AvoidDollarSigns"/>
<rule ref="rulesets/naming.xml/MethodWithSameNameAsEnclosingClass"/>
<rule ref="rulesets/naming.xml/SuspiciousHashcodeMethodName"/>
<rule ref="rulesets/naming.xml/SuspiciousConstantFieldName"/>
<rule ref="rulesets/naming.xml/SuspiciousEqualsMethodName"/>
<rule ref="rulesets/naming.xml/AvoidFieldNameMatchingTypeName"/>
<rule ref="rulesets/naming.xml/AvoidFieldNameMatchingMethodName"/>
<rule ref="rulesets/naming.xml/NoPackage"/>
<rule ref="rulesets/naming.xml/PackageCase"/>
<rule ref="rulesets/naming.xml/MisleadingVariableName"/>
<rule ref="rulesets/naming.xml/BooleanGetMethodName">
<properties>
<property name="checkParameterizedMethods" value="false"/>
</properties>
</rule>
<!--====================naming Rules end======================-->
<!--====================optimization Rules begin(共10个)======================-->
<!--rule ref="rulesets/optimizations.xml/LocalVariableCouldBeFinal"/-->
<!--rule ref="rulesets/optimizations.xml/MethodArgumentCouldBeFinal"/-->
<!--rule ref="rulesets/optimizations.xml/AvoidInstantiatingObjectsInLoops"/-->
<rule ref="rulesets/optimizations.xml/UseArrayListInsteadOfVector"/>
<!--rule ref="rulesets/optimizations.xml/SimplifyStartsWith"/-->
<!--rule ref="rulesets/optimizations.xml/UseStringBufferForStringAppends"/-->
<rule ref="rulesets/optimizations.xml/UseArraysAsList"/>
<rule ref="rulesets/optimizations.xml/AvoidArrayLoops"/>
<rule ref="rulesets/optimizations.xml/UnnecessaryWrapperObjectCreation"/>
<!--rule ref="rulesets/optimizations.xml/AddEmptyString"/-->
<!--====================optimization Rules end======================-->
<!--====================strictexception Rules begin(共9个)======================-->
<rule ref="rulesets/strictexception.xml/AvoidCatchingThrowable"/>
<rule ref="rulesets/strictexception.xml/SignatureDeclareThrowsException"/>
<rule ref="rulesets/strictexception.xml/ExceptionAsFlowControl"/>
<rule ref="rulesets/strictexception.xml/AvoidCatchingNPE"/>
<rule ref="rulesets/strictexception.xml/AvoidThrowingRawExceptionTypes"/>
<!--rule ref="rulesets/strictexception.xml/AvoidThrowingNullPointerException"/-->
<rule ref="rulesets/strictexception.xml/AvoidRethrowingException"/>
<rule ref="rulesets/strictexception.xml/DoNotExtendJavaLangError"/>
<rule ref="rulesets/strictexception.xml/DoNotThrowExceptionInFinally"/>
<!--====================strictexception Rules end======================-->
<!--====================sunsecure Rules begin(共2个)======================-->
<!--rule ref="rulesets/sunsecure.xml/MethodReturnsInternalArray"/-->
<!--rule ref="rulesets/sunsecure.xml/ArrayIsStoredDirectly"/-->
<!--====================sunsecure Rules end======================-->
<!--====================strings Rules begin(共15个)======================-->
<!--
<rule ref="rulesets/strings.xml/AvoidDuplicateLiterals">
<properties>
<property name="threshold" value="4"/>
</properties>
</rule>
-->
<rule ref="rulesets/strings.xml/StringInstantiation"/>
<rule ref="rulesets/strings.xml/StringToString"/>
<!--rule ref="rulesets/strings.xml/InefficientStringBuffering"/-->
<rule ref="rulesets/strings.xml/UnnecessaryCaseChange"/>
<rule ref="rulesets/strings.xml/UseStringBufferLength"/>
<rule ref="rulesets/strings.xml/AppendCharacterWithChar"/>
<!--
<rule ref="rulesets/strings.xml/ConsecutiveLiteralAppends">
<properties>
<property name="threshold" value="1"/>
</properties>
</rule>
-->
<!--rule ref="rulesets/strings.xml/UseIndexOfChar"/-->
<!--rule ref="rulesets/strings.xml/InefficientEmptyStringCheck"/-->
<!--rule ref="rulesets/strings.xml/InsufficientStringBufferDeclaration"/-->
<rule ref="rulesets/strings.xml/UselessStringValueOf"/>
<rule ref="rulesets/strings.xml/StringBufferInstantiationWithChar"/>
<rule ref="rulesets/strings.xml/UseEqualsToCompareStrings"/>
<!--rule ref="rulesets/strings.xml/AvoidStringBufferField"/-->
<!--====================strings Rules end======================-->
<!--====================unusedcode Rules begin(共4个)======================-->
<rule ref="rulesets/unusedcode.xml/UnusedPrivateField"/>
<rule ref="rulesets/unusedcode.xml/UnusedLocalVariable"/>
<rule ref="rulesets/unusedcode.xml/UnusedPrivateMethod"/>
<rule ref="rulesets/unusedcode.xml/UnusedFormalParameter"/>
<!--====================unusedcode Rules end======================-->
</ruleset>
<ruleset name="Favorites"
xmlns="http://pmd.sf.net/ruleset/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://pmd.sf.net/ruleset/1.0.0 http://pmd.sf.net/ruleset_xml_schema.xsd"
xsi:noNamespaceSchemaLocation="http://pmd.sf.net/ruleset_xml_schema.xsd">
<description>
规则版本号:V1.2(2008-11-04)
去除规则AvoidUsingHardCodedIP
增加规则-------级别为3----------------------------------
EmptyStaticInitializer、EmptyStatementNotInLoop、UnnecessaryFinalModifier、
ExcessiveParameterList、UnnecessaryConstructor、DontImportSun、UseSingleton、
AvoidDeeplyNestedIfStmts、DefaultLabelNotLastInSwitchStmt、NonCaseLabelInSwitchStatement、
AvoidInstanceofChecksInCatchClause、SimplifyConditional、AvoidCallingFinalize、
DontImportJavaLang、ImportFromSamePackage、BooleanGetMethodName、
SignatureDeclareThrowsException、AvoidThrowingRawExceptionTypes、DoNotExtendJavaLangError
-------级别为4----------------------------------
OverrideBothEqualsAndHashcode、EmptySynchronizedBlock、UselessOperationOnImmutable、
MisplacedNullCheck、BrokenNullCheck、IfStmtsMustUseBraces、WhileLoopsMustUseBraces、
IfElseStmtsMustUseBraces、ForLoopsMustUseBraces、AvoidAccessibilityAlteration、
DoNotCallGarbageCollectionExplicitly、BadComparison、InstantiationToGetClass、
UseNotifyAllInsteadOfNotify、ReturnEmptyArrayRatherThanNull、StringInstantiation、
StringToString、UseEqualsToCompareStrings、UnusedPrivateField、UnusedPrivateMethod
规则版本号:V1.1(2008-08-13)
去除规则ShortVariable
规则版本号:V1.0(2008-08-11)
推荐指数是4、5级的规则。
</description>
<!--====================Basic Rules begin(共33个)======================-->
<rule ref="rulesets/basic.xml/EmptyCatchBlock">
<properties>
<property name="allowCommentedBlocks" value="false"/>
</properties>
</rule>
<!--不允许出现空的catch块,避免屏蔽异常,不处理或不报告异常。(FindBugs不检查)-->
<rule ref="rulesets/basic.xml/EmptyIfStmt"/>
<!--不允许有空if语句块(或空else块)。(FindBugs不检查)-->
<rule ref="rulesets/basic.xml/EmptyWhileStmt"/>
<!--不允许有空while循环块。注意:不包括do循环。(FindBugs不检查)-->
<rule ref="rulesets/basic.xml/EmptyTryBlock"/>
<!--不允许有空try块。(FindBugs不检查)-->
<rule ref="rulesets/basic.xml/EmptyFinallyBlock"/>
<!--不允许有空finally块。(FindBugs不检查)-->
<rule ref="rulesets/basic.xml/EmptySwitchStatements"/>
<!--不允许有空switch块。与这个规则重复:rulesets/design.xml/SwitchStmtsShouldHaveDefault、MissingBreakInSwitch。(FindBugs不检查)-->
<rule ref="rulesets/basic.xml/JumbledIncrementer"/>
<!--避免混乱的循环变量赋值(避免在内循环里修改外循环变量)。与这个规则有点重复:rulesets/controversial.xml/DataflowAnomalyAnalysis。(FindBugs不检查)-->
<!--rule ref="rulesets/basic.xml/ForLoopShouldBeWhileLoop"/-->
<!--简单的for循环可以用while循环取代。(FindBugs不检查,注,FindBugs能发现死循环)-->
<!--rule ref="rulesets/basic.xml/UnnecessaryConversionTemporary"/-->
<!--当基本型数据转换成String时,避免不必要的临时对象。(FindBugs检查)-->
<rule ref="rulesets/basic.xml/OverrideBothEqualsAndHashcode"/>
<!--equals和hashcode同时定义。(FindBugs检查)-->
<!--rule ref="rulesets/basic.xml/DoubleCheckedLocking"/-->
<!--doublecheck问题。(FindBugs检查)-->
<rule ref="rulesets/basic.xml/ReturnFromFinallyBlock"/>
<!--禁止在finally块里return,避免屏蔽异常。(FindBugs不检查)-->
<rule ref="rulesets/basic.xml/EmptySynchronizedBlock"/>
<!--避免空的同步块。(FindBugs检查)-->
<!--rule ref="rulesets/basic.xml/UnnecessaryReturn"/-->
<!--方法返回值void,避免不必要的return。(FindBugs不检查)-->
<rule ref="rulesets/basic.xml/EmptyStaticInitializer"/>
<!--空的static初始化。(FindBugs不检查)-->
<rule ref="rulesets/basic.xml/UnconditionalIfStatement"/>
<!--if语句的条件始终是true或false。(FindBugs不检查)-->
<rule ref="rulesets/basic.xml/EmptyStatementNotInLoop"/>
<!--出现了空语句(就一个分号),如果在循环里则可以。(FindBugs不检查)-->
<rule ref="rulesets/basic.xml/BooleanInstantiation"/>
<!--避免实例化Boolean对象,而应用常量Boolean.TRUE, Boolean.FALSE。(FindBugs只检查构造方法生成对象的情况,不检查valueOf)-->
<rule ref="rulesets/basic.xml/UnnecessaryFinalModifier"/>
<!--当一个类定义成final后,它所有的方法自动final。(FindBugs不检查)-->
<!--rule ref="rulesets/basic.xml/CollapsibleIfStatements"/-->
<!--内嵌的if语句能够和外层的if语句合并成一个if语句。(FindBugs不检查)-->
<!--rule ref="rulesets/basic.xml/UselessOverridingMethod"/-->
<!--被覆盖的方法仅仅调用了基类的方法。(FindBugs检查)-->
<rule ref="rulesets/basic.xml/ClassCastExceptionWithToArray"/>
<!--Collection.toArray调用转换成数组,应主动传一个明确类型的数组对象,否则运行时会抛ClassCastException异常。相似规则:rulesets/design.xml/OptimizableToArrayCall。(FindBugs不检查)-->
<rule ref="rulesets/basic.xml/AvoidDecimalLiteralsInBigDecimalConstructor"/>
<!--new BigDecimal建议用String参数的构造方法,而不是十进制小数常量(整数除外)。(FindBugs不检查)-->
<rule ref="rulesets/basic.xml/UselessOperationOnImmutable"/>
<!--不可变对象(如BigDecimal、BigInteger)上的操作结果被忽略。(FindBugs检查)-->
<rule ref="rulesets/basic.xml/MisplacedNullCheck"/>
<!--空指针判断放错了位置。要么之前已报空指针,要么此处永远不可能是空指针。(FindBugs检查)-->
<!--rule ref="rulesets/basic.xml/UnusedNullCheckInEquals"/-->
<!--在判断了对象是否是空指针后,后面紧接着调用该对象的equals方法,而不是将对象作为另一个对象的equals参数。(FindBugs不检查)-->
<!--rule ref="rulesets/basic.xml/AvoidThreadGroup"/-->
<!--不建议用ThreadGroup,因为它的方法不是线程安全的。(FindBugs不检查)-->
<rule ref="rulesets/basic.xml/BrokenNullCheck"/>
<!--应该用&&取代||或反之。(FindBugs检查)-->
<rule ref="rulesets/basic.xml/BigIntegerInstantiation"/>
<!--不要再创建已经有的对象(BigDecimal.ZERO, BigDecimal.ONE, BigDecimal.TEN)。(FindBugs不检查)-->
<!--rule ref="rulesets/basic.xml/AvoidUsingOctalValues"/-->
<!--避免使用八进制值。(FindBugs不检查)-->
<!--
<rule ref="rulesets/basic.xml/AvoidUsingHardCodedIP">
<properties>
<property name="pattern" value=""/>
</properties>
</rule>
-->
<!--避免硬编码IPv4和IPv6,以免在某些情况下变的不可能布署。(FindBugs不检查)-->
<rule ref="rulesets/basic.xml/CheckResultSet"/>
<!--对ResultSet的方法(next,previous,first,last)调用结果要进行是否是真的判断。(FindBugs不检查)-->
<rule ref="rulesets/basic.xml/AvoidMultipleUnaryOperators"/>
<!--避免多个一元操作符,要么是一个错误,要么易引起混淆。(FindBugs不检查)-->
<!--====================Basic Rules end======================-->
<!--====================braces Rules begin(共4个)======================-->
<rule ref="rulesets/braces.xml/IfStmtsMustUseBraces"/>
<rule ref="rulesets/braces.xml/WhileLoopsMustUseBraces"/>
<rule ref="rulesets/braces.xml/IfElseStmtsMustUseBraces"/>
<rule ref="rulesets/braces.xml/ForLoopsMustUseBraces"/>
<!--====================braces Rules end======================-->
<!--====================clone Rules begin(共3个)======================-->
<rule ref="rulesets/clone.xml/ProperCloneImplementation"/>
<rule ref="rulesets/clone.xml/CloneThrowsCloneNotSupportedException"/>
<rule ref="rulesets/clone.xml/CloneMethodMustImplementCloneable"/>
<!--====================clone Rules end======================-->
<!--====================codesize Rules begin(共11个)======================-->
<!--
<rule ref="rulesets/codesize.xml/NPathComplexity">
<properties>
<property name="minimum" value="200"/>
</properties>
</rule>
-->
<!--
<rule ref="rulesets/codesize.xml/ExcessiveMethodLength">
<properties>
<property name="minimum" value="100"/>
</properties>
</rule>
-->
<rule ref="rulesets/codesize.xml/ExcessiveParameterList">
<properties>
<property name="minimum" value="6"/>
</properties>
</rule>
<!--
<rule ref="rulesets/codesize.xml/ExcessiveClassLength">
<properties>
<property name="minimum" value="1000"/>
</properties>
</rule>
-->
<!--
<rule ref="rulesets/codesize.xml/CyclomaticComplexity">
<properties>
<property name="reportLevel" value="10"/>
property name="showClassesComplexity" value="true"/>
property name="showMethodsComplexity" value="true"/>
</properties>
</rule>
-->
<!--
<rule ref="rulesets/codesize.xml/ExcessivePublicCount">
<properties>
<property name="minimum" value="45"/>
</properties>
</rule>
-->
<!--
<rule ref="rulesets/codesize.xml/TooManyFields">
<properties>
<property name="maxfields" value="15"/>
</properties>
</rule>
-->
<!--
<rule ref="rulesets/codesize.xml/NcssMethodCount">
<properties>
<property name="minimum" value="100"/>
</properties>
</rule>
-->
<!--
<rule ref="rulesets/codesize.xml/NcssTypeCount">
<properties>
<property name="minimum" value="1500"/>
</properties>
</rule>
-->
<!--
<rule ref="rulesets/codesize.xml/NcssConstructorCount">
<properties>
<property name="minimum" value="100"/>
</properties>
</rule>
-->
<!--
<rule ref="rulesets/codesize.xml/TooManyMethods">
<properties>
<property name="maxmethods" value="20"/>
</properties>
</rule>
-->
<!--====================codesize Rules end======================-->
<!--====================controversial Rules begin(共19个)======================-->
<rule ref="rulesets/controversial.xml/UnnecessaryConstructor"/>
<!--rule ref="rulesets/controversial.xml/NullAssignment"/-->
<!--rule ref="rulesets/controversial.xml/OnlyOneReturn"/-->
<!--rule ref="rulesets/controversial.xml/UnusedModifier"/-->
<!--rule ref="rulesets/controversial.xml/AssignmentInOperand"/-->
<!--rule ref="rulesets/controversial.xml/AtLeastOneConstructor"/-->
<rule ref="rulesets/controversial.xml/DontImportSun"/>
<!--rule ref="rulesets/controversial.xml/SuspiciousOctalEscape"/-->
<!--rule ref="rulesets/controversial.xml/CallSuperInConstructor"/-->
<!--rule ref="rulesets/controversial.xml/UnnecessaryParentheses"/-->
<!--rule ref="rulesets/controversial.xml/DefaultPackage"/-->
<!--rule ref="rulesets/controversial.xml/BooleanInversion"/-->
<!--
<rule ref="rulesets/controversial.xml/DataflowAnomalyAnalysis">
<properties>
<property name="maxviolations" value="100"/>
<property name="maxpaths" value="1000"/>
</properties>
</rule>
-->
<!--rule ref="rulesets/controversial.xml/AvoidFinalLocalVariable"/-->
<!--rule ref="rulesets/controversial.xml/AvoidUsingShortType"/-->
<!--rule ref="rulesets/controversial.xml/AvoidUsingVolatile"/-->
<!--rule ref="rulesets/controversial.xml/AvoidUsingNativeCode"/-->
<rule ref="rulesets/controversial.xml/AvoidAccessibilityAlteration"/>
<rule ref="rulesets/controversial.xml/DoNotCallGarbageCollectionExplicitly"/>
<!--====================controversial Rules end======================-->
<!--====================coupling Rules begin(共3个)======================-->
<!--
<rule ref="rulesets/coupling.xml/CouplingBetweenObjects">
<properties>
<property name="threshold" value="20"/>
</properties>
</rule>
-->
<!--
<rule ref="rulesets/coupling.xml/ExcessiveImports">
<properties>
<property name="minimum" value="30"/>
</properties>
</rule>
-->
<rule ref="rulesets/coupling.xml/LooseCoupling"/>
<!--====================coupling Rules end======================-->
<!--====================Design Rules begin(共48个)======================-->
<rule ref="rulesets/design.xml/UseSingleton"/>
<!--如果成员方法都是static,建议使用Singletom模式,或定义成abstract类。(FindBugs不检查)-->
<rule ref="rulesets/design.xml/SimplifyBooleanReturns"/>
<!--避免以下代码
if (bar == x) {
return true;
} else {
return false;
}(FindBugs不检查)
-->
<rule ref="rulesets/design.xml/SimplifyBooleanExpressions"/>
<!--避免以下代码
boolean bar = (isFoo() == true);(FindBugs不检查)
-->
<rule ref="rulesets/design.xml/SwitchStmtsShouldHaveDefault"/>
<!--switch语句应该有一个default。(FindBugs不检查)-->
<rule ref="rulesets/design.xml/AvoidDeeplyNestedIfStmts">
<properties>
<property name="problemDepth" value="5"/>
</properties>
</rule>
<!--避免较深的if语句,注意:有else的不算。(FindBugs不检查)-->
<!--
<rule ref="rulesets/design.xml/AvoidReassigningParameters"/>
-->
<!--避免方法参数未使用就被赋值。(FindBugs检查)-->
<!--不用
<rule ref="rulesets/design.xml/SwitchDensity">
<properties>
<property name="minimum" value="10"/>
</properties>
</rule>
-->
<!--label下的语句太多,建议优化重构。(FindBugs不检查)-->
<!--rule ref="rulesets/design.xml/ConstructorCallsOverridableMethod"/-->
<!-- 在构造方法中调用了可能会被覆盖的成员方法,后果:可能会有空指针错误。(FindBugs不检查) -->
<rule ref="rulesets/design.xml/AccessorClassGeneration"/>
<!-- 避免以下代码,私有构造方法类在类定义外生成实例,这会导致the generation of an accessor。(FindBugs不检查)
public class Outer {
void method(){
Inner ic = new Inner();//Causes generation of accessor class
}
public class Inner {
private Inner(){}
}
}
-->
<rule ref="rulesets/design.xml/FinalFieldCouldBeStatic"/>
<!-- final成员变量(field,类字段)建议定义成static,这样可以节省空间 。(FindBugs不检查)-->
<!--rule ref="rulesets/design.xml/CloseResource"/-->
<!-- Connection,Statement,ResultSet对象使用后要close。(FindBugs不检查) -->
<!--rule ref="rulesets/design.xml/NonStaticInitializer"/-->
<!-- 不建议使用非静态初始化块 ,易引起混乱。(FindBugs不检查)-->
<rule ref="rulesets/design.xml/DefaultLabelNotLastInSwitchStmt"/>
<!-- switch中的default应放在最后一个。(FindBugs不检查)-->
<rule ref="rulesets/design.xml/NonCaseLabelInSwitchStatement"/>
<!-- switch中有非case的label。(FindBugs不检查)-->
<!--rule ref="rulesets/design.xml/OptimizableToArrayCall"/-->
<!-- Collection.toArray(T[] a)调用中new a数组时要指定数组长度。(FindBugs检查)-->
<rule ref="rulesets/design.xml/BadComparison"/>
<!-- 避免与Double.NaN进行是否相等比较(==)。(FindBugs检查)-->
<rule ref="rulesets/design.xml/EqualsNull"/>
<!-- 避免与null比较,如x.equals(null) (FindBugs不检查)-->
<!--
<rule ref="rulesets/design.xml/ConfusingTernary"/>
-->
<!-- 避免if(x!=y),要先if(x==y) (FindBugs不检查)-->
<rule ref="rulesets/design.xml/InstantiationToGetClass"/>
<!-- 为了获得Class对象,请用类的class成员,而不要实例化对象然后getClass (FindBugs检查)-->
<!--rule ref="rulesets/design.xml/IdempotentOperations"/-->
<!-- 避免幂等操作,如变量赋值给它自己 (FindBugs检查)-->
<!--rule ref="rulesets/design.xml/SimpleDateFormatNeedsLocale"/-->
<!-- 生成SimpleDateFormat实例的时候要求指定Locale(FindBugs不检查) -->
<!--rule ref="rulesets/design.xml/ImmutableField"/-->
<!-- field在变量定义时或构造方法中赋值后就再也没有改变过,则可以定义成final的。(FindBugs不检查) -->
<!--rule ref="rulesets/design.xml/UseLocaleWithCaseConversions"/-->
<!-- 在进行大小字转换(String.toLowerCase()/toUpperCase() )的时候请使用Locale,可以避免某些Locale带来的问题(FindBugs检查)-->
<!--rule ref="rulesets/design.xml/AvoidProtectedFieldInFinalClass"/-->
<!-- final类不要出现protected字段(FindBugs检查)-->
<!--rule ref="rulesets/design.xml/AssignmentToNonFinalStatic"/-->
<!-- 赋值给静态非final变量,可能会不安全。在静态区赋值或定义时赋值则没问题。(FindBugs检查)-->
<rule ref="rulesets/design.xml/MissingStaticMethodInNonInstantiatableClass"/>
<!-- 在不能实例化的类里(定义了私有构造方法的类)没有静态方法,这样这个类不可用。(FindBugs不检查)-->
<!--rule ref="rulesets/design.xml/AvoidSynchronizedAtMethodLevel"/-->
<!-- 用块级别的同步代替方法级的同步,这样能够保证让真正需要的代码同步(FindBugs不检查)-->
<!--rule ref="rulesets/design.xml/MissingBreakInSwitch"/-->
<!-- case没有break(FindBugs检查)-->
<rule ref="rulesets/design.xml/UseNotifyAllInsteadOfNotify"/>
<!-- 用notifyAll取代notify(FindBugs检查)-->
<rule ref="rulesets/design.xml/AvoidInstanceofChecksInCatchClause"/>
<!-- 避免在catch子句里再判断具体的异常类型,就是用instanceof。(FindBugs不检查)-->
<!--rule ref="rulesets/design.xml/AbstractClassWithoutAbstractMethod"/-->
<!-- 抽象类没有定义任何抽象方法,如果类仅希望作为基类使用,但又不需要抽象方法,则建议提供一个protected构造方法。(FindBugs不检查)-->
<!--rule ref="rulesets/design.xml/SimplifyConditional"/-->
<!-- 条件表达式中没有必要在instanceof之前进行空指针判断。(FindBugs不检查)-->
<!--rule ref="rulesets/design.xml/CompareObjectsWithEquals"/-->
<!-- 建议用equals对象,而不是用==.(FindBugs检查)-->
<!--rule ref="rulesets/design.xml/PositionLiteralsFirstInComparisons"/-->
<!-- 字符串变量与常量比较时,先写常量,这样可以避免空指针异常。(FindBugs不检查)-->
<!--rule ref="rulesets/design.xml/UnnecessaryLocalBeforeReturn"/-->
<!-- 避免不必要的本地变量。(FindBugs不检查)-->
<!--
<rule ref="rulesets/design.xml/NonThreadSafeSingleton">
<properties>
<property name="checkNonStaticMethods" value="true"/>
<property name="checkNonStaticFields" value="true"/>
</properties>
</rule>
-->
<!-- 线程不安全的Singleton。(FindBugs不检查)-->
<!--rule ref="rulesets/design.xml/UncommentedEmptyMethod"/-->
<!-- 未加注释的空方法,在方法的花括弧之间未加注释。(FindBugs不检查)-->
<!--
<rule ref="rulesets/design.xml/UncommentedEmptyConstructor">
<properties>
<property name="ignoreExplicitConstructorInvocation" value="true"/>
</properties>
</rule>
-->
<!-- 未加注释的空构造方法,在方法的花括弧之间未加注释。注意,在super或this前的注释不算。(FindBugs不检查)-->
<!--rule ref="rulesets/design.xml/AvoidConstantsInterface"/-->
<!-- 避免只有常量的接口定义,可以考虑将其转换成类。(FindBugs不检查)-->
<!--rule ref="rulesets/design.xml/UnsynchronizedStaticDateFormatter"/-->
<!-- 静态SimpleDateFormat成员变量访问未加同步。(FindBugs检查,另外FindBugs不建议定义静态SimpleDateFormat成员变量)-->
<rule ref="rulesets/design.xml/PreserveStackTrace"/>
<!-- catch到了异常后又重新throw新的异常,未保留源异常,源异常的stack trace可能会丢失,不利于程序调试。(FindBugs不检查)-->
<rule ref="rulesets/design.xml/UseCollectionIsEmpty"/>
<!-- 对Collection对象,建议用isEmpty()取代size()与0的判断。(FindBugs不检查)-->
<rule ref="rulesets/design.xml/ClassWithOnlyPrivateConstructorsShouldBeFinal"/>
<!-- 只有私有构造方法的类应该申明为final的,除非构造方法被内部类调用。注,私有构造方法的类能够被它的内部类使用。(FindBugs不检查)-->
<!--
<rule ref="rulesets/design.xml/EmptyMethodInAbstractClassShouldBeAbstract"/>
-->
<!-- 抽象类里的空方法应该定义成abstract。(FindBugs不检查)-->
<!--
<rule ref="rulesets/design.xml/SingularField">
<properties>
<property name="CheckInnerClasses" value="true"/>
<property name="DisallowNotAssignment" value="true"/>
</properties>
</rule>
-->
<!-- 某个类字段仅在一个方法中使用,建议改用本地变量。构造方法中有赋值不算,但定义时有初始值算。(FindBugs不检查)-->
<rule ref="rulesets/design.xml/ReturnEmptyArrayRatherThanNull"/>
<!-- 返回空数组,而不是null。(FindBugs检查)-->
<!--rule ref="rulesets/design.xml/AbstractClassWithoutAnyMethod"/-->
<!-- 如果一个抽象类不包含任何方法,只有数据字段,则建议定义private或protected的构造方法以不允许实例化。(FindBugs不检查)-->
<rule ref="rulesets/design.xml/TooFewBranchesForASwitchStatement"/>
<!--
<properties>
<property name="minimumNumberCaseForASwitch" value="3"/>
</properties>
-->
<!-- switch的case语句如果太少的话建议用if取代,以增加代码可读性。(FindBugs不检查)-->
<!--====================Design Rules end======================-->
<!--====================finalizers Rules begin(共6个)======================-->
<rule ref="rulesets/finalizers.xml/EmptyFinalizer"/>
<rule ref="rulesets/finalizers.xml/FinalizeOnlyCallsSuperFinalize"/>
<rule ref="rulesets/finalizers.xml/FinalizeOverloaded"/>
<rule ref="rulesets/finalizers.xml/FinalizeDoesNotCallSuperFinalize"/>
<!--rule ref="rulesets/finalizers.xml/FinalizeShouldBeProtected"/-->
<rule ref="rulesets/finalizers.xml/AvoidCallingFinalize"/>
<!--====================finalizers Rules end======================-->
<!--====================imports Rules begin(共5个)======================-->
<rule ref="rulesets/imports.xml/DuplicateImports"/>
<rule ref="rulesets/imports.xml/DontImportJavaLang"/>
<rule ref="rulesets/imports.xml/UnusedImports"/>
<rule ref="rulesets/imports.xml/ImportFromSamePackage"/>
<!--
<rule ref="rulesets/imports.xml/TooManyStaticImports">
<properties>
<property name="maximumStaticImports" value="4"/>
</properties>
</rule>
-->
<!--====================imports Rules end======================-->
<!--====================j2ee Rules begin(共9个)======================-->
<!--rule ref="rulesets/j2ee.xml/UseProperClassLoader"/-->
<!--rule ref="rulesets/j2ee.xml/MDBAndSessionBeanNamingConvention"/-->
<!--rule ref="rulesets/j2ee.xml/RemoteSessionInterfaceNamingConvention"/-->
<!--rule ref="rulesets/j2ee.xml/LocalInterfaceSessionNamingConvention"/-->
<!--rule ref="rulesets/j2ee.xml/LocalHomeNamingConvention"/-->
<!--rule ref="rulesets/j2ee.xml/RemoteInterfaceNamingConvention"/-->
<!--rule ref="rulesets/j2ee.xml/DoNotCallSystemExit"/-->
<!--rule ref="rulesets/j2ee.xml/StaticEJBFieldShouldBeFinal"/-->
<!--rule ref="rulesets/j2ee.xml/DoNotUseThreads"/-->
<!--====================j2ee Rules end======================-->
<!--====================logging-jakarta-commons Rules begin(共2个)======================-->
<!--rule ref="rulesets/logging-jakarta-commons.xml/UseCorrectExceptionLogging"/-->
<!--
<rule ref="rulesets/logging-jakarta-commons.xml/ProperLogger">
<properties>
<property name="staticLoggerName" value="log"/>
</properties>
</rule>
-->
<!--====================logging-jakarta-commons Rules end======================-->
<!--====================logging-java Rules begin(共4个)======================-->
<rule ref="rulesets/logging-java.xml/MoreThanOneLogger"/>
<!--rule ref="rulesets/logging-java.xml/LoggerIsNotStaticFinal"/-->
<rule ref="rulesets/logging-java.xml/SystemPrintln"/>
<rule ref="rulesets/logging-java.xml/AvoidPrintStackTrace"/>
<!--====================logging-java Rules end======================-->
<!--====================naming Rules begin(共18个)======================-->
<!--rule ref="rulesets/naming.xml/ShortVariable"/-->
<!--
<rule ref="rulesets/naming.xml/LongVariable">
<properties>
<property name="minimum" value="40"/>
</properties>
</rule>
-->
<rule ref="rulesets/naming.xml/ShortMethodName"/>
<rule ref="rulesets/naming.xml/VariableNamingConventions"/>
<rule ref="rulesets/naming.xml/MethodNamingConventions"/>
<rule ref="rulesets/naming.xml/ClassNamingConventions"/>
<!--rule ref="rulesets/naming.xml/AbstractNaming"/-->
<rule ref="rulesets/naming.xml/AvoidDollarSigns"/>
<rule ref="rulesets/naming.xml/MethodWithSameNameAsEnclosingClass"/>
<rule ref="rulesets/naming.xml/SuspiciousHashcodeMethodName"/>
<rule ref="rulesets/naming.xml/SuspiciousConstantFieldName"/>
<rule ref="rulesets/naming.xml/SuspiciousEqualsMethodName"/>
<rule ref="rulesets/naming.xml/AvoidFieldNameMatchingTypeName"/>
<rule ref="rulesets/naming.xml/AvoidFieldNameMatchingMethodName"/>
<rule ref="rulesets/naming.xml/NoPackage"/>
<rule ref="rulesets/naming.xml/PackageCase"/>
<rule ref="rulesets/naming.xml/MisleadingVariableName"/>
<rule ref="rulesets/naming.xml/BooleanGetMethodName">
<properties>
<property name="checkParameterizedMethods" value="false"/>
</properties>
</rule>
<!--====================naming Rules end======================-->
<!--====================optimization Rules begin(共10个)======================-->
<!--rule ref="rulesets/optimizations.xml/LocalVariableCouldBeFinal"/-->
<!--rule ref="rulesets/optimizations.xml/MethodArgumentCouldBeFinal"/-->
<!--rule ref="rulesets/optimizations.xml/AvoidInstantiatingObjectsInLoops"/-->
<rule ref="rulesets/optimizations.xml/UseArrayListInsteadOfVector"/>
<!--rule ref="rulesets/optimizations.xml/SimplifyStartsWith"/-->
<!--rule ref="rulesets/optimizations.xml/UseStringBufferForStringAppends"/-->
<rule ref="rulesets/optimizations.xml/UseArraysAsList"/>
<rule ref="rulesets/optimizations.xml/AvoidArrayLoops"/>
<rule ref="rulesets/optimizations.xml/UnnecessaryWrapperObjectCreation"/>
<!--rule ref="rulesets/optimizations.xml/AddEmptyString"/-->
<!--====================optimization Rules end======================-->
<!--====================strictexception Rules begin(共9个)======================-->
<rule ref="rulesets/strictexception.xml/AvoidCatchingThrowable"/>
<rule ref="rulesets/strictexception.xml/SignatureDeclareThrowsException"/>
<rule ref="rulesets/strictexception.xml/ExceptionAsFlowControl"/>
<rule ref="rulesets/strictexception.xml/AvoidCatchingNPE"/>
<rule ref="rulesets/strictexception.xml/AvoidThrowingRawExceptionTypes"/>
<!--rule ref="rulesets/strictexception.xml/AvoidThrowingNullPointerException"/-->
<rule ref="rulesets/strictexception.xml/AvoidRethrowingException"/>
<rule ref="rulesets/strictexception.xml/DoNotExtendJavaLangError"/>
<rule ref="rulesets/strictexception.xml/DoNotThrowExceptionInFinally"/>
<!--====================strictexception Rules end======================-->
<!--====================sunsecure Rules begin(共2个)======================-->
<!--rule ref="rulesets/sunsecure.xml/MethodReturnsInternalArray"/-->
<!--rule ref="rulesets/sunsecure.xml/ArrayIsStoredDirectly"/-->
<!--====================sunsecure Rules end======================-->
<!--====================strings Rules begin(共15个)======================-->
<!--
<rule ref="rulesets/strings.xml/AvoidDuplicateLiterals">
<properties>
<property name="threshold" value="4"/>
</properties>
</rule>
-->
<rule ref="rulesets/strings.xml/StringInstantiation"/>
<rule ref="rulesets/strings.xml/StringToString"/>
<!--rule ref="rulesets/strings.xml/InefficientStringBuffering"/-->
<rule ref="rulesets/strings.xml/UnnecessaryCaseChange"/>
<rule ref="rulesets/strings.xml/UseStringBufferLength"/>
<rule ref="rulesets/strings.xml/AppendCharacterWithChar"/>
<!--
<rule ref="rulesets/strings.xml/ConsecutiveLiteralAppends">
<properties>
<property name="threshold" value="1"/>
</properties>
</rule>
-->
<!--rule ref="rulesets/strings.xml/UseIndexOfChar"/-->
<!--rule ref="rulesets/strings.xml/InefficientEmptyStringCheck"/-->
<!--rule ref="rulesets/strings.xml/InsufficientStringBufferDeclaration"/-->
<rule ref="rulesets/strings.xml/UselessStringValueOf"/>
<rule ref="rulesets/strings.xml/StringBufferInstantiationWithChar"/>
<rule ref="rulesets/strings.xml/UseEqualsToCompareStrings"/>
<!--rule ref="rulesets/strings.xml/AvoidStringBufferField"/-->
<!--====================strings Rules end======================-->
<!--====================unusedcode Rules begin(共4个)======================-->
<rule ref="rulesets/unusedcode.xml/UnusedPrivateField"/>
<rule ref="rulesets/unusedcode.xml/UnusedLocalVariable"/>
<rule ref="rulesets/unusedcode.xml/UnusedPrivateMethod"/>
<rule ref="rulesets/unusedcode.xml/UnusedFormalParameter"/>
<!--====================unusedcode Rules end======================-->
</ruleset>
发表评论
-
java 中的文件读取信息
2013-03-11 08:56 1113import java.io.BufferedReader ... -
oracle结果集的操作信息
2013-03-04 16:22 983众所周知的几个结果集集合操作命令,今天详细地测试了一下,发现一 ... -
js正则表达式(二)
2013-01-09 11:20 926首先加个重要的东西 * ... -
java路径问题以及java对文件的基本操作信息
2012-12-19 14:09 10071.基本概念的理解 绝对 ... -
JS正则表达式
2012-11-15 17:10 886function isTrueName(s) { var pa ... -
java公用类
2012-11-15 17:05 891package cn.org.jshuwei.j2ee.uti ... -
java规范信息
2012-10-30 08:44 28741 一、判断选择题(每题1分) 1. 表达式要在低优先级操作符 ... -
java时间公用和StringUnitl以及java调用存储过程
2012-10-16 17:38 16621 构建存储过程的语句信息 /** * 从Fun ... -
jquery批量删除
2012-09-20 14:31 3424<%@ page language="java ... -
java操作execl文件(2003与2007不兼容问题)
2012-09-19 14:49 1500package com.huawei.bss.execlCom ... -
java操作execl文件
2012-09-19 08:53 1021package com.huawei.bss.execlCom ... -
通过onkeypress和onkeydown事件禁用键盘中某些键
2012-09-17 15:09 997http://zywang.iteye.com/blog/70 ... -
properties的修改
2012-09-14 16:05 1085public static void modifyProper ... -
java学习的一点记录
2012-09-12 16:15 1325public class Tools { stati ... -
STRUTS2与JSON的LIST和MAP对象返回
2012-09-07 14:57 6710<%@ page language="java ... -
struts2 iterator双重叠迭取值
2012-09-05 18:08 1297•效果:Map<String,List<Derpa ... -
struts2多个配置文件的应用
2012-09-05 10:10 1110<!-- 定义Struts2的核心Filter --&g ... -
java中使用net.sf.json对json进行解析
2012-09-04 12:24 1078作者: http://zhangnet1.iteye.com/ ... -
XML的TreeConfig
2012-09-04 10:20 946/** * <?xml version=&qu ... -
JSON与 STRuts2
2012-09-04 10:20 1342package com.huawei.cmclient.com ...
相关推荐
安装说明 1、importorder.xml文件 ,包的导入顺序 打开eclipse中菜单...5、pmd.xml文件,check style规则模板 打开eclipse中菜单"windows"-->Preferences。 选择“PMD”-->"Rules Configuration" ,然后导入。
`content.xml.xz`和`artifacts.xml.xz`是经过XZ压缩的XML文件,分别对应于`content.jar`和`artifacts.jar`的元数据内容。它们提供了更高效的存储方式,便于在网络传输或离线安装时减小文件体积。 `features`目录下...
PMD_ruleset规则文件,已经最基本的验证进行了导入。在Eclipse导入即可
在XML文件中,规则集以`<ruleset>`标签表示,包含多个规则定义。 2. **规则(Rule)** 每个规则代表一个特定的检查,如“避免使用空的finally块”或“避免过多的import”。规则以`<rule>`标签表示,包括ID、名称、...
3. **定制规则**:如果你需要自定义规则,可以修改或创建XML配置文件(通常为`pmd.xml`)。配置文件中定义了要启用的规则和它们的参数。 4. **查看报告**:PMD会生成一个XML、HTML或文本格式的报告,显示有问题的...
最全maven pom文件 功能包括 1.整合 scm(git) 、ci(hudson)、issus(trac) 2.依赖部分根据自己添加 3.build 部分,自定义目录功能 4.report整合包括:javadoc、jxr、checkstyle、pmd、changelog、emma、...
本文将详细介绍如何使用"Eclipse_CodeFormatter.xml"文件在IDEA和Eclipse中实现代码格式化的统一。 首先,"Eclipse_CodeFormatter.xml"是一个Eclipse的代码格式化配置文件,它存储了关于代码缩进、空格、括号放置、...
PMD的规则集可以通过XML配置文件进行定制,允许用户根据项目需求选择和调整规则。 PMD的标签“pmd-java”表明这是专门针对Java语言的版本。除了Java,PMD还支持其他语言,如C#、Python和PL/SQL等,但在这个特定的...
2. **创建自定义规则文件**:根据需要创建新的XML文件,定义具体的规则。 3. **整合到PMD中**:将自定义规则文件与PMD命令一起使用,以实现对特定问题的检查。 #### 七、结束语 通过使用PMD这样的静态代码分析工具...
本文将深入探讨Java编程规范,并结合提供的资源,如`Java Coding Standard.doc`,以及配置文件`iisi-Formatter.xml`、`iisi-PMD.xml`和`iisi-Checkstyle.xml`,来阐述如何提升Java代码的可读性、可维护性和一致性。...
5. `plugin.xml`:这可能是一个描述PMD插件配置的XML文件,用于IDE识别和集成PMD。 在实际使用PMD时,了解和调整这些资源可以帮助你更好地定制和优化PMD的检查效果。例如,你可以通过修改`plugin.xml`来改变PMD在...
1. **bin** 目录:这是PMD的可执行文件所在的目录,包含了用于运行PMD的命令行脚本,如`pmd.sh`(适用于Linux/Unix系统)和`pmd.bat`(适用于Windows系统)。这些脚本使得开发者可以在终端或命令行环境中轻松启动PMD...
- 在 Maven 项目的 `pom.xml` 文件中,您需要在 `<build>` 和 `<reporting>` 部分分别配置 PMD 插件。在 `<build>` 部分的配置用于构建过程中的代码检查,而在 `<reporting>` 部分的配置则用于生成报告。 ```xml...
这需要编写XML文件来定义新规则,并将其添加到PMD的规则集中。 9. **性能优化**:PMD在分析大量代码时,可能会对性能产生影响。因此,了解如何合理配置PMD,如设置适当的内存大小,或者使用过滤器减少分析范围,都...
PMD的规则集可以通过`pmd.xml`文件进行定制,同样可以集成到构建工具和IDE中,以便在开发过程中进行实时检查。 再者,FindBugs是一款专门针对Java代码的静态分析工具,它能够检测出代码中可能导致错误的模式,如空...
- 导入新的PMD规则集XML文件(如newRules/pmd.xml)。 - 自定义规则集,选择你希望启用或禁用的规则,然后点击`Apply`和`OK`。 4. **应用规则集** - 对于Checkstyle,你可以右键点击项目 -> `Checkstyle` -> `...
allLevel 的规则文件只分两级(PMD 默认为 5级),可以点击视图右上角中的 1 或者 2 查看不同级别的 voilations。 通过配置和使用 PMD 插件,开发者可以检测到 Java 代码中的错误和不良编程实践,从而提高代码的...
这里,`pmd_rules.xml`和`checkstyle.xml`分别是PMD和Checkstyle的自定义规则文件,它们定义了我们要遵循的编码规范。 最后,为了在持续集成环境中运行这些任务,`ci_build.xml`可能会这样组织: ```xml , ...
在bin目录下,有两个主要的脚本文件,分别对应于Windows和Unix/Linux系统:`pmd.bat` 和 `pmd.sh`。通过运行这些脚本,你可以指定待检查的源代码目录、配置文件以及想要执行的规则集。 规则集是PMD的核心部分,它...
需要在build.xml文件中配置PMD的规则集和要分析的目标源代码路径。 5. 关于 PMD 规则 PMD的规则分为多个类别,如Design、Error Prone、Performance、Maintainability和Best Practices。每个规则都有一个独特的ID,...