aboutsummaryrefslogtreecommitdiff
path: root/config
diff options
context:
space:
mode:
authorRoman Ivanov <ivanov-jr@mail.ru>2015-10-08 17:14:01 -0700
committerRoman Ivanov <ivanov-jr@mail.ru>2015-10-08 17:14:01 -0700
commit947b30dd6eb589f265ee061a99801064a2ae6fe4 (patch)
tree09a4ceb45e7641600e5dfaa4f630e51ddbf5fefa /config
parenta75c64efe39a5c4391faf8ec2fba07ae76411a0e (diff)
downloadcheckstyle-947b30dd6eb589f265ee061a99801064a2ae6fe4.tar.gz
Issue #985: Fix PMD violations for ShortVariable rule (final)
Diffstat (limited to 'config')
-rw-r--r--config/pmd.xml25
1 files changed, 24 insertions, 1 deletions
diff --git a/config/pmd.xml b/config/pmd.xml
index 54b521476..fc6dabd6c 100644
--- a/config/pmd.xml
+++ b/config/pmd.xml
@@ -190,9 +190,32 @@
<rule ref="rulesets/java/migrating.xml"/>
<rule ref="rulesets/java/naming.xml">
- <!-- till #985 -->
+ <!-- we use CheckstyleCustomShortVariable, to control lenght (will be fixed in PMD 5.4) and skip Override methods -->
<exclude name="ShortVariable"/>
</rule>
+<rule name="CheckstyleCustomShortVariable"
+ message="Avoid variables with short names that shorter than 2 symbols: {0}"
+ language="java"
+ class="net.sourceforge.pmd.lang.rule.XPathRule"
+ externalInfoUrl="">
+<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) < 2]
+ [not(ancestor::ForInit)]
+ [not(../../VariableDeclarator and ../../../LocalVariableDeclaration and ../../../../ForStatement)]
+ [not((ancestor::FormalParameter) and (ancestor::TryStatement))]
+ [not(ancestor::ClassOrInterfaceDeclaration[//MarkerAnnotation/Name[pmd-java:typeof(@Image, 'java.lang.Override', 'Override')]])]
+ ]]>
+ </value>
+ </property>
+</properties>
+</rule>
<rule ref="rulesets/java/naming.xml/AbstractNaming">
<properties>
<!-- We can not brake compatibility with previous versions -->