2021-01-27 13:42:22 +01:00
The needless repetition of an operator is usually a typo. There is no reason to write ``++!!!i++`` when ``++!i++`` will do.
2020-06-30 12:48:07 +02:00
2021-02-02 15:02:10 +01:00
2020-06-30 12:48:07 +02:00
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.
2021-02-02 15:02:10 +01:00
2021-02-08 12:42:26 +01:00
This rule raises an issue for sequences of: ``++!++``, ``++~++``, ``++-++``, and ``{plus}``.
2020-06-30 12:48:07 +02:00
== Noncompliant Code Example
2022-02-04 17:28:24 +01:00
[source,java]
2020-06-30 12:48:07 +02:00
----
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
2022-02-04 17:28:24 +01:00
[source,java]
2020-06-30 12:48:07 +02:00
----
int i = 1;
int j = -i;
int k = ~i;
int m = i;
boolean b = false;
boolean c = !b;
----
== Exceptions
2021-01-27 13:42:22 +01:00
Overflow handling for GWT compilation using ``++~~++`` is ignored.
2021-06-02 20:44:38 +02:00
2021-06-03 09:05:38 +02:00
ifdef::env-github,rspecator-view[]
2021-09-20 15:38:42 +02:00
'''
== Implementation Specification
(visible only on this page)
include::../message.adoc[]
2021-06-08 15:52:13 +02:00
'''
2021-06-02 20:44:38 +02:00
== Comments And Links
(visible only on this page)
include::../comments-and-links.adoc[]
2021-06-03 09:05:38 +02:00
endif::env-github,rspecator-view[]