26 lines
694 B
Plaintext
26 lines
694 B
Plaintext
![]() |
The needless repetition of an operator is usually a typo. There is no reason to write <code>!!!i</code> when <code>!i</code> 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: <code>!</code>, <code>^</code>, <code>-</code>, and <code>\+</code>.
|
||
|
|
||
|
== Noncompliant Code Example
|
||
|
|
||
|
----
|
||
|
var a int = 1
|
||
|
var flag bool = true
|
||
|
|
||
|
var a1 int = ^^^a // Noncompliant
|
||
|
var flag2 bool = !!!flag // Noncompliant
|
||
|
----
|
||
|
|
||
|
== Compliant Solution
|
||
|
|
||
|
----
|
||
|
var a int = 1
|
||
|
var flag bool = true
|
||
|
|
||
|
var a1 int = ^a
|
||
|
var flag2 bool = !flag
|
||
|
----
|