71 lines
1.7 KiB
Plaintext
71 lines
1.7 KiB
Plaintext
== Why is this an issue?
|
|
|
|
The Java Language Specification defines a set of rules called naming conventions that apply to Java programs.
|
|
These conventions provide recommendations for naming packages, classes, methods, and variables.
|
|
|
|
By following shared naming conventions, teams can collaborate more efficiently.
|
|
|
|
This rule checks that static non-final field names match a provided regular expression.
|
|
|
|
=== Noncompliant code example
|
|
|
|
The default regular expression applied by the rule is `^[a-z][a-zA-Z0-9]*$`:
|
|
|
|
[source,java,diff-id=1,diff-type=noncompliant]
|
|
----
|
|
public class MyClass {
|
|
private static String foo_bar; // Noncompliant
|
|
}
|
|
----
|
|
|
|
=== Compliant solution
|
|
|
|
[source,java,diff-id=1,diff-type=compliant]
|
|
----
|
|
public class MyClass {
|
|
private static String fooBar;
|
|
}
|
|
----
|
|
|
|
== Resources
|
|
|
|
* https://www.oreilly.com/library/view/java-8-pocket/9781491901083/ch01.html[O'Reilly - Java 8 in pocket - Naming Conventions]
|
|
* https://www.educative.io/answers/what-are-the-naming-conventions-in-java[Educative - Naming conventions in Java]
|
|
|
|
ifdef::env-github,rspecator-view[]
|
|
|
|
'''
|
|
== Implementation Specification
|
|
(visible only on this page)
|
|
|
|
=== Message
|
|
|
|
Rename this field "XXX" to match the regular expression ${format}.
|
|
|
|
=== Parameters
|
|
|
|
.format
|
|
****
|
|
|
|
----
|
|
^[a-z][a-zA-Z0-9]*$
|
|
----
|
|
|
|
Regular expression used to check the field names against.
|
|
****
|
|
|
|
'''
|
|
== Comments And Links
|
|
(visible only on this page)
|
|
|
|
=== on 9 Jun 2015, 13:45:21 Ann Campbell wrote:
|
|
FYI [~alexandre.gigleux] I've made a few updates.
|
|
|
|
=== on 9 Jun 2015, 13:48:13 Ann Campbell wrote:
|
|
Note for Java: same as RSPEC-116 but for static non-final fields
|
|
|
|
=== on 12 Jun 2015, 16:04:59 Ann Campbell wrote:
|
|
CodePro: Static Field Naming Convention
|
|
|
|
endif::env-github,rspecator-view[]
|