Skip to content

BIND009: transform-without-return

Script transform can finish without return

Code BIND009
Name transform-without-return
Category Bindings and expressions (BIND)
Default severity error
Enabled by default yes
Fix available no
ign-lint equivalent none

Reports script transforms whose body can reach its end without a return statement. The analysis follows the control flow of the body: if/elif without a final else, loops that may run zero times, except handlers that do not return, try/finally, with. Paths that end in raise or in a while True: loop without break do not count. Calls that never return (sys.exit()) are not recognised, and conditions are not evaluated: if x: return 1 followed by elif not x: return 0 is reported because the code does not show that one branch always runs.

Transforms that do not parse are left to SCR001.

Ignition calls the transform as a function: falling off the end returns None, so the bound property becomes null. The binding shows no error and no quality problem; the component just loses its value on some inputs.

def transform(self, value, quality, timestamp):
if value > 100:
return "High"
elif value > 50:
return "Medium"

Use instead:

def transform(self, value, quality, timestamp):
if value > 100:
return "High"
elif value > 50:
return "Medium"
return "Low"

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