rspec/rules/S2761/python/rule.adoc

41 lines
863 B
Plaintext
Raw Normal View History

Calling the ``++not++`` or ``++~++`` prefix operator twice might be redundant: the second invocation undoes the first. Such mistakes are typically caused by accidentally double-tapping the key in question without noticing. Either this is a bug, if the operator was actually meant to be called once, or misleading if done on purpose.
== Noncompliant Code Example
[source,python]
----
a = 0
b = False
c = not not a # Noncompliant
d = ~~b # Noncompliant
----
== Compliant Solution
[source,python]
----
a = 0
b = False
c = not a # Compliant
d = ~b # Compliant
----
ifdef::env-github,rspecator-view[]
'''
== Implementation Specification
(visible only on this page)
=== Message
Use the "{not|~}" operator just once or not at all.
'''
== Comments And Links
(visible only on this page)
include::../comments-and-links.adoc[]
endif::env-github,rspecator-view[]