SCR114: pointless-statement
Expression statement with no effect
| Code | SCR114 |
| Name | pointless-statement |
| Category | Scripts (SCR) |
| Default severity | warning |
| Enabled by default | yes |
| Fix available | no |
| ign-lint equivalent | none |
What it does
Section titled “What it does”Reports expression statements that do nothing: a name, an attribute access
(self.refreshBinding without parentheses), a comparison (x == 1 meant
as x = 1), arithmetic, a literal. Expressions that call something
(also with backticks, which call repr), yield or contain a list
comprehension (its variables stay bound after it in Python 2) anywhere are
not reported.
Inside a try body, a lone name, attribute or subscript is not reported:
payload["key"] there checks that the key exists.
Docstrings (the first statement of a module, class or function, including
the body of a Perspective script) and string statements right after an
assignment (attribute docstrings) are not reported. Other string
statements are reported unless allow-strings is set: they are often
used to comment out code, which is better done with #.
Why is this bad?
Section titled “Why is this bad?”The statement has no effect. Most often a call is missing its parentheses
(system.perspective.closePopup) or an assignment was written as a
comparison.
Example
Section titled “Example”def runAction(self, event): self.view.custom.dirty == False self.getSibling("Table").refreshBindingUse instead:
def runAction(self, event): self.view.custom.dirty = False self.getSibling("Table").refreshBinding("props.data")Options
Section titled “Options”allow-strings(defaultfalse): do not report string statements.
pylint
Section titled “pylint”Corresponds to W0104 pointless-statement, W0105 pointless-string-statement and W0106 expression-not-assigned. pylint
also reports the existence checks in try bodies that iglint allows.
Option reference
Section titled “Option reference”Set in [rules.SCR114] of iglint.toml (or [tool.iglint.rules.SCR114] in pyproject.toml).
| Option | Type | Default | Description |
|---|---|---|---|
allow-strings |
boolean | false |
Do not report string statements. |
Generated from the rule metadata by iglint generate-docs; iglint rule SCR114 prints the same page in the terminal. Source: docs/rules/SCR114.md.