From 59eaa27c59455d6bb430b4b989f2e0931075e382 Mon Sep 17 00:00:00 2001 From: Romain Pelisse Date: Fri, 4 Dec 2009 13:37:26 +0000 Subject: [PATCH] Adding a new rule : GenericsNaming Thanks to Nicolas Dordet for his inputs on this one. git-svn-id: https://pmd.svn.sourceforge.net/svnroot/pmd/branches/pmd/4.2.x@7009 51baf565-9d33-0410-a72c-fc3788e3496d --- pmd/etc/changelog.txt | 1 + .../pmd/rules/naming/NamingRulesTest.java | 1 + .../pmd/rules/naming/xml/GenericsNaming.xml | 47 ++++++++++++++++++ pmd/rulesets/naming.xml | 49 +++++++++++++++++++ 4 files changed, 98 insertions(+) create mode 100644 pmd/regress/test/net/sourceforge/pmd/rules/naming/xml/GenericsNaming.xml diff --git a/pmd/etc/changelog.txt b/pmd/etc/changelog.txt index b5625b8ee2..f3799ae254 100644 --- a/pmd/etc/changelog.txt +++ b/pmd/etc/changelog.txt @@ -21,6 +21,7 @@ New rule: Android: DoNotHardCodeSDCard Controversial : AvoidLiteralsInIfCondition (patch 2591627), UseConcurrentHashMap StrictExceptions : AvoidCatchingGenericException, AvoidLosingExceptionInformation + Naming : GenericsNaming February 08, 2009 - 4.2.5: diff --git a/pmd/regress/test/net/sourceforge/pmd/rules/naming/NamingRulesTest.java b/pmd/regress/test/net/sourceforge/pmd/rules/naming/NamingRulesTest.java index 5babe69fea..9ce2520fcf 100644 --- a/pmd/regress/test/net/sourceforge/pmd/rules/naming/NamingRulesTest.java +++ b/pmd/regress/test/net/sourceforge/pmd/rules/naming/NamingRulesTest.java @@ -26,6 +26,7 @@ public class NamingRulesTest extends SimpleAggregatorTst { addRule("naming", "SuspiciousEqualsMethodName"); addRule("naming", "SuspiciousHashcodeMethodName"); addRule("naming", "VariableNamingConventions"); + addRule("naming", "GenericsNaming"); } public static junit.framework.Test suite() { diff --git a/pmd/regress/test/net/sourceforge/pmd/rules/naming/xml/GenericsNaming.xml b/pmd/regress/test/net/sourceforge/pmd/rules/naming/xml/GenericsNaming.xml new file mode 100644 index 0000000000..bd698a9416 --- /dev/null +++ b/pmd/regress/test/net/sourceforge/pmd/rules/naming/xml/GenericsNaming.xml @@ -0,0 +1,47 @@ + + + + + 0 + +{ +} + ]]> + + + + 0 + +{ +} + ]]> + + + + 1 + +{ +} + ]]> + + + + 1 + +{ +} + ]]> + + diff --git a/pmd/rulesets/naming.xml b/pmd/rulesets/naming.xml index 2eef174ddc..b4318421b0 100644 --- a/pmd/rulesets/naming.xml +++ b/pmd/rulesets/naming.xml @@ -507,4 +507,53 @@ public boolean getFoo(boolean bar); // ok, unless checkParameterizedMethods=true ]]> + + +Generics names should be a one letter long and upper case. + + 4 + + + + 1 + or + string:upper-case(@Image) != @Image +] +]]> + + + + + extends BaseDao +{ + // This is ok... +} + +public interface GenericDao +{ + // Also this +} + +public interface GenericDao +{ + // 'e' should be an 'E' +} + +public interface GenericDao +{ + // 'EF' is not ok. +} + + + + ]]> + +