2023-05-03 11:06:20 +02:00
== Why is this an issue?
2023-10-12 16:12:10 +02:00
include::../description.adoc[]
2022-03-22 10:24:23 +01:00
2023-10-12 16:12:10 +02:00
=== Exceptions
This rule ignores overriding methods.
2022-03-22 10:24:23 +01:00
[source,python]
----
2023-10-12 16:12:10 +02:00
class C(B):
def do_something(self, a, b): # no issue reported on b
return self.compute(a)
2022-03-22 10:24:23 +01:00
----
2023-10-12 16:12:10 +02:00
This rule also ignores variables named with a single underscore `_`. Such naming is a common practice for indicating that the variable is insignificant.
2022-03-22 10:24:23 +01:00
[source,python]
----
2023-10-12 16:12:10 +02:00
def do_something(a, _): # no issue reported on _
2022-03-22 10:24:23 +01:00
return compute(a)
----
2023-12-04 16:21:34 +01:00
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)
----
2023-10-12 16:12:10 +02:00
== How to fix it
2022-03-22 10:24:23 +01:00
2023-10-12 16:12:10 +02:00
include::../how-to-fix-it.adoc[]
2022-03-22 10:24:23 +01:00
2023-10-12 16:12:10 +02:00
=== Code examples
2022-03-22 10:24:23 +01:00
2023-10-12 16:12:10 +02:00
==== Noncompliant code example
2022-03-22 10:24:23 +01:00
2023-10-12 16:12:10 +02:00
[source,python,diff-id=1,diff-type=noncompliant]
2022-03-22 10:24:23 +01:00
----
2023-10-12 16:12:10 +02:00
def do_something(a, b): # "b" is unused
2022-03-22 10:24:23 +01:00
return compute(a)
----
2023-10-12 16:12:10 +02:00
==== Compliant solution
2022-03-22 10:24:23 +01:00
2023-10-12 16:12:10 +02:00
[source,python,diff-id=1,diff-type=compliant]
----
def do_something(a):
return compute(a)
----
2021-06-02 20:44:38 +02:00
2021-06-03 09:05:38 +02:00
ifdef::env-github,rspecator-view[]
2021-09-20 15:38:42 +02:00
'''
== Implementation Specification
(visible only on this page)
include::../message.adoc[]
2021-06-08 15:52:13 +02:00
'''
2021-06-02 20:44:38 +02:00
== Comments And Links
(visible only on this page)
include::../comments-and-links.adoc[]
2023-06-22 10:38:01 +02:00
2021-06-03 09:05:38 +02:00
endif::env-github,rspecator-view[]