
Inline adoc files when they are included exactly once. Also fix language tags because this inlining gives us better information on what language the code is written in.
82 lines
2.2 KiB
Plaintext
82 lines
2.2 KiB
Plaintext
== Why is this an issue?
|
|
|
|
Any statement, other than a ``++pass++``, ``++...++`` (ellipsis) or an empty statement (i.e. a single semicolon \"``++;++``"), which has no side effect and does not result in a change of control flow will normally indicate a programming error, and therefore should be refactored.
|
|
|
|
=== Noncompliant code example
|
|
|
|
[source,python]
|
|
----
|
|
a == 1 # Noncompliant; was assignment intended?
|
|
a < b # Noncompliant; have we forgotten to assign the result to a variable?
|
|
----
|
|
|
|
=== Exceptions
|
|
|
|
*Strings*
|
|
|
|
Some projects use string literals as comments. By default, this rule will not raise an issue on these strings. Reporting on string literals can be enabled by setting the rule parameter "reportOnStrings" to "true".
|
|
|
|
|
|
[source,python]
|
|
----
|
|
class MyClass:
|
|
myattr = 42
|
|
"""This is an attribute""" # Noncompliant by default. Set "reportOnStrings" to "false"
|
|
----
|
|
|
|
*Operators*
|
|
|
|
By default, this rule considers that no arithmetic operator has a side effect. Some rare projects redefine operators and add a side effect. You can list such operators in the rule parameter "ignoredOperators".
|
|
|
|
|
|
[source,python]
|
|
----
|
|
def process(p, beam):
|
|
"""
|
|
Apache Beam redefines "|" and ">>" operators and they have a side effect.
|
|
Thus for Apache Beam projects "ignoredOperators"should be set to "|,>>"
|
|
"""
|
|
p | "create" >> beam.Create() # Noncompliant by default
|
|
----
|
|
|
|
include::../see.adoc[]
|
|
|
|
ifdef::env-github,rspecator-view[]
|
|
|
|
'''
|
|
== Implementation Specification
|
|
(visible only on this page)
|
|
|
|
include::../message.adoc[]
|
|
|
|
=== Parameters
|
|
|
|
.reportOnStrings
|
|
****
|
|
_string_
|
|
|
|
----
|
|
false
|
|
----
|
|
|
|
Enable issues on string literals which are not assigned. Set this parameter to "false" if you use strings as comments.
|
|
****
|
|
.ignoredOperators
|
|
****
|
|
_string_
|
|
|
|
----
|
|
empty string
|
|
----
|
|
|
|
Comma separated list of operators which have a side effect and should be ignored by this rule. By default, this rule considers that no unary or binary operator have a side effect. For example, if you override operators ">>" and "|" and they have a side effect, this parameter should then be set to ">>,|".
|
|
****
|
|
|
|
|
|
'''
|
|
== Comments And Links
|
|
(visible only on this page)
|
|
|
|
include::../comments-and-links.adoc[]
|
|
endif::env-github,rspecator-view[]
|