rspec/rules/S2039/java/rule.adoc

59 lines
865 B
Plaintext
Raw Normal View History

== Why is this an issue?
2020-06-30 12:48:07 +02:00
include::../description.adoc[]
=== Noncompliant code example
2020-06-30 12:48:07 +02:00
2022-02-04 17:28:24 +01:00
[source,java]
2020-06-30 12:48:07 +02:00
----
class Ball {
String color="red"; // Noncompliant
}
enum A {
B;
int a;
}
----
=== Compliant solution
2020-06-30 12:48:07 +02:00
2022-02-04 17:28:24 +01:00
[source,java]
2020-06-30 12:48:07 +02:00
----
class Ball {
private String color="red"; // Compliant
}
enum A {
B;
private int a;
}
----
=== Exceptions
2020-06-30 12:48:07 +02:00
Members annotated with ``++@VisibleForTesting++`` annotation are ignored, as it indicates that visibility has been purposely relaxed to make the code testable.
2020-06-30 12:48:07 +02:00
2021-02-02 15:02:10 +01:00
[source,java]
2020-06-30 12:48:07 +02:00
----
class Cone {
@VisibleForTesting
Logger logger; // Compliant
}
----
ifdef::env-github,rspecator-view[]
'''
== Implementation Specification
(visible only on this page)
include::../message.adoc[]
'''
== Comments And Links
(visible only on this page)
include::../comments-and-links.adoc[]
endif::env-github,rspecator-view[]