rspec/rules/S2757/go/rule.adoc

20 lines
362 B
Plaintext
Raw Normal View History

2020-06-30 12:48:07 +02:00
include::../description.adoc[]
== Noncompliant Code Example
----
var target, num = -5, 3
target =- num // Noncompliant; target = -3. Is that really what's meant?
target =+ num // Noncompliant; target = 3
----
== Compliant Solution
----
var target, num = -5, 3
target = -num // Compliant; intent to assign inverse value of num is clear
target += num
----