Rules / empty-branch
Empty IF branch or empty loop in Structured Text
An IF/ELSIF/ELSE branch or a loop body is empty. The logic was either never written or removed during an edit while the construct stayed.
Severity: Warning
Rule id: empty-branch
Empty IF/loop branch
What the rule checks
An IF/ELSIF/ELSE branch or a loop body is empty (THEN END_IF, DO END_FOR): the logic was either never written or cut out during an edit and the construct left behind.
What it does to the plant
A reaction everyone assumes exists is missing: the alarm is raised, the horn never sounds.
Example
PROGRAM AlarmsVAR xAlarm : BOOL; xHorn : BOOL;END_VARIF xAlarm THENEND_IF
PROGRAM AlarmsVAR xAlarm : BOOL; xHorn : BOOL;END_VARIF xAlarm THEN xHorn := TRUE;END_IF
Both listings are run through the linter by an automated test: the rule fires on the first and stays silent on the second.
How to fix
- Fill the branch with logic or remove the empty IF/loop.
- If it is empty on purpose, leave an explanatory comment.
Upload a PLCopen XML or CODESYS .export file: the report is free and the code is not stored.
The same linter without uploading a file: command line and GitHub Action.
Related rules
;; (empty statement) · double-semicolon
2026-11-26