79 lines
1.5 KiB
Plaintext
79 lines
1.5 KiB
Plaintext
== Why is this an issue?
|
|
|
|
include::../description.adoc[]
|
|
|
|
=== Exceptions
|
|
|
|
This rule ignores overriding methods.
|
|
|
|
[source,python]
|
|
----
|
|
class C(B):
|
|
def do_something(self, a, b): # no issue reported on b
|
|
return self.compute(a)
|
|
----
|
|
|
|
This rule also ignores variables named with a single underscore `_`. Such naming is a common practice for indicating that the variable is insignificant.
|
|
|
|
[source,python]
|
|
----
|
|
def do_something(a, _): # no issue reported on _
|
|
return compute(a)
|
|
----
|
|
|
|
The rule also won't raise an issue if the parameter is referenced in a docstring or a comment:
|
|
|
|
[source,python]
|
|
----
|
|
class MyClass:
|
|
def do_something(self, my_param): # no issue reported
|
|
# Overrides may use my_param to ...
|
|
return compute(a)
|
|
----
|
|
|
|
[source,python]
|
|
----
|
|
class MyClass:
|
|
def do_something(self, my_param): # no issue reported
|
|
"""Overrides may use my_param to ..."""
|
|
return compute(a)
|
|
----
|
|
|
|
== How to fix it
|
|
|
|
include::../how-to-fix-it.adoc[]
|
|
|
|
=== Code examples
|
|
|
|
==== Noncompliant code example
|
|
|
|
[source,python,diff-id=1,diff-type=noncompliant]
|
|
----
|
|
def do_something(a, b): # "b" is unused
|
|
return compute(a)
|
|
----
|
|
|
|
==== Compliant solution
|
|
|
|
[source,python,diff-id=1,diff-type=compliant]
|
|
----
|
|
def do_something(a):
|
|
return compute(a)
|
|
----
|
|
|
|
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[]
|