Skip to content

SCR105: unreachable-code

Statement can never run

Code SCR105
Name unreachable-code
Category Scripts (SCR)
Default severity warning
Enabled by default yes
Fix available no
ign-lint equivalent none

Reports the first statement of a block that execution can never reach: after return, raise, break or continue, after an if/else or try/except whose every branch ends that way, and after a while True: loop without break. Only the first unreachable statement of a run is reported. The bodies of if False: and while 0: are not reported (they are a common way to disable code on purpose).

Calls that never return (sys.exit()) are not taken into account.

The code looks like it does something but never runs. In Perspective scripts it is often a statement written after an early return by mistake, such as a property write that should happen before it.

def transform(self, value, quality, timestamp):
return value * 10
self.custom.lastValue = value

Use instead:

def transform(self, value, quality, timestamp):
self.custom.lastValue = value
return value * 10

Corresponds to W0101 unreachable, which only looks at the statement directly after return, raise, break and continue.


Generated from the rule metadata by iglint generate-docs; iglint rule SCR105 prints the same page in the terminal. Source: docs/rules/SCR105.md.