From bf51f15834c3b67f6ba1aebf114dd823069a7f3c Mon Sep 17 00:00:00 2001 From: "Travis CI (pmd-bot)" Date: Fri, 17 May 2019 14:51:36 +0000 Subject: [PATCH] Update documentation TRAVIS_JOB_NUMBER=3757.1 TRAVIS_COMMIT_RANGE=8d21fd52b345...7defd6b501d7 --- docs/pages/pmd/rules/apex.md | 10 +- docs/pages/pmd/rules/apex/codestyle.md | 270 ++++++++++++++++++++++++- 2 files changed, 267 insertions(+), 13 deletions(-) diff --git a/docs/pages/pmd/rules/apex.md b/docs/pages/pmd/rules/apex.md index dec0347f36..d9d4ef3d06 100644 --- a/docs/pages/pmd/rules/apex.md +++ b/docs/pages/pmd/rules/apex.md @@ -22,13 +22,17 @@ folder: pmd/rules {% include callout.html content="Rules which enforce a specific coding style." %} -* [ClassNamingConventions](pmd_rules_apex_codestyle.html#classnamingconventions): Class names should always begin with an upper case character. +* [ClassNamingConventions](pmd_rules_apex_codestyle.html#classnamingconventions): Configurable naming conventions for type declarations. This rule reports type declarat... +* [FieldNamingConventions](pmd_rules_apex_codestyle.html#fieldnamingconventions): Configurable naming conventions for field declarations. This rule reports variable declarations ... * [ForLoopsMustUseBraces](pmd_rules_apex_codestyle.html#forloopsmustusebraces): Avoid using 'for' statements without using surrounding braces. If the code formatting orindentati... +* [FormalParameterNamingConventions](pmd_rules_apex_codestyle.html#formalparameternamingconventions): Configurable naming conventions for formal parameters of methods. This rule reports fo... * [IfElseStmtsMustUseBraces](pmd_rules_apex_codestyle.html#ifelsestmtsmustusebraces): Avoid using if..else statements without using surrounding braces. If the code formattingor indent... * [IfStmtsMustUseBraces](pmd_rules_apex_codestyle.html#ifstmtsmustusebraces): Avoid using if statements without using braces to surround the code block. If the codeformatting ... -* [MethodNamingConventions](pmd_rules_apex_codestyle.html#methodnamingconventions): Method names should always begin with a lower case character, and should not contain underscores. +* [LocalVariableNamingConventions](pmd_rules_apex_codestyle.html#localvariablenamingconventions): Configurable naming conventions for local variable declarations. This rule reports var... +* [MethodNamingConventions](pmd_rules_apex_codestyle.html#methodnamingconventions): Configurable naming conventions for method declarations. This rule reports method decl... * [OneDeclarationPerLine](pmd_rules_apex_codestyle.html#onedeclarationperline): Apex allows the use of several variables declaration of the same type on one line. However, itcan... -* [VariableNamingConventions](pmd_rules_apex_codestyle.html#variablenamingconventions): A variable naming conventions rule - customize this to your liking. Currently, itchecks for fina... +* [PropertyNamingConventions](pmd_rules_apex_codestyle.html#propertynamingconventions): Configurable naming conventions for property declarations. This rule reports property ... +* [VariableNamingConventions](pmd_rules_apex_codestyle.html#variablenamingconventions): Deprecated A variable naming conventions rule - customize this to your liking. Currently, itchecks for fina... * [WhileLoopsMustUseBraces](pmd_rules_apex_codestyle.html#whileloopsmustusebraces): Avoid using 'while' statements without using braces to surround the code block. If the codeformat... ## Design diff --git a/docs/pages/pmd/rules/apex/codestyle.md b/docs/pages/pmd/rules/apex/codestyle.md index 7f8f72b1a5..c6286feaa7 100644 --- a/docs/pages/pmd/rules/apex/codestyle.md +++ b/docs/pages/pmd/rules/apex/codestyle.md @@ -5,7 +5,7 @@ permalink: pmd_rules_apex_codestyle.html folder: pmd/rules/apex sidebaractiveurl: /pmd_rules_apex.html editmepath: ../pmd-apex/src/main/resources/category/apex/codestyle.xml -keywords: Code Style, ClassNamingConventions, IfElseStmtsMustUseBraces, IfStmtsMustUseBraces, ForLoopsMustUseBraces, MethodNamingConventions, OneDeclarationPerLine, VariableNamingConventions, WhileLoopsMustUseBraces +keywords: Code Style, ClassNamingConventions, IfElseStmtsMustUseBraces, IfStmtsMustUseBraces, FieldNamingConventions, ForLoopsMustUseBraces, FormalParameterNamingConventions, LocalVariableNamingConventions, MethodNamingConventions, OneDeclarationPerLine, PropertyNamingConventions, VariableNamingConventions, WhileLoopsMustUseBraces language: Apex --- @@ -15,14 +15,21 @@ language: Apex **Priority:** High (1) -Class names should always begin with an upper case character. +Configurable naming conventions for type declarations. This rule reports +type declarations which do not match the regex that applies to their +specific kind (e.g. enum or interface). Each regex can be configured through +properties. + +By default this rule uses the standard Apex naming convention (Pascal case). **This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.apex.rule.codestyle.ClassNamingConventionsRule](https://github.com/pmd/pmd/blob/master/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/codestyle/ClassNamingConventionsRule.java) **Example(s):** ``` java -public class Foo {} +public class FooClass { } // This is in pascal case, so it's ok + +public class fooClass { } // This will be reported unless you change the regex ``` **This rule has the following properties:** @@ -32,12 +39,85 @@ public class Foo {} |cc\_categories|Style|Deprecated Code Climate Categories|yes. Delimiter is '\|'.| |cc\_remediation\_points\_multiplier|5|Deprecated Code Climate Remediation Points multiplier|no| |cc\_block\_highlighting|false|Deprecated Code Climate Block Highlighting|no| +|testClassPattern|\[A-Z\]\[a-zA-Z0-9\_\]\*|Regex which applies to test class names|no| +|abstractClassPattern|\[A-Z\]\[a-zA-Z0-9\_\]\*|Regex which applies to abstract class names|no| +|classPattern|\[A-Z\]\[a-zA-Z0-9\_\]\*|Regex which applies to class names|no| +|interfacePattern|\[A-Z\]\[a-zA-Z0-9\_\]\*|Regex which applies to interface names|no| +|enumPattern|\[A-Z\]\[a-zA-Z0-9\_\]\*|Regex which applies to enum names|no| **Use this rule with the default properties by just referencing it:** ``` xml ``` +**Use this rule and customize it:** +``` xml + + + + + + + + + +``` + +## FieldNamingConventions + +**Since:** PMD 6.15.0 + +**Priority:** High (1) + +Configurable naming conventions for field declarations. This rule reports variable declarations +which do not match the regex that applies to their specific kind ---e.g. constants (static final), +static field, final field. Each regex can be configured through properties. + +By default this rule uses the standard Apex naming convention (Camel case). + +**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.apex.rule.codestyle.FieldNamingConventionsRule](https://github.com/pmd/pmd/blob/master/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/codestyle/FieldNamingConventionsRule.java) + +**Example(s):** + +``` java +public class Foo { + Integer instanceField; // This is in camel case, so it's ok + + Integer INSTANCE_FIELD; // This will be reported unless you change the regex +} +``` + +**This rule has the following properties:** + +|Name|Default Value|Description|Multivalued| +|----|-------------|-----------|-----------| +|cc\_categories|Style|Deprecated Code Climate Categories|yes. Delimiter is '\|'.| +|cc\_remediation\_points\_multiplier|1|Deprecated Code Climate Remediation Points multiplier|no| +|cc\_block\_highlighting|false|Deprecated Code Climate Block Highlighting|no| +|enumConstantPattern|\[A-Z\]\[A-Z0-9\_\]\*|Regex which applies to enum constant field names|no| +|constantPattern|\[A-Z\]\[A-Z0-9\_\]\*|Regex which applies to constant field names|no| +|finalPattern|\[a-z\]\[a-zA-Z0-9\]\*|Regex which applies to final field names|no| +|staticPattern|\[a-z\]\[a-zA-Z0-9\]\*|Regex which applies to static field names|no| +|instancePattern|\[a-z\]\[a-zA-Z0-9\]\*|Regex which applies to instance field names|no| + +**Use this rule with the default properties by just referencing it:** +``` xml + +``` + +**Use this rule and customize it:** +``` xml + + + + + + + + + +``` + ## ForLoopsMustUseBraces **Since:** PMD 5.6.0 @@ -79,6 +159,56 @@ for (int i = 0; i < 42; i++) { // preferred approach ``` +## FormalParameterNamingConventions + +**Since:** PMD 6.15.0 + +**Priority:** High (1) + +Configurable naming conventions for formal parameters of methods. +This rule reports formal parameters which do not match the regex that applies to their +specific kind (e.g. method parameter, or final method parameter). Each regex can be +configured through properties. + +By default this rule uses the standard Apex naming convention (Camel case). + +**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.apex.rule.codestyle.FormalParameterNamingConventionsRule](https://github.com/pmd/pmd/blob/master/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/codestyle/FormalParameterNamingConventionsRule.java) + +**Example(s):** + +``` java +public class Foo { + public bar(Integer methodParameter) { } // This is in camel case, so it's ok + + public baz(Integer METHOD_PARAMETER) { } // This will be reported unless you change the regex +} +``` + +**This rule has the following properties:** + +|Name|Default Value|Description|Multivalued| +|----|-------------|-----------|-----------| +|cc\_categories|Style|Deprecated Code Climate Categories|yes. Delimiter is '\|'.| +|cc\_remediation\_points\_multiplier|1|Deprecated Code Climate Remediation Points multiplier|no| +|cc\_block\_highlighting|false|Deprecated Code Climate Block Highlighting|no| +|finalMethodParameterPattern|\[a-z\]\[a-zA-Z0-9\]\*|Regex which applies to final method parameter names|no| +|methodParameterPattern|\[a-z\]\[a-zA-Z0-9\]\*|Regex which applies to method parameter names|no| + +**Use this rule with the default properties by just referencing it:** +``` xml + +``` + +**Use this rule and customize it:** +``` xml + + + + + + +``` + ## IfElseStmtsMustUseBraces **Since:** PMD 5.6.0 @@ -161,21 +291,29 @@ if (foo) { // preferred approach ``` -## MethodNamingConventions +## LocalVariableNamingConventions -**Since:** PMD 5.5.0 +**Since:** PMD 6.15.0 **Priority:** High (1) -Method names should always begin with a lower case character, and should not contain underscores. +Configurable naming conventions for local variable declarations. +This rule reports variable declarations which do not match the regex that applies to their +specific kind (e.g. local variable, or final local variable). Each regex can be configured through +properties. -**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.apex.rule.codestyle.MethodNamingConventionsRule](https://github.com/pmd/pmd/blob/master/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/codestyle/MethodNamingConventionsRule.java) +By default this rule uses the standard Apex naming convention (Camel case). + +**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.apex.rule.codestyle.LocalVariableNamingConventionsRule](https://github.com/pmd/pmd/blob/master/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/codestyle/LocalVariableNamingConventionsRule.java) **Example(s):** ``` java public class Foo { - public void fooStuff() { + public Foo() { + Integer localVariable; // This is in camel case, so it's ok + + Integer LOCAL_VARIABLE; // This will be reported unless you change the regex } } ``` @@ -187,7 +325,59 @@ public class Foo { |cc\_categories|Style|Deprecated Code Climate Categories|yes. Delimiter is '\|'.| |cc\_remediation\_points\_multiplier|1|Deprecated Code Climate Remediation Points multiplier|no| |cc\_block\_highlighting|false|Deprecated Code Climate Block Highlighting|no| -|skipTestMethodUnderscores|false|Skip underscores in test methods|no| +|finalLocalPattern|\[a-z\]\[a-zA-Z0-9\]\*|Regex which applies to final local variable names|no| +|localPattern|\[a-z\]\[a-zA-Z0-9\]\*|Regex which applies to local variable names|no| + +**Use this rule with the default properties by just referencing it:** +``` xml + +``` + +**Use this rule and customize it:** +``` xml + + + + + + +``` + +## MethodNamingConventions + +**Since:** PMD 5.5.0 + +**Priority:** High (1) + +Configurable naming conventions for method declarations. This rule reports +method declarations which do not match the regex that applies to their +specific kind (e.g. static method, or test method). Each regex can be +configured through properties. + +By default this rule uses the standard Apex naming convention (Camel case). + +**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.apex.rule.codestyle.MethodNamingConventionsRule](https://github.com/pmd/pmd/blob/master/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/codestyle/MethodNamingConventionsRule.java) + +**Example(s):** + +``` java +public class Foo { + public void instanceMethod() { } // This is in camel case, so it's ok + + public void INSTANCE_METHOD() { } // This will be reported unless you change the regex +``` + +**This rule has the following properties:** + +|Name|Default Value|Description|Multivalued| +|----|-------------|-----------|-----------| +|cc\_categories|Style|Deprecated Code Climate Categories|yes. Delimiter is '\|'.| +|cc\_remediation\_points\_multiplier|1|Deprecated Code Climate Remediation Points multiplier|no| +|cc\_block\_highlighting|false|Deprecated Code Climate Block Highlighting|no| +|skipTestMethodUnderscores|false|Deprecated Skip underscores in test methods|no| +|testPattern|\[a-z\]\[a-zA-Z0-9\]\*|Regex which applies to test method names|no| +|staticPattern|\[a-z\]\[a-zA-Z0-9\]\*|Regex which applies to static method names|no| +|instancePattern|\[a-z\]\[a-zA-Z0-9\]\*|Regex which applies to instance method names|no| **Use this rule with the default properties by just referencing it:** ``` xml @@ -198,7 +388,9 @@ public class Foo { ``` xml - + + + ``` @@ -258,8 +450,60 @@ Integer b; ``` +## PropertyNamingConventions + +**Since:** PMD 6.15.0 + +**Priority:** High (1) + +Configurable naming conventions for property declarations. This rule reports +property declarations which do not match the regex that applies to their +specific kind (e.g. static property, or instance property). Each regex can be +configured through properties. + +By default this rule uses the standard Apex naming convention (Camel case). + +**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.apex.rule.codestyle.PropertyNamingConventionsRule](https://github.com/pmd/pmd/blob/master/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/codestyle/PropertyNamingConventionsRule.java) + +**Example(s):** + +``` java +public class Foo { + public Integer instanceProperty { get; set; } // This is in camel case, so it's ok + + public Integer INSTANCE_PROPERTY { get; set; } // This will be reported unless you change the regex +} +``` + +**This rule has the following properties:** + +|Name|Default Value|Description|Multivalued| +|----|-------------|-----------|-----------| +|cc\_categories|Style|Deprecated Code Climate Categories|yes. Delimiter is '\|'.| +|cc\_remediation\_points\_multiplier|1|Deprecated Code Climate Remediation Points multiplier|no| +|cc\_block\_highlighting|false|Deprecated Code Climate Block Highlighting|no| +|staticPattern|\[a-z\]\[a-zA-Z0-9\]\*|Regex which applies to static property names|no| +|instancePattern|\[a-z\]\[a-zA-Z0-9\]\*|Regex which applies to instance property names|no| + +**Use this rule with the default properties by just referencing it:** +``` xml + +``` + +**Use this rule and customize it:** +``` xml + + + + + + +``` + ## VariableNamingConventions +Deprecated + **Since:** PMD 5.5.0 **Priority:** High (1) @@ -268,6 +512,12 @@ A variable naming conventions rule - customize this to your liking. Currently, checks for final variables that should be fully capitalized and non-final variables that should not include underscores. +This rule is deprecated and will be removed with PMD 7.0.0. The rule is replaced +by the more general rules {% rule "apex/codestyle/FieldNamingConventions" %}, +{% rule "apex/codestyle/FormalParameterNamingConventions" %}, +{% rule "apex/codestyle/LocalVariableNamingConventions" %}, and +{% rule "apex/codestyle/PropertyNamingConventions" %}. + **This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.apex.rule.codestyle.VariableNamingConventionsRule](https://github.com/pmd/pmd/blob/master/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/codestyle/VariableNamingConventionsRule.java) **Example(s):**