== Why is this an issue?

Non-abstract classes and enums with non-``++static++``, ``++private++`` members should explicitly initialize those members, either in a constructor or with a default value.

=== Noncompliant code example

[source,java]
----
class A { // Noncompliant
  private int field;
}
----

=== Compliant solution

[source,java]
----
class A {
  private int field;

  A(int field) {
    this.field = field;
  }
}
----

=== Exceptions

* Class implementing a Builder Pattern (name ending with "Builder").
* https://docs.oracle.com/javaee/7/tutorial/index.html[Java EE] class annotated with:
** https://docs.oracle.com/javaee/7/api/javax/annotation/ManagedBean.html[ManagedBean]
** https://docs.oracle.com/javaee/7/api/javax/ejb/MessageDriven.html[MessageDriven]
** https://docs.oracle.com/javaee/7/api/javax/ejb/Singleton.html[Singleton]
** https://docs.oracle.com/javaee/7/api/javax/ejb/Stateful.html[Stateful]
** https://docs.oracle.com/javaee/7/api/javax/ejb/Stateless.html[Stateless]
** https://docs.oracle.com/javaee/7/api/javax/jws/WebService.html[WebService]
** https://docs.oracle.com/javaee/7/api/javax/servlet/annotation/WebFilter.html[WebFilter]
** https://docs.oracle.com/javaee/7/api/javax/servlet/annotation/WebServlet.html[WebServlet]

* Class and field annotated with:
** https://codehaus-plexus.github.io/plexus-containers/plexus-component-annotations/index.html[Plexus Component Annotations]
** https://maven.apache.org/developers/mojo-api-specification.html[Maven Mojo]

* Field annotated with:
** https://docs.oracle.com/javaee/7/api/javax/annotation/Resource.html[Resource]
** https://docs.oracle.com/javaee/7/api/javax/ejb/EJB.html[EJB]
** https://docs.oracle.com/javaee/7/api/javax/inject/Inject.html[Inject]
** https://docs.spring.io/spring-framework/docs/current/javadoc-api/org/springframework/beans/factory/annotation/Autowired.html[Autowired]

* Class annotated with:
** https://www.javadoc.io/doc/org.projectlombok/lombok/latest/lombok/Builder.html[Lombok Builder]

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

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

=== Message

Add a constructor to the class/enum, or provide default values.


Primary: Class declaration.
Secondary: Un-initiliased members.


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

=== is related to: S836

=== is related to: S2107

=== on 3 Jul 2014, 15:49:10 Ann Campbell wrote:
rewritten

=== on 30 Jul 2014, 20:21:44 Freddy Mallet wrote:
Feedback [~ann.campbell.2]:

* I would decrease the remediation cost to 5 minutes as we're just talking about creating a constructor to initialize the value
* If this might really lead a a reliability issue, I guess we should use the tag "bug"

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