include::../common/introduction.adoc[]

== Why is this an issue?

include::../common/why-is-this-an-issue.adoc[]

include::../common/why-is-this-an-issue-thread-safety.adoc[]

include::../common/rule-behaviour.adoc[]

=== What is the potential impact?

include::../common/what-is-the-potential-impact.adoc[]

== How to fix it

include::../common/how-to-fix-it.adoc[]

=== Code examples

==== Noncompliant code example

The following example assumes that constant names should match the default
regular expression ``++^[A-Z][A-Z0-9]*(_[A-Z0-9]+)*$++``:

[source,java,diff-id=1,diff-type=noncompliant]
----
public class MyClass {
  public static final float pi = 3.14159f; // Noncompliant: Constant is not capitalized

  void myMethod() {
    System.out.println(pi);
  }
}

public enum MyEnum {
  optionOne, // Noncompliant
  optionTwo; // Noncompliant
}
----

==== Compliant solution

[source,java,diff-id=1,diff-type=compliant]
----
public class MyClass {
  public static final float PI = 3.14159f;

  void myMethod() {
    System.out.println(PI);
  }
}

public enum MyEnum {
  OPTION_ONE,
  OPTION_TWO;
}
----

== Resources

=== External coding guidelines

* https://google.github.io/styleguide/javaguide.html#s5.2.4-constant-names[The Google Java Style Guide on Constant Names].

ifdef::env-github,rspecator-view[]

'''
== Implementation Specification
(visible only on this page)

include::../common/message.adoc[]

include::../common/parameters.adoc[]

'''
== Comments And Links
(visible only on this page)

include::../common/comments-and-links.adoc[]

endif::env-github,rspecator-view[]
