57 lines
1.1 KiB
Plaintext
57 lines
1.1 KiB
Plaintext
== Why is this an issue?
|
|
|
|
The needless repetition of an operator is usually a typo. There is no reason to write ``++!!!i++`` when ``++!i++`` will do.
|
|
|
|
|
|
On the other hand, the repetition of increment and decrement operators may have been done on purpose, but doing so obfuscates the meaning, and should be simplified.
|
|
|
|
|
|
This rule raises an issue for sequences of: ``++!++``, ``++~++``, ``++-++``, and ``{plus}``.
|
|
|
|
=== Noncompliant code example
|
|
|
|
[source,java]
|
|
----
|
|
int i = 1;
|
|
|
|
int j = - - -i; // Noncompliant; just use -i
|
|
int k = ~~~i; // Noncompliant; same as i
|
|
int m = + +i; // Noncompliant; operators are useless here
|
|
|
|
boolean b = false;
|
|
boolean c = !!!b; // Noncompliant
|
|
----
|
|
|
|
=== Compliant solution
|
|
|
|
[source,java]
|
|
----
|
|
int i = 1;
|
|
|
|
int j = -i;
|
|
int k = ~i;
|
|
int m = i;
|
|
|
|
boolean b = false;
|
|
boolean c = !b;
|
|
----
|
|
|
|
=== Exceptions
|
|
|
|
Overflow handling for GWT compilation using ``++~~++`` is ignored.
|
|
|
|
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[]
|