Update documentation
TRAVIS_JOB_NUMBER=2740.1 TRAVIS_COMMIT_RANGE=e90e01b69582...6684c58bfb0c
This commit is contained in:
1 parent
6684c58bfb
commit
2feac39d2f
2 files changed
+54
-1
No files matched your search
@@ -79,6 +79,7 @@ folder: pmd/rules
|
||||
* [EmptyMethodInAbstractClassShouldBeAbstract](pmd_rules_java_codestyle.html#emptymethodinabstractclassshouldbeabstract): Empty or auto-generated methods in an abstract class should be tagged as abstract. This helps to ...
|
||||
* [ExtendsObject](pmd_rules_java_codestyle.html#extendsobject): No need to explicitly extend Object.
|
||||
* [FieldDeclarationsShouldBeAtStartOfClass](pmd_rules_java_codestyle.html#fielddeclarationsshouldbeatstartofclass): Fields should be declared at the top of the class, before any method declarations, constructors, ...
|
||||
* [FieldNamingConventions](pmd_rules_java_codestyle.html#fieldnamingconventions): Configurable naming conventions for field declarations. This rule reports variable declarations ...
|
||||
* [ForLoopShouldBeWhileLoop](pmd_rules_java_codestyle.html#forloopshouldbewhileloop): Some for loops can be simplified to while loops, this makes them more concise.
|
||||
* [ForLoopsMustUseBraces](pmd_rules_java_codestyle.html#forloopsmustusebraces): <span style="border-radius: 0.25em; color: #fff; padding: 0.2em 0.6em 0.3em; display: inline; background-color: #d9534f; font-size: 75%;">Deprecated</span> Avoid using 'for' statements without using curly braces. If the code formatting or indentation is...
|
||||
* [FormalParameterNamingConventions](pmd_rules_java_codestyle.html#formalparameternamingconventions): Configurable naming conventions for formal parameters of methods and lambdas. This rul...
|
||||
|
||||
@@ -5,7 +5,7 @@ permalink: pmd_rules_java_codestyle.html
|
||||
folder: pmd/rules/java
|
||||
sidebaractiveurl: /pmd_rules_java.html
|
||||
editmepath: ../pmd-java/src/main/resources/category/java/codestyle.xml
|
||||
keywords: Code Style, AbstractNaming, AtLeastOneConstructor, AvoidDollarSigns, AvoidFinalLocalVariable, AvoidPrefixingMethodParameters, AvoidProtectedFieldInFinalClass, AvoidProtectedMethodInFinalClassNotExtending, AvoidUsingNativeCode, BooleanGetMethodName, CallSuperInConstructor, ClassNamingConventions, CommentDefaultAccessModifier, ConfusingTernary, ControlStatementBraces, DefaultPackage, DontImportJavaLang, DuplicateImports, EmptyMethodInAbstractClassShouldBeAbstract, ExtendsObject, FieldDeclarationsShouldBeAtStartOfClass, ForLoopShouldBeWhileLoop, ForLoopsMustUseBraces, FormalParameterNamingConventions, GenericsNaming, IdenticalCatchBranches, IfElseStmtsMustUseBraces, IfStmtsMustUseBraces, LinguisticNaming, LocalHomeNamingConvention, LocalInterfaceSessionNamingConvention, LocalVariableCouldBeFinal, LocalVariableNamingConventions, LongVariable, MDBAndSessionBeanNamingConvention, MethodArgumentCouldBeFinal, MethodNamingConventions, MIsLeadingVariableName, NoPackage, OnlyOneReturn, PackageCase, PrematureDeclaration, RemoteInterfaceNamingConvention, RemoteSessionInterfaceNamingConvention, ShortClassName, ShortMethodName, ShortVariable, SuspiciousConstantFieldName, TooManyStaticImports, UnnecessaryAnnotationValueElement, UnnecessaryConstructor, UnnecessaryFullyQualifiedName, UnnecessaryLocalBeforeReturn, UnnecessaryModifier, UnnecessaryReturn, UselessParentheses, UselessQualifiedThis, VariableNamingConventions, WhileLoopsMustUseBraces
|
||||
keywords: Code Style, AbstractNaming, AtLeastOneConstructor, AvoidDollarSigns, AvoidFinalLocalVariable, AvoidPrefixingMethodParameters, AvoidProtectedFieldInFinalClass, AvoidProtectedMethodInFinalClassNotExtending, AvoidUsingNativeCode, BooleanGetMethodName, CallSuperInConstructor, ClassNamingConventions, CommentDefaultAccessModifier, ConfusingTernary, ControlStatementBraces, DefaultPackage, DontImportJavaLang, DuplicateImports, EmptyMethodInAbstractClassShouldBeAbstract, ExtendsObject, FieldDeclarationsShouldBeAtStartOfClass, FieldNamingConventions, ForLoopShouldBeWhileLoop, ForLoopsMustUseBraces, FormalParameterNamingConventions, GenericsNaming, IdenticalCatchBranches, IfElseStmtsMustUseBraces, IfStmtsMustUseBraces, LinguisticNaming, LocalHomeNamingConvention, LocalInterfaceSessionNamingConvention, LocalVariableCouldBeFinal, LocalVariableNamingConventions, LongVariable, MDBAndSessionBeanNamingConvention, MethodArgumentCouldBeFinal, MethodNamingConventions, MIsLeadingVariableName, NoPackage, OnlyOneReturn, PackageCase, PrematureDeclaration, RemoteInterfaceNamingConvention, RemoteSessionInterfaceNamingConvention, ShortClassName, ShortMethodName, ShortVariable, SuspiciousConstantFieldName, TooManyStaticImports, UnnecessaryAnnotationValueElement, UnnecessaryConstructor, UnnecessaryFullyQualifiedName, UnnecessaryLocalBeforeReturn, UnnecessaryModifier, UnnecessaryReturn, UselessParentheses, UselessQualifiedThis, VariableNamingConventions, WhileLoopsMustUseBraces
|
||||
language: Java
|
||||
---
|
||||
## AbstractNaming
|
||||
@@ -756,6 +756,58 @@ public class HelloWorldBean {
|
||||
<rule ref="category/java/codestyle.xml/FieldDeclarationsShouldBeAtStartOfClass" />
|
||||
```
|
||||
|
||||
## FieldNamingConventions
|
||||
|
||||
**Since:** PMD 6.7.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),
|
||||
enum constant, final field. Each regex can be configured through properties.
|
||||
|
||||
By default this rule uses the standard Java naming convention (Camel case), and uses the ALL_UPPER
|
||||
convention for constants and enum constants.
|
||||
|
||||
**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.java.rule.codestyle.FieldNamingConventionsRule](https://github.com/pmd/pmd/blob/master/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/codestyle/FieldNamingConventionsRule.java)
|
||||
|
||||
**Example(s):**
|
||||
|
||||
``` java
|
||||
class Foo {
|
||||
int myField = 1; // This is in camel case, so it's ok
|
||||
int my_Field = 1; // This contains an underscore, it's not ok by default
|
||||
// but you may allow it, or even require the "my_" prefix
|
||||
|
||||
final int FinalField = 1; // you may configure a different convention for final fields,
|
||||
// e.g. here PascalCase: [A-Z][a-zA-Z0-9]*
|
||||
|
||||
interface Interface {
|
||||
double PI = 3.14; // interface "fields" use the constantPattern property
|
||||
}
|
||||
|
||||
enum AnEnum {
|
||||
ORG, NET, COM; // These use a separate property but are set to ALL_UPPER by default
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
**This rule has the following properties:**
|
||||
|
||||
|Name|Default Value|Description|Multivalued|
|
||||
|----|-------------|-----------|-----------|
|
||||
|publicConstantPattern|[A-Z][A-Z_0-9]*|Regex which applies to public constant names|no|
|
||||
|constantPattern|[A-Z][A-Z_0-9]*|Regex which applies to non-public static final field names|no|
|
||||
|enumConstantPattern|[A-Z][A-Z_0-9]*|Regex which applies to enum constant names|no|
|
||||
|finalFieldPattern|[a-z][a-zA-Z0-9]*|Regex which applies to final field names|no|
|
||||
|staticFieldPattern|[a-z][a-zA-Z0-9]*|Regex which applies to static field names|no|
|
||||
|defaultFieldPattern|[a-z][a-zA-Z0-9]*|Regex which applies to field names|no|
|
||||
|
||||
**Use this rule by referencing it:**
|
||||
``` xml
|
||||
<rule ref="category/java/codestyle.xml/FieldNamingConventions" />
|
||||
```
|
||||
|
||||
## ForLoopShouldBeWhileLoop
|
||||
|
||||
**Since:** PMD 1.02
|
||||
|
||||
Reference in new issue
Block a user