rspec/rules/S5953/python/rule.adoc

47 lines
706 B
Plaintext
Raw Normal View History

== Why is this an issue?
2021-04-28 16:49:39 +02:00
Variables, Classes and functions should not be undefined, otherwise the code will fail with a NameError.
=== Noncompliant code example
2021-04-28 16:49:39 +02:00
2022-02-04 17:28:24 +01:00
[source,python]
2021-04-28 16:49:39 +02:00
----
my_var # Noncompliant (variable is never defined)
def noncompliant():
foo() # Noncompliant
MyClass() # Noncompliant
----
=== Compliant solution
2021-04-28 16:49:39 +02:00
2022-02-04 17:28:24 +01:00
[source,python]
2021-04-28 16:49:39 +02:00
----
from mod import my_var
my_var
def compliant():
foo = sum
foo()
class MyClass:
pass
MyClass()
----
ifdef::env-github,rspecator-view[]
'''
== Implementation Specification
(visible only on this page)
=== Message
XX is not defined. Change its name or define it before using it.
endif::env-github,rspecator-view[]