
When an include is not surrounded by empty lines, its content is inlined on the same line as the adjacent content. That can lead to broken tags and other display issues. This PR fixes all such includes and introduces a validation step that forbids introducing the same problem again.
52 lines
1.1 KiB
Plaintext
52 lines
1.1 KiB
Plaintext
== Why is this an issue?
|
|
|
|
The repetition of a unary operator is usually a typo. The second operator invalidates the first one in most cases:
|
|
|
|
[source,go]
|
|
----
|
|
var a int = 1
|
|
var flag bool = true
|
|
|
|
var a1 int = ^^^a // Noncompliant: equivalent to "^a"
|
|
var flag2 bool = !!!flag // Noncompliant: equivalent to "!flag"
|
|
----
|
|
|
|
On the other hand, while repeating the increment and decrement operators is technically correct, it obfuscates the meaning:
|
|
|
|
[source,go]
|
|
----
|
|
var i int = 1
|
|
var j int = ++ ++i // Noncompliant
|
|
var k int = -- --i // Noncompliant
|
|
----
|
|
|
|
Using ``+=`` or ``-=`` improves readability:
|
|
|
|
[source,go]
|
|
----
|
|
var i int = 1
|
|
i += 2
|
|
var j int = i
|
|
i -=2
|
|
var k int = i
|
|
----
|
|
|
|
This rule raises an issue for repetitions of ``++!++``, ``++^++``, ``++-++``, ``{plus}``, increment ``++`` and decrement ``--`` operators.
|
|
|
|
|
|
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[]
|