rspec/rules/S2852/python/rule.adoc

37 lines
794 B
Plaintext
Raw Normal View History

== Why is this an issue?
Unlike class and instance methods, static methods don't receive an implicit first argument. Nonetheless naming the first argument ``++self++`` or ``++clz++`` guarantees confusion - either on the part of the original author, who may never understand why the arguments don't hold the values he expected, or on that of future maintainers.
=== Noncompliant code example
2022-02-04 17:28:24 +01:00
[source,python]
----
class MyClass:
@staticmethod
def s_meth(self, arg1, arg2): #Noncompliant
# ...
----
=== Compliant solution
2022-02-04 17:28:24 +01:00
[source,python]
----
class MyClass:
@staticmethod
def s_meth(arg1, arg2): #Noncompliant
# ...
----
ifdef::env-github,rspecator-view[]
'''
== Comments And Links
(visible only on this page)
=== duplicates: S2854
endif::env-github,rspecator-view[]