rspec/rules/S1854/python/rule.adoc

27 lines
551 B
Plaintext
Raw Normal View History

2020-06-30 12:47:33 +02:00
include::../description.adoc[]
== Noncompliant Code Example
----
def func(a, b, compute):
i = a + b # Noncompliant; calculation result not used before value is overwritten
i = compute() # Noncompliant; the value is not used before leaving the function
----
== Compliant Solution
----
def func(a, b, compute):
i = a + b
i += compute()
return i
----
== Exceptions
2020-12-23 14:59:06 +01:00
This rule ignores initializations to -1, 0, 1, ``None``, ``True``, ``False`` and ``""``.
2020-06-30 12:47:33 +02:00
No issue will be raised on unpacked variables.
include::../see.adoc[]