rspec/rules/S2761/go/rule.adoc

47 lines
976 B
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,go]
----
var a int = 1
var flag bool = true
var a1 int = ^^^a // Noncompliant
var flag2 bool = !!!flag // Noncompliant
----
=== Compliant solution
[source,go]
----
var a int = 1
var flag bool = true
var a1 int = ^a
var flag2 bool = !flag
----
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[]