include::../summary.adoc[]

== Why is this an issue?

include::../description.adoc[]

=== Exceptions

*Intentionally empty statement*

Statements such as ``++pass++`` or ``++...++`` (ellipsis) are clearly meant to have no effect and may be used to indicate an implementation is missing. No issue will be raised in this case.

*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]
----
def foo():
    bar()
    """Some comment"""  # Compliant by default. Noncompliant with "reportOnStrings" set to "true"
    qix()
----

*Operators*

By default, this rule considers that no arithmetic operator has a side effect. Some projects may 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
----

== How to fix it

include::../how-to-fix.adoc[]

=== Code examples

==== Noncompliant code example

[source,python]
----
def get_result():
    result = 42
    if should_be_zero():
        result == 0 # Noncompliant: no side effect, was an assignment intended?
    return result
----

==== Compliant solution

[source,python]
----
def get_result():
    result = 42
    if should_be_zero():
        result = 0 # Compliant
    return result
----

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[]
