
## Review A dedicated reviewer checked the rule description successfully for: - [x] logical errors and incorrect information - [x] information gaps and missing content - [x] text style and tone - [x] PR summary and labels follow [the guidelines](https://github.com/SonarSource/rspec/#to-modify-an-existing-rule)
56 lines
998 B
Plaintext
56 lines
998 B
Plaintext
include::../rationale.adoc[]
|
|
|
|
=== Exceptions
|
|
|
|
`_` will not raise an issue for this rule. The following examples are compliant:
|
|
|
|
[source,python]
|
|
----
|
|
for _ in range(10):
|
|
do_something()
|
|
username, login, _ = auth
|
|
do_something_else(username, login)
|
|
----
|
|
|
|
include::../how-to-fix-it.adoc[]
|
|
|
|
=== Code examples
|
|
|
|
==== Noncompliant code example
|
|
|
|
[source,python,diff-id=1,diff-type=noncompliant]
|
|
----
|
|
def hello(name):
|
|
message = "Hello " + name # Noncompliant - message is unused
|
|
print(name)
|
|
for i in range(10): # Noncompliant - i is unused
|
|
foo()
|
|
----
|
|
|
|
==== Compliant solution
|
|
|
|
[source,python,diff-id=1,diff-type=compliant]
|
|
----
|
|
def hello(name):
|
|
message = "Hello " + name
|
|
print(message)
|
|
for _ in range(10):
|
|
foo()
|
|
----
|
|
|
|
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[]
|