rspec/rules/S1854/python/rule.adoc

48 lines
830 B
Plaintext
Raw Normal View History

== Why is this an issue?
2020-06-30 12:47:33 +02:00
include::../description.adoc[]
=== Noncompliant code example
2020-06-30 12:47:33 +02:00
2022-02-04 17:28:24 +01:00
[source,python]
2020-06-30 12:47:33 +02:00
----
def func(a, b, compute):
i = a + b # Noncompliant; calculation result not used before value is overwritten
i = compute()
return i
2020-06-30 12:47:33 +02:00
----
=== Compliant solution
2020-06-30 12:47:33 +02:00
2022-02-04 17:28:24 +01:00
[source,python]
2020-06-30 12:47:33 +02:00
----
def func(a, b, compute):
i = a + b
i += compute()
return i
----
=== Exceptions
2020-06-30 12:47:33 +02:00
2021-01-27 13:42:22 +01:00
This rule ignores initializations to -1, 0, 1, ``++None++``, ``++True++``, ``++False++`` and ``++""++``.
2020-06-30 12:47:33 +02:00
2021-02-02 15:02:10 +01:00
2020-06-30 12:47:33 +02:00
No issue will be raised on unpacked variables.
include::../see.adoc[]
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[]