aurora-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kevi...@apache.org
Subject [1/2] incubator-aurora git commit: DRY up PMD configuration.
Date Fri, 20 Mar 2015 19:55:25 GMT
Repository: incubator-aurora
Updated Branches:
  refs/heads/master 91aec8c47 -> f12d9fe41


http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/f12d9fe4/config/pmd/naming.xml
----------------------------------------------------------------------
diff --git a/config/pmd/naming.xml b/config/pmd/naming.xml
deleted file mode 100644
index 233352d..0000000
--- a/config/pmd/naming.xml
+++ /dev/null
@@ -1,621 +0,0 @@
-<?xml version="1.0"?>
-<!--
-Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this work except in compliance with the License.
-You may obtain a copy of the License in the LICENSE file, or at:
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
--->
-<!--
-This is a modified file from the PMD project.  Copying and editing ruleset
-configurations is the approach used to modify a ruleset behavior, such as
-disabling individul rules.
--->
-
-<ruleset name="Naming"
-    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>
-The Naming Ruleset contains rules regarding preferred usage of names and identifiers.
-  </description>
-
-<!--
-Requiring longer variable names can be cumbersome when applied globally.
-  <rule name="ShortVariable"
-   		language="java"
-  		  since="0.3"
-        message="Avoid variables with short names like {0}"
-        class="net.sourceforge.pmd.lang.rule.XPathRule"
-          externalInfoUrl="http://pmd.sourceforge.net/pmd-5.1.1/rules/java/naming.html#ShortVariable">
-    <description>
-Fields, local variables, or parameter names that are very short are not helpful to the reader.
-    </description>
-    <priority>3</priority>
-      <properties>
-          <property name="xpath">
-              <value>
-                  <![CDATA[
-//VariableDeclaratorId[string-length(@Image) < 3]
- [not(ancestor::ForInit)]
- [not(../../VariableDeclarator and ../../../LocalVariableDeclaration and ../../../../ForStatement)]
- [not((ancestor::FormalParameter) and (ancestor::TryStatement))]
-                  ]]>
-              </value>
-          </property>
-      </properties>
-    <example>
-<![CDATA[
-public class Something {
-    private int q = 15;                         // field - too short
-    public static void main( String as[] ) {    // formal arg - too short
-        int r = 20 + q;                         // local var - too short
-        for (int i = 0; i < 10; i++) {          // not a violation (inside 'for' loop)
-            r += q;
-        }
-        for (Integer i : numbers) {             // not a violation (inside 'for-each' loop)
-            r += q;
-        }
-    }
-}
-]]>
-    </example>
-  </rule>
--->
-
-<!--
-Requiring shorter variable names can be cumbersome when applied globally.
-  <rule name="LongVariable"
-   		language="java"
-  		  since="0.3"
-        message="Avoid excessively long variable names like {0}"
-        class="net.sourceforge.pmd.lang.rule.XPathRule"
-          externalInfoUrl="http://pmd.sourceforge.net/pmd-5.1.1/rules/java/naming.html#LongVariable">
-    <description>
-Fields, formal arguments, or local variable names that are too long can make the code difficult
to follow.
-    </description>
-      <priority>3</priority>
-      <properties>
-          <property name="minimum" type="Integer" description="The variable length reporting
threshold" min="1" max="100" value="17"/>
-          <property name="xpath">
-              <value>
-                  <![CDATA[
-//VariableDeclaratorId[string-length(@Image) > $minimum]
-                  ]]>
-              </value>
-          </property>
-      </properties>
-    <example>
-<![CDATA[
-public class Something {
-	int reallyLongIntName = -3;  			// VIOLATION - Field
-	public static void main( String argumentsList[] ) { // VIOLATION - Formal
-		int otherReallyLongName = -5; 		// VIOLATION - Local
-		for (int interestingIntIndex = 0;	// VIOLATION - For
-             interestingIntIndex < 10;
-             interestingIntIndex ++ ) {
-    }
-}
-]]>
-    </example>
-  </rule>
--->
-
-<!--
-Short method names are useful on occasion, such as with factory methods: Rate.of(...).
-  <rule name="ShortMethodName"
-   		language="java"
-  		  since="0.3"
-        message="Avoid using short method names"
-        class="net.sourceforge.pmd.lang.rule.XPathRule"
-          externalInfoUrl="http://pmd.sourceforge.net/pmd-5.1.1/rules/java/naming.html#ShortMethodName">
-     <description>
-Method names that are very short are not helpful to the reader.
-     </description>
-      <priority>3</priority>
-      <properties>
-          <property name="xpath">
-              <value>
-                  <![CDATA[
-//MethodDeclarator[string-length(@Image) < 3]
-                  ]]>
-              </value>
-          </property>
-      </properties>
-     <example>
-<![CDATA[
-public class ShortMethod {
-	public void a( int i ) { // Violation
-	}
-}
-]]>
-     </example>
-  </rule>
--->
-
-    <rule name="VariableNamingConventions"
-    since="1.2"
-    message="{0} variable {1} should begin with {2}"
-    class="net.sourceforge.pmd.lang.java.rule.naming.VariableNamingConventionsRule"
-          externalInfoUrl="http://pmd.sourceforge.net/pmd-5.1.1/rules/java/naming.html#VariableNamingConventions">
-        <description>
-A variable naming conventions rule - customize this to your liking.  Currently, it
-checks for final variables that should be fully capitalized and non-final variables
-that should not include underscores.
-        </description>
-        <priority>1</priority>
-        <example>
-<![CDATA[
-public class Foo {
-   public static final int MY_NUM = 0;
-   public String myTest = "";
-   DataModule dmTest = new DataModule();
-}
-]]>
-        </example>
-    </rule>
-
-    <rule name="MethodNamingConventions"
-    			  since="1.2"
-              message="Method name does not begin with a lower case character."
-              class="net.sourceforge.pmd.lang.java.rule.naming.MethodNamingConventionsRule"
-          externalInfoUrl="http://pmd.sourceforge.net/pmd-5.1.1/rules/java/naming.html#MethodNamingConventions">
-          <description>
-Method names should always begin with a lower case character, and should not contain underscores.
-          </description>
-          <priority>1</priority>
-          <example>
-<![CDATA[
-public class Foo {
-	public void fooStuff() {
-	}
-}
-]]>
-          </example>
-        </rule>
-
-    <rule name="ClassNamingConventions"
-    		 since="1.2"
-          message="Class names should begin with an uppercase character"
-          class="net.sourceforge.pmd.lang.java.rule.naming.ClassNamingConventionsRule"
-          externalInfoUrl="http://pmd.sourceforge.net/pmd-5.1.1/rules/java/naming.html#ClassNamingConventions">
-      <description>
-Class names should always begin with an upper case character.
-      </description>
-      <priority>1</priority>
-      <example>
-<![CDATA[
-public class Foo {}
-]]>
-      </example>
-    </rule>
-
-<!--
-TODO(wfarner): Enable this if/when we have automatic transaction management, rather than
the classes
-in org.apache.aurora.scheduler.storage.Storage (e.g. Work).
-    <rule name="AbstractNaming"
-   		language="java"
-    		 since="1.4"
-          message="Abstract classes should be named 'AbstractXXX'"
-          class="net.sourceforge.pmd.lang.rule.XPathRule"
-          externalInfoUrl="http://pmd.sourceforge.net/pmd-5.1.1/rules/java/naming.html#AbstractNaming">
-       <description>
-Abstract classes should be named 'AbstractXXX'.
-       </description>
-        <priority>3</priority>
-        <properties>
-            <property name="xpath">
-                <value>
-                    <![CDATA[
-//ClassOrInterfaceDeclaration
- [@Abstract='true' and @Interface='false']
- [not (starts-with(@Image,'Abstract'))]
-                    ]]>
-                </value>
-            </property>
-        </properties>
-       <example>
-<![CDATA[
-public abstract class Foo { // should be AbstractFoo
-}
-]]>
-       </example>
-    </rule>
--->
-
-    <rule name="AvoidDollarSigns"
-    		  since="1.5"
-           message="Avoid using dollar signs in variable/method/class/interface names"
-           class="net.sourceforge.pmd.lang.java.rule.naming.AvoidDollarSignsRule"
-          externalInfoUrl="http://pmd.sourceforge.net/pmd-5.1.1/rules/java/naming.html#AvoidDollarSigns">
-       <description>
-Avoid using dollar signs in variable/method/class/interface names.
-       </description>
-         <priority>3</priority>
-       <example>
-   <![CDATA[
-public class Fo$o {  // not a recommended name
-}
-   ]]>
-       </example>
-     </rule>
-
-    <rule name="MethodWithSameNameAsEnclosingClass"
-    		 since="1.5"
-          message="Classes should not have non-constructor methods with the same name as
the class"
-          class="net.sourceforge.pmd.lang.java.rule.naming.MethodWithSameNameAsEnclosingClassRule"
-          externalInfoUrl="http://pmd.sourceforge.net/pmd-5.1.1/rules/java/naming.html#MethodWithSameNameAsEnclosingClass">
-       <description>
-Non-constructor methods should not have the same name as the enclosing class.
-       </description>
-        <priority>3</priority>
-       <example>
-    <![CDATA[
-public class MyClass {
-
-	public MyClass() {}			// this is OK because it is a constructor
-	
-	public void MyClass() {}	// this is bad because it is a method
-}
-    ]]>
-       </example>
-     </rule>
-
-    <rule name="SuspiciousHashcodeMethodName"
-    		 since="1.5"
-          message="The method name and return type are suspiciously close to hashCode()"
-          class="net.sourceforge.pmd.lang.java.rule.naming.SuspiciousHashcodeMethodNameRule"
-          externalInfoUrl="http://pmd.sourceforge.net/pmd-5.1.1/rules/java/naming.html#SuspiciousHashcodeMethodName">
-       <description>
-The method name and return type are suspiciously close to hashCode(), which may denote an
intention
-to override the hashCode() method.
-       </description>
-        <priority>3</priority>
-       <example>
-    <![CDATA[
-public class Foo {
-	public int hashcode() {	// oops, this probably was supposed to be 'hashCode'
-	
-	}
-}
-    ]]>
-       </example>
-     </rule>
-
-    <rule name="SuspiciousConstantFieldName"
-   		language="java"
-    		 since="2.0"
-          message="The field name indicates a constant but its modifiers do not"
-          class="net.sourceforge.pmd.lang.rule.XPathRule"
-          externalInfoUrl="http://pmd.sourceforge.net/pmd-5.1.1/rules/java/naming.html#SuspiciousConstantFieldName">
-       <description>
-Field names using all uppercase characters - Sun's Java naming conventions indicating constants
- should
-be declared as final.
-       </description>
-       <priority>3</priority>
-        <properties>
-            <property name="xpath">
-                <value>
-<![CDATA[
-//ClassOrInterfaceDeclaration[@Interface='false']
- /ClassOrInterfaceBody/ClassOrInterfaceBodyDeclaration/FieldDeclaration
-  [@Final='false']
-  [VariableDeclarator/VariableDeclaratorId[upper-case(@Image)=@Image]]
- ]]>
-                </value>
-            </property>
-        </properties>
-       <example>
-    <![CDATA[
-public class Foo {
- // this is bad, since someone could accidentally
- // do PI = 2.71828; which is actually e
- // final double PI = 3.16; is ok
-  double PI = 3.16;
-}
-    ]]>
-       </example>
-     </rule>
-
-    <rule name="SuspiciousEqualsMethodName"
-          language="java"
-          since="2.0"
-          message="The method name and parameter number are suspiciously close to equals(Object)"
-          class="net.sourceforge.pmd.lang.rule.XPathRule"
-          externalInfoUrl="http://pmd.sourceforge.net/pmd-5.1.1/rules/java/naming.html#SuspiciousEqualsMethodName">
-        <description>
-The method name and parameter number are suspiciously close to equals(Object), which can
denote an
-intention to override the equals(Object) method.
-        </description>
-        <priority>2</priority>
-        <properties>
-            <property name="xpath">
-                <value><![CDATA[
-//MethodDeclarator[@Image = 'equals']
-[   
-    (count(FormalParameters/*) = 1
-    and not (FormalParameters/FormalParameter/Type/ReferenceType/ClassOrInterfaceType
-        [@Image = 'Object' or @Image = 'java.lang.Object'])
-    or not (../ResultType/Type/PrimitiveType[@Image = 'boolean'])
-    )  or  (
-    count(FormalParameters/*) = 2
-    and ../ResultType/Type/PrimitiveType[@Image = 'boolean']
-    and FormalParameters//ClassOrInterfaceType[@Image = 'Object' or @Image = 'java.lang.Object']
-    )
-]
-| //MethodDeclarator[@Image = 'equal']
-[
-    count(FormalParameters/*) = 1
-    and FormalParameters/FormalParameter/Type/ReferenceType/ClassOrInterfaceType
-        [@Image = 'Object' or @Image = 'java.lang.Object']
-]           
-]]>
-                    </value>
-                 </property>
-              </properties>
-        <example><![CDATA[
-public class Foo {
-   public int equals(Object o) {
-     // oops, this probably was supposed to be boolean equals
-   }
-   public boolean equals(String s) {
-     // oops, this probably was supposed to be equals(Object)
-   }
-   public boolean equals(Object o1, Object o2) {
-     // oops, this probably was supposed to be equals(Object)
-   }
-}
-        ]]></example>
-    </rule>
-
-    <rule name="AvoidFieldNameMatchingTypeName"
-          since="3.0"
-          message="It is somewhat confusing to have a field name matching the declaring class
name"
-          class="net.sourceforge.pmd.lang.java.rule.naming.AvoidFieldNameMatchingTypeNameRule"
-          externalInfoUrl="http://pmd.sourceforge.net/pmd-5.1.1/rules/java/naming.html#AvoidFieldNameMatchingTypeName">
-      <description>
-It is somewhat confusing to have a field name matching the declaring class name.
-This probably means that type and/or field names should be chosen more carefully.
-      </description>
-        <priority>3</priority>
-      <example>
-<![CDATA[
-public class Foo extends Bar {
-	int foo;	// There is probably a better name that can be used
-}
-]]>
-      </example>
-    </rule>
-
-    <rule name="AvoidFieldNameMatchingMethodName"
-    	  since="3.0"
-          message="Field {0} has the same name as a method"
-          class="net.sourceforge.pmd.lang.java.rule.naming.AvoidFieldNameMatchingMethodNameRule"
-          externalInfoUrl="http://pmd.sourceforge.net/pmd-5.1.1/rules/java/naming.html#AvoidFieldNameMatchingMethodName">
-      <description>
-It can be confusing to have a field name with the same name as a method. While this is permitted,

-having information (field) and actions (method) is not clear naming. Developers versed in

-Smalltalk often prefer this approach as the methods denote accessor methods.
-      </description>
-        <priority>3</priority>
-      <example>
-<![CDATA[
-public class Foo {
-	Object bar;
-	// bar is data or an action or both?
-	void bar() {
-	}
-}
-]]>
-      </example>
-    </rule>
-
-
-
-    <rule name="NoPackage"
-   	  language="java"
-          since="3.3"
-          message="All classes and interfaces must belong to a named package"
-          class="net.sourceforge.pmd.lang.rule.XPathRule"
-          externalInfoUrl="http://pmd.sourceforge.net/pmd-5.1.1/rules/java/naming.html#NoPackage">
-    <description>
-Detects when a class or interface does not have a package definition.
-    </description>
-    <priority>3</priority>
-      <properties>
-          <property name="xpath">
-              <value>
-                  <![CDATA[
-//ClassOrInterfaceDeclaration[count(preceding::PackageDeclaration) = 0]
-                  ]]>
-              </value>
-          </property>
-      </properties>
-    <example>
-<![CDATA[
-// no package declaration
-public class ClassInDefaultPackage {
-}
-]]>
-    </example>
-  </rule>
-
-    <rule name="PackageCase"
-   		language="java"
-            since="3.3"
-            message="Package name contains upper case characters"
-            class="net.sourceforge.pmd.lang.rule.XPathRule"
-          externalInfoUrl="http://pmd.sourceforge.net/pmd-5.1.1/rules/java/naming.html#PackageCase">
-        <description>
-Detects when a package definition contains uppercase characters.
-        </description>
-        <priority>3</priority>
-          <properties>
-              <property name="xpath">
-                  <value>
-                      <![CDATA[
-//PackageDeclaration/Name[lower-case(@Image)!=@Image]
-                      ]]>
-                  </value>
-              </property>
-          </properties>
-        <example>
-    <![CDATA[
-package com.MyCompany;  // should be lowercase name
-
-public class SomeClass {
-}
-    ]]>
-        </example>
-      </rule>
-
-    <rule name="MisleadingVariableName"
-   		language="java"
-          since="3.4"
-          message="Avoid naming non-fields with the prefix 'm_'"
-          class="net.sourceforge.pmd.lang.rule.XPathRule"
-          externalInfoUrl="http://pmd.sourceforge.net/pmd-5.1.1/rules/java/naming.html#MisleadingVariableName">
-      <description>
-Detects when a non-field has a name starting with 'm_'.  This usually denotes a field and
could be confusing.
-      </description>
-      <priority>3</priority>
-        <properties>
-            <property name="xpath">
-                <value>
-                    <![CDATA[
-//VariableDeclaratorId
-[starts-with(@Image, 'm_')]
-[not (../../../FieldDeclaration)]
-                    ]]>
-                </value>
-            </property>
-        </properties>
-      <example>
-  <![CDATA[
-public class Foo {
-    private int m_foo; // OK
-    public void bar(String m_baz) {  // Bad
-      int m_boz = 42; // Bad
-    }
-}
-  ]]>
-      </example>
-    </rule>
-
-    <rule name="BooleanGetMethodName"
-   		language="java"
-        since="4.0"
-        message="A 'getX()' method which returns a boolean should be named 'isX()'"
-        class="net.sourceforge.pmd.lang.rule.XPathRule"
-        externalInfoUrl="http://pmd.sourceforge.net/pmd-5.1.1/rules/java/naming.html#BooleanGetMethodName">
-        <description>
-Methods that return boolean results should be named as predicate statements to denote this.
-I.e, 'isReady()', 'hasValues()', 'canCommit()', 'willFail()', etc.   Avoid the use of the
'get'
-prefix for these methods.
-        </description>
-        <priority>4</priority>
-        <properties>
-            <property name="xpath">
-                <value>
-                    <![CDATA[
-//MethodDeclaration[
-MethodDeclarator[count(FormalParameters/FormalParameter) = 0 or $checkParameterizedMethods
= 'true']
-                [starts-with(@Image, 'get')]
-and
-ResultType/Type/PrimitiveType[@Image = 'boolean']
-]
-]]>
-                </value>
-            </property>
-            <property name="checkParameterizedMethods" type="Boolean" description="Check
parameterized methods" value="false"/>
-        </properties>
-        <example>
-            <![CDATA[
-public boolean getFoo(); 	// bad
-public boolean isFoo(); 	// ok
-public boolean getFoo(boolean bar); // ok, unless checkParameterizedMethods=true
-     ]]></example>
-    </rule>
-
-<!--
-There are rare, but valid, cases where short class names are useful.
-    <rule 	name="ShortClassName"
-   		language="java"
-            since="5.0"
-            message="A Classname should have a minimum of five characters"
-            class="net.sourceforge.pmd.lang.rule.XPathRule"
-          	externalInfoUrl="http://pmd.sourceforge.net/pmd-5.1.1/rules/java/naming.html#ShortClassName">
-        <description>
-        	<![CDATA[
-Classnames with fewer than five characters are not recommended.
-			]]>
-        </description>
-        <priority>4</priority>
-          <properties>
-              <property name="xpath">
-                  <value>
-                      <![CDATA[
-//ClassOrInterfaceDeclaration[string-length(@Image) < 5]
-                      ]]>
-                  </value>
-              </property>
-          </properties>
-        <example>
-    <![CDATA[
-public class Foo {
-}
-    ]]>
-        </example>
-      </rule>
--->
-
-   <rule name="GenericsNaming"
-         language="java"
-         since="4.2.6"
-         message="Generics names should be a one letter long and upper case."
-         class="net.sourceforge.pmd.lang.rule.XPathRule"
-        externalInfoUrl="http://pmd.sourceforge.net/pmd-5.1.1/rules/java/naming.html#GenericsNaming">
-        <description>
-Names for references to generic values should be limited to a single uppercase letter.
-        </description>
-        <priority>4</priority>
-        <properties>
-            <property name="xpath">
-                <value>
-                    <![CDATA[
-//TypeDeclaration/ClassOrInterfaceDeclaration/TypeParameters/TypeParameter[
-  string-length(@Image) > 1 
-  or
-  string:upper-case(@Image) != @Image
-]
-]]>
-                </value>
-            </property>
-        </properties>
-        <example>
-            <![CDATA[
-public interface GenericDao<E extends BaseModel, K extends Serializable> extends BaseDao
{
-   // This is ok...
-}
-
-public interface GenericDao<E extends BaseModel, K extends Serializable> {
-   // Also this
-}
-
-public interface GenericDao<e extends BaseModel, K extends Serializable> {
-   // 'e' should be an 'E'
-}
-
-public interface GenericDao<EF extends BaseModel, K extends Serializable> {
-   // 'EF' is not ok.
-}
-     ]]></example>
-    </rule>
-
-</ruleset>


Mime
View raw message