rspec/rules/S5797/python/rule.adoc

39 lines
713 B
Plaintext
Raw Normal View History

include::../description.adoc[]
=== Code examples
==== Noncompliant code example
[source,python,diff-id=1,diff-type=noncompliant]
----
def foo():
a = True
if a: # Noncompliant: the condition is always true
return 1
else:
return 2
----
==== Compliant solution
[source,python,diff-id=1,diff-type=compliant]
----
def foo():
a = bar()
if a:
return 1
else:
return 2
----
== Resources
=== Documentation
* Python documentation - https://www.python.org/dev/peps/pep-0285/[PEP 285 - Adding a bool type]
* Python documentation - https://docs.python.org/3/library/stdtypes.html#truth-value-testing[Python documentation - Truth Value Testing]
include::../rule.adoc[]