MyEclipse integrated PMD Code detection plug-in custom rule configuration file

Source: Internet
Author: User
Tags garbage collection
Put my latest updated MyEclipse2014 integrated PMD code detection plug-in custom rule profile Java version released, to facilitate their future review, but also to see if they can help to have this need of small partners. FileName: cplatform_pmd5.2.3_rules.xml
<?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> corresponding pmd:v5.2.3 rule version: V1.1 (2015-01-13) Recommended index: 3, 4, 5 level rule modification rules: Emptycatchblock, Emptyifstmt, Emptywhilestmt, Emptytryblock, Emptyfinallyblock, emptyswitchstatements, Emptysynchronizedblock, Emptystaticinitializer, Emptystatementnotinloop and other rules transferred to the Rulesets/java/empty.xml Unnecessaryfinalmodifier, Uselessoperationonimmutable rules to Rulesets/java/unnecessary.xml: removing rules: Usesingleton corresponding pmd:v4.2.6 recommended index: 3, 4, Level 5 Rule Modification rule: Add rule: Removal rule: </description>

<!--====================basic Rules begin (Total 33) ======================--> <!--do not allow empty catch blocks to avoid blocking exceptions. Do not process or report exceptions. (FindBugs does not check)--> <rule ref= "Rulesets/java/empty.xml/emptycatchblock" > <properties> <property Name = "Allowcommentedblocks" value= "false"/> </properties> </rule> <!--does not allow an empty if statement block (or an empty else block). (FindBugs does not check)--> <rule ref= "rulesets/java/empty.xml/emptyifstmt"/> <!--do not allow an empty while loop block. Note: Do loops are not included. (FindBugs does not check)--> <rule ref= "rulesets/java/empty.xml/emptywhilestmt"/> <!--do not allow empty try blocks. (FindBugs does not check)--> <rule ref= "Rulesets/java/empty.xml/emptytryblock"/> <!--do not allow empty finally blocks. (FindBugs does not check)--> <rule ref= "Rulesets/java/empty.xml/emptyfinallyblock"/> <!--do not allow empty switch blocks. Repeat with this rule: Rulesets/java/design.xml/switchstmtsshouldhavedefault, Missingbreakinswitch. (findbugs not checked)--> <rule ref= "rulesets/java/empty.xml/emptyswitchstatements"/> <!-- Avoid confusing loop variable assignments (avoid modifying outer loop variables in the inner loop). A little repetitive with this rule: rulesets/java/controversial.xml/dataflowanomAlyanalysis. (FindBugs does not check)--> <rule ref= "Rulesets/java/basic.xml/jumbledincrementer"/> <!--a simple for loop can be replaced with a while loop. (FindBugs does not check, note, findbugs can find dead loops)--> <!--rule ref= "Rulesets/java/basic.xml/forloopshouldbewhileloop"/--> <!--avoid unnecessary temporary objects when basic data is converted to string. (findbugs check)--> <!--rule ref= "rulesets/java/basic.xml/unnecessaryconversiontemporary"/--> <!-- Equals and hashcode are defined at the same time. (findbugs check)--> <rule ref= "Rulesets/java/basic.xml/overridebothequalsandhashcode"/> <!--doublecheck issues. (findbugs check)--> <!--rule ref= "rulesets/java/basic.xml/doublecheckedlocking"/--> <!-- It is forbidden to return in finally blocks to avoid blocking exceptions. (FindBugs does not check)--> <rule ref= "Rulesets/java/basic.xml/returnfromfinallyblock"/> <!--avoid empty sync blocks. (findbugs check)--> <rule ref= "Rulesets/java/empty.xml/emptysynchronizedblock"/> <!--method returns the value void, Avoid unnecessary return. (findbugs)--> <!--rule ref= "Rulesets/java/basic.xml/unnecessaryreturn"/--> <!--empty static initialization. (findbugs not checked)--> <rule ref= "Rulesets/jaVa/empty.xml/emptystaticinitializer "/> <!--if statement is always true or false. (FindBugs does not check)--> <rule ref= "rulesets/java/basic.xml/unconditionalifstatement"/> <!--an empty statement (just a semicolon) appears. If you're in a loop, you can. (FindBugs does not check)--> <rule ref= "Rulesets/java/empty.xml/emptystatementnotinloop"/> <!--Avoid instantiating a Boolean object. and apply constant Boolean.true, Boolean.false. (FindBugs only checks the construction method generates the object, does not check valueof)--> <rule ref= "rulesets/java/basic.xml/booleaninstantiation"/> <!- -When a class is defined as final, all of its methods are automatically final. (findbugs not checked)--> <rule ref= "Rulesets/java/unnecessary.xml/unnecessaryfinalmodifier"/> <!-- The embedded if statement can be merged with the outer if statement into an if statement. (findbugs not checked)--> <!--rule ref= "rulesets/java/basic.xml/collapsibleifstatements"/--> <!-- The overridden method simply invokes the method of the base class. (findbugs check)--> <!--rule ref= "Rulesets/java/basic.xml/uselessoverridingmethod"/--> <!-- The Collection.toarray call converts an array object of an explicitly type, otherwise the runtime throws the ClassCastException exception. Similarity rule: Rulesets/java/design.xml/optimizabletoarraycall. (findbugs not checked)--> <rule ref= "Rulesets/java/basic.xml/classcastexceptionwithtoarray "/> <!--new BigDecimal recommends constructing a string argument instead of a decimal decimal constant (except for integers). (findbugs not checked)--> <rule ref= "Rulesets/java/basic.xml/avoiddecimalliteralsinbigdecimalconstructor"/> <! -The results of operations on immutable objects (such as BigDecimal, BigInteger) are ignored. (findbugs check)--> <rule ref= "rulesets/java/unnecessary.xml/uselessoperationonimmutable"/> <!-- Null pointer judge misplaced position. Either you have previously reported a null pointer, or you can never be a null pointer here. (findbugs check)--> <rule ref= "Rulesets/java/basic.xml/misplacednullcheck"/> <!--After judging whether the object is a null pointer, The Equals method of the object is called shortly thereafter, rather than the object as the equals parameter of the other object. (findbugs not checked)--> <!--rule ref= "rulesets/java/basic.xml/unusednullcheckinequals"/--> <!-- Threadgroup is not recommended because its methods are not thread-safe. (findbugs not checked)--> <!--rule ref= "Rulesets/java/basic.xml/avoidthreadgroup"/--> <!--should be replaced by && | | or vice versa. (findbugs check)--> <rule ref= "Rulesets/java/basic.xml/brokennullcheck"/> <!--do not create an existing object (Bigdecimal.zero , Bigdecimal.one, Bigdecimal.ten). (findbugs not checked)--> <rule ref= "Rulesets/java/basic.xml/bigintegerinstantiatIon "/> <!--avoid using octal values. (FindBugs does not check)--> <!--rule ref= "rulesets/java/basic.xml/avoidusingoctalvalues"/--> <!--to avoid hard coding IPv4 and IPV6, To avoid the possibility of becoming impossible in certain circumstances. (findbugs not checked)--> <!--<rule ref= "Rulesets/java/basic.xml/avoidusinghardcodedip" > <properties> <property name= "pattern" value= ""/> </properties> </rule>--> <!--method for resultset (Next, Previous,first,last) calls whether the results are really judged. (FindBugs does not check)--> <rule ref= "Rulesets/java/basic.xml/checkresultset"/> <!--avoid multiple unary operators, either an error or a confusing result. (findbugs not checked)--> <rule ref= "rulesets/java/basic.xml/avoidmultipleunaryoperators"/> <!--============== ======basic Rules end======================-->

<!--====================braces Rules begin (Total 4) ======================--> <!--avoid curly braces when using an if statement--> < Rule ref= "rulesets/java/braces.xml/ifstmtsmustusebraces"/> <!--avoid using a while loop without braces--> <rule ref= " Rulesets/java/braces.xml/whileloopsmustusebraces "/> <!--avoid using If-else statements without braces--> <rule ref=" rulesets/ Java/braces.xml/ifelsestmtsmustusebraces "/> <!--avoid using a for loop without braces--> <rule ref=" rulesets/java/ Braces.xml/forloopsmustusebraces "/> <!--====================braces Rules end======================-->

<!--====================clone Rules begin (Total 3) ======================--> <!--appropriate cloning implementation: Object Clone () method should include Super.clone () implementation--> <rule ref= "rulesets/java/clone.xml/propercloneimplementation"/> <!-- Cloning method to throw unsupported clone exception: Clone () method should throw clonenotsupportedexception--> <rule ref= "rulesets/java/clone.xml/ Clonethrowsclonenotsupportedexception "/> <!--cloning method must implement the Cloneable interface: If the class implements Cloneable interface, Clone () Methods should be implemented as a final method and only throw clonenotsupportedexception exceptions--> <rule ref= "rulesets/java/clone.xml/ Clonemethodmustimplementcloneable "/> <!--====================clone Rules end======================-->
<!--====================codesize Rules begin (Total 11) ======================--> <!-- N Path Complexity: Npath complexity is a method of the total number of possible execution paths, generally take 200 as a critical point to reduce complexity--> <!--<rule ref= "rulesets/java/codesize.xml/ Npathcomplexity "> <properties> <property name=" minimum "value=" "/> </properties> </rule >--> <!--method is too long: This violation is too much to do in the method, try to reduce the size of the method by creating an auxiliary method or removing the copy/paste code--> <!--<rule ref= "rulesets/java/ Codesize.xml/excessivemethodlength "> <properties> <property name=" minimum "value="/> </ Properties> </rule>--> <!--too many parameters: an too long argument list indicates that a new object should be created to wrap a large number of parameter values, which is to organize the parameters together--> <rule ref= " Rulesets/java/codesize.xml/excessiveparameterlist "> <properties> <property name=" minimum "value=" 6 "/ > </properties> </rule> <!--too long class: Too long class files indicate that classes try to do too much, try to decompose it, reduce it to manageable scale--> <!--<rule ref= " Rulesets/java/codesize.xml/excessiveclasslength "> <properties> <property name=" minimum "value=" 1000 "/ > &LT;/PROPERTIES&GT </rule>--> <!--rank complexity: The complexity determined by decision points such as if,while,for,case labels, 1-4 is low complexity, 5-7 is medium, 8 to 10 is high complexity, 11 is very high--> <! --<rule ref= "rulesets/java/codesize.xml/cyclomaticcomplexity" > <properties> <property name= " Reportlevel "value=" "/> Property name=" Showclassescomplexity "value=" true "/> Property name=" Showmethodscomplexity "value=" true "/> </properties> </rule>--> <!-- Too many public members: a class that declares a large number of public methods and properties indicates that the class needs to be decomposed because it takes a lot of effort to completely test the class--> <!--<rule ref= "rulesets/java/codesize.xml/ Excessivepubliccount "> <properties> <property name=" minimum "value=" "/> </properties> </ Rule>--> <!--too many domains: A class that contains too many fields can be redesigned to contain fewer fields, and you can organize some information into nested classes. For example, a class contains the City/state/zip domain, which can be used to organize these three domains in an address domain--> <!--<rule ref= "Rulesets/java/codesize.xml/toomanyfields "> <properties> <property name=" maxfields "value="/> </properties> </rule>--> <!- -ncss Method Code Calculation: This rule calculates the number of lines of code for a given method (without the construction method) using the NCSS (non-annotation code block) algorithm. NCSS ignores comments in code and is countedCalculates the actual number of lines of code. With this algorithm, a single line of code is computed as 1. (also ignores blank lines)--> <!--<rule ref= "Rulesets/java/codesize.xml/ncssmethodcount" > <properties> < Property name= "Minimum" value= "/> </properties> </rule>--> <!--NCSS class code calculation: This rule takes ncss (non-annotation code block The algorithm computes the number of lines of code for the given type. NCSS ignores comments in the code and calculates the actual number of lines of code. With this algorithm, a single line of code is computed as 1. (also ignores blank lines)--> <!--<rule ref= "Rulesets/java/codesize.xml/ncsstypecount" > < properties> <property name= "minimum" value= "1500"/> </properties> </rule>--> <!-- NCSs constructor Code calculation: This rule applies to the number of lines of code that the NCSS (non-annotation code block) algorithm computes for a given construction method. NCSS ignores comments in the code and calculates the actual number of lines of code. With this algorithm, a single line of code is computed as 1. (also ignores blank lines)--> <!--<rule ref= "Rulesets/java/codesize.xml/ncssconstructorcount" > < properties> <property name= "minimum" value= "M"/> </properties> </rule>--> <!-- Too many methods: The class contains too many methods that may need to be refactored to reduce complexity and get finer grained objects--> <!--<rule ref= "Rulesets/java/codesize.xml/toomanymethods" > <properties> <property name= "maxmethods" value= "/> </properties> &Lt;/rule>--> <!--====================codesize Rules end===============================-->
<!--==============controversial Rules begin (Total 19) ====================--> <!--non-essential Constructors: This rule checks for unnecessary constructors. For example: There is only one common, empty method body, parameterless constructor--> <rule ref= "Rulesets/java/controversial.xml/unnecessaryconstructor"/> <!-- Null assignment: Assigning NULL to a variable (outside of a declaration) is often a bad form. At some point this assignment indicates that the programmer is not thinking about what to do next in a good code. --> <!--Note: This is useful when you need to assign a variable to null to prompt the garbage collector to do garbage collection, so ignore this rule--> <!--rules ref= "rulesets/java/ Controversial.xml/nullassignment "/--> <!--only one return: A method should have and only one return point, and should be the last statement of the method. --> <!--rule ref= "Rulesets/java/controversial.xml/onlyonereturn"/--> <!--useless modifier: The domain defined in the interface is automatically public Static final, the method is automatically public abstract, the nested class or interface in the interface is automatically public static. For historical reasons, contextual hinting modifiers are accepted by the compiler, but are superfluous. --> <!--rule ref= "Rulesets/java/controversial.xml/unusedmodifier"/--> <!--assignment in action: Avoid assigning values in operations This makes the code complex and difficult to read--> <!--rule ref= "Rulesets/java/controversial.xml/assignmentinoperand"/--> <!-- At least one constructor: Each class should declare at least one constructor--> <!--rule ref= "Rulesets/java/controversial.xml/atleastoneconstructor"/--> < !--do not introduce SUN Package: Avoid introducing any classes from "sun.*", which are not portable and may change--> <rule ref= "Rulesets/java/controversial.xml/dontimportsun"/>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.