rspec/rules/S2333/java/rule.adoc
Fred Tingaud 16f6c0aecf
Inline adoc when include has no additional value (#1940)
Inline adoc files when they are included exactly once.

Also fix language tags because this inlining gives us better information
on what language the code is written in.
2023-05-25 14:18:12 +02:00

43 lines
1.1 KiB
Plaintext

== Why is this an issue?
The methods declared in an ``++interface++`` are ``++public++`` and ``++abstract++`` by default. Any variables are automatically ``++public static final++``. Finally, ``++class++`` and ``++interface++`` are automatically ``++public static++``. There is no need to explicitly declare them so.
Since annotations are implicitly interfaces, the same holds true for them as well.
Similarly, the ``++final++`` modifier is redundant on any method of a ``++final++`` class, ``++private++`` is redundant on the constructor of an ``++Enum++``, and ``++static++`` is redundant for ``++interface++`` nested into a ``++class++`` or ``++enum++``.
=== Noncompliant code example
[source,java]
----
public interface Vehicle {
public void go(int speed, Direction direction); // Noncompliant
----
=== Compliant solution
[source,java]
----
public interface Vehicle {
void go(int speed, Direction direction);
----
ifdef::env-github,rspecator-view[]
'''
== Implementation Specification
(visible only on this page)
=== Message
"xxx" is redundant in this context.
endif::env-github,rspecator-view[]