rspec/rules/S1854/python/rule.adoc
2023-10-13 12:26:37 +02:00

55 lines
1.0 KiB
Plaintext

include::../why.adoc[]
=== Exceptions
This rule ignores initializations to `-1`, `0`, `1`, `None`, `True`, `False` and `""`.
No issue will be raised on unpacked variables.
include::../howtofixit.adoc[]
=== Code examples
==== Noncompliant code example
[source,python,diff-id=1,diff-type=noncompliant]
----
def func(a, b, compute):
i = a + b # Noncompliant; calculation result not used before value is overwritten
i = compute()
return i
----
==== Compliant solution
[source,python,diff-id=1,diff-type=compliant]
----
def func(a, b, compute):
i = a + b
i += compute()
return i
----
include::../see.adoc[]
=== Related rules
* S1763 - All code should be reachable
* S3516 - Functions returns should not be invariant
* S3626 - Jump statements should not be redundant
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[]