Naming RulesThe Naming Ruleset contains a collection of rules about names - too long, too short, and so forth. ShortVariableDetects when a field, local or parameter has a short name. This rule is defined by the following XPath expression: //VariableDeclaratorId[string-length(@Image) < 3] [not(ancestor::ForInit)] [not((ancestor::FormalParameter) and (ancestor::TryStatement))] Here's an example of code that would trigger this rule: public class Something { private int q = 15; // VIOLATION - Field public static void main( String as[] ) { // VIOLATION - Formal int r = 20 + q; // VIOLATION - Local for (int i = 0; i < 10; i++) { // Not a Violation (inside FOR) r += q; } } } LongVariableDetects when a field, formal or local variable is declared with a big name. This rule is defined by the following XPath expression: //VariableDeclaratorId[string-length(@Image) > 12] Here's an example of code that would trigger this rule: 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 ++ ) { } } ShortMethodNameRuleDetects when very short method names are used. This rule is defined by the following XPath expression: //MethodDeclarator[string-length(@Image) < 3] Here's an example of code that would trigger this rule: public class ShortMethod { public void a( int i ) { // Violation } } VariableNamingConventionsRuleA variable naming conventions rule - customize this to your liking Final variables should be all caps Non-final variables should not include underscores Here's an example of code that would trigger this rule: public class Foo { public static final int MY_NUM = 0; public String myTest = ""; DataModule dmTest = new DataModule(); } MethodNamingConventionsMethod names should always begin with a lower case character, and should not contain underscores. Here's an example of code that would trigger this rule: public class Foo { public void fooStuff() { } } ClassNamingConventionsRuleClass names should always begin with an upper case character, and should not contain underscores. Here's an example of code that would trigger this rule: public class Foo {} |