You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@aurora.apache.org by ma...@apache.org on 2014/12/11 20:51:24 UTC

incubator-aurora git commit: Adding PMD rule to check @Timed annotation placement.

Repository: incubator-aurora
Updated Branches:
  refs/heads/master 73a500c84 -> a21ab21e2


Adding PMD rule to check @Timed annotation placement.

Bugs closed: AURORA-967

Reviewed at https://reviews.apache.org/r/28914/


Project: http://git-wip-us.apache.org/repos/asf/incubator-aurora/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-aurora/commit/a21ab21e
Tree: http://git-wip-us.apache.org/repos/asf/incubator-aurora/tree/a21ab21e
Diff: http://git-wip-us.apache.org/repos/asf/incubator-aurora/diff/a21ab21e

Branch: refs/heads/master
Commit: a21ab21e2c6e3fcc0dbb28d62b70e66dcaeeec33
Parents: 73a500c
Author: Maxim Khutornenko <ma...@apache.org>
Authored: Thu Dec 11 11:50:59 2014 -0800
Committer: -l <ma...@apache.org>
Committed: Thu Dec 11 11:50:59 2014 -0800

----------------------------------------------------------------------
 config/pmd/custom.xml | 86 ++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 86 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/a21ab21e/config/pmd/custom.xml
----------------------------------------------------------------------
diff --git a/config/pmd/custom.xml b/config/pmd/custom.xml
new file mode 100644
index 0000000..7026d04
--- /dev/null
+++ b/config/pmd/custom.xml
@@ -0,0 +1,86 @@
+<?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.
+-->
+
+<ruleset name="Aurora"
+         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>
+    Custom Aurora PMD rules.
+  </description>
+
+  <rule name="TimedAnnotationNonOverridableMethod"
+        language="java"
+        class="net.sourceforge.pmd.lang.rule.XPathRule"
+        message="A method must be overridable to have the @Timed annotation.">
+    <description>
+      A method must be overridable (non-static, non-final, public, protected or package-private)
+      in order to be used with the @Timed annotation. See: https://github.com/google/guice/wiki/AOP.
+    </description>
+    <priority>1</priority>
+    <properties>
+      <property name="xpath">
+        <value>
+          <![CDATA[
+//ClassOrInterfaceBodyDeclaration[MethodDeclaration]
+[count(./Annotation//Name[@Image='Timed']) > 0]
+[count(./MethodDeclaration[(@Static = 'true') or (@Final = 'true') or (@Private = 'true')]) > 0]
+            ]]>
+        </value>
+      </property>
+    </properties>
+    <example>
+      <![CDATA[
+  public class Foo {
+      @Timed
+      // Must be non-static, non-final, public, protected or package-private.
+      protected Foo() { }
+  }
+       ]]>
+    </example>
+  </rule>
+
+  <rule name="TimedAnnotationNonOverridableClass"
+        language="java"
+        class="net.sourceforge.pmd.lang.rule.XPathRule"
+        message="A class must be non-final, public or package-private to have methods with the @Timed annotation.">
+    <description>
+      A class must be non-final, public or package-private to have methods with the @Timed
+      annotation. See: https://github.com/google/guice/wiki/AOP.
+    </description>
+    <priority>1</priority>
+    <properties>
+      <property name="xpath">
+        <value>
+          <![CDATA[
+//ClassOrInterfaceDeclaration[(@Final = 'true') or (@Private = 'true') or (@Protected = 'true')]
+/ClassOrInterfaceBody/ClassOrInterfaceBodyDeclaration/Annotation//Name[@Image='Timed']
+            ]]>
+        </value>
+      </property>
+    </properties>
+    <example>
+      <![CDATA[
+  // Must be non-final, public or package-private
+  class Foo {
+      @Timed
+      public Foo() { }
+  }
+       ]]>
+    </example>
+  </rule>
+
+</ruleset>