From ac5d1135aa9b1926f80ae19e71808273914ef1a1 Mon Sep 17 00:00:00 2001 From: "Justin M. Stroud" Date: Mon, 3 Jun 2024 02:54:18 -0700 Subject: [PATCH] Added inner classes to ClassNamingConventionsRule, and added property to support name checking for inner classes. --- .../apex/rule/codestyle/ClassNamingConventionsRule.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/codestyle/ClassNamingConventionsRule.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/codestyle/ClassNamingConventionsRule.java index 11f0a0cd9b..894bd09eba 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/codestyle/ClassNamingConventionsRule.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/codestyle/ClassNamingConventionsRule.java @@ -22,6 +22,9 @@ public class ClassNamingConventionsRule extends AbstractNamingConventionsRule { private static final PropertyDescriptor TEST_CLASS_REGEX = prop("testClassPattern", "test class", DESCRIPTOR_TO_DISPLAY_NAME).defaultValue(PASCAL_CASE_WITH_UNDERSCORES).build(); + private static final PropertyDescriptor INNER_CLASS_REGEX = prop("innerClassPattern", "inner class", + DESCRIPTOR_TO_DISPLAY_NAME).defaultValue(PASCAL_CASE_WITH_UNDERSCORES).build(); + private static final PropertyDescriptor ABSTRACT_CLASS_REGEX = prop("abstractClassPattern", "abstract class", DESCRIPTOR_TO_DISPLAY_NAME).defaultValue(PASCAL_CASE_WITH_UNDERSCORES).build(); @@ -36,6 +39,7 @@ public class ClassNamingConventionsRule extends AbstractNamingConventionsRule { public ClassNamingConventionsRule() { definePropertyDescriptor(TEST_CLASS_REGEX); + definePropertyDescriptor(INNER_CLASS_REGEX); definePropertyDescriptor(ABSTRACT_CLASS_REGEX); definePropertyDescriptor(CLASS_REGEX); definePropertyDescriptor(INTERFACE_REGEX); @@ -53,6 +57,8 @@ public class ClassNamingConventionsRule extends AbstractNamingConventionsRule { checkMatches(TEST_CLASS_REGEX, node, data); } else if (node.getModifiers().isAbstract()) { checkMatches(ABSTRACT_CLASS_REGEX, node, data); + } else if (node.getParent() instanceof ASTUserClass) { + checkMatches(INNER_CLASS_REGEX, node, data); } else { checkMatches(CLASS_REGEX, node, data); }