free quality report for PLCopenXML exports

Rules / case-without-else

CASE without ELSE in Structured Text: what happens on an unexpected value

If the selector takes a value that has no label, nothing runs and the program silently keeps its previous state. In state machines this is a common cause of a "stuck step".

Severity: Warning Rule id: case-without-else CASE without an ELSE branch (no default)

What the rule checks

CASE without an ELSE branch: if the selector takes a value not among the labels, nothing runs: a silent skip (a common state-machine bug).

What it does to the plant

A sequence gets stuck on a step that does not exist: equipment never leaves the mode and never reaches a safe state.

Example

Bad: the rule fires
PROGRAM SequenceVAR    iStep : INT;    xPump : BOOL;END_VARCASE iStep OF    0: xPump := FALSE;    1: xPump := TRUE;END_CASE
Fixed: the rule is silent
PROGRAM SequenceVAR    iStep : INT;    xPump : BOOL;END_VARCASE iStep OF    0: xPump := FALSE;    1: xPump := TRUE;ELSE    xPump := FALSE;    iStep := 0;END_CASE

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

  1. Add an ELSE branch with default handling (signal/log/safe state).
  2. If all selector values are truly covered, keep ELSE with an explanatory comment.
Check your project

Upload a PLCopen XML or CODESYS .export file: the report is free and the code is not stored.

Local version on GitHub →

The same linter without uploading a file: command line and GitHub Action.

Related rules

2026-11-26

Processing happens in memory, and the uploaded code is not stored. The tool advises; code changes are up to the engineer (see what the linter can't see). What happens to your code → · Rule reference · Your code & privacy · Industry benchmark · Feedback · GitHub