rspec/rules/S3699/python/rule.adoc

39 lines
819 B
Plaintext
Raw Normal View History

If a function does not return anything, it makes no sense to use its output. Specifically, passing it to another function, or assigning its "result" to a variable is probably a bug because such functions return nothing, which is probably not what was intended.
== Noncompliant Code Example
[source,python]
----
def foo():
l = [1, 2, 3]
result = l.append(42) # Noncompliant, `append` mutates list l
return result
----
== Compliant Solution
[source,python]
----
def foo():
l = [1, 2, 3]
l.append(42)
return l
----
ifdef::env-github,rspecator-view[]
'''
== Implementation Specification
(visible only on this page)
include::../message.adoc[]
include::../highlighting.adoc[]
'''
== Comments And Links
(visible only on this page)
include::../comments-and-links.adoc[]
endif::env-github,rspecator-view[]