free quality report for PLCopenXML exports

Rules / unreachable-branch

ELSIF branch never runs: the previous condition already covers the whole range

When an IF chain has x < T followed by ELSIF x >= T, the second branch takes the entire remaining range and every later ELSIF is dead. The compiler cannot see it because each condition is valid on its own.

Severity: Critical Rule id: unreachable-branch Unreachable IF/ELSIF branch

What the rule checks

IF x<T … ELSIF x>=T …: the second branch covers the whole remaining range, so the following ELSIF branches never execute (a classic weather-curve mistake).

What it does to the plant

Part of a heating curve or a control stage never applies: in deep frost the boiler holds the same setpoint as in a thaw.

Example

Bad: the rule fires
PROGRAM HeatCurveVAR    rOutdoor : REAL;    rSetpoint : REAL;END_VARIF rOutdoor < 0.0 THEN    rSetpoint := 70.0;ELSIF rOutdoor >= 0.0 THEN    rSetpoint := 60.0;ELSIF rOutdoor >= 10.0 THEN    rSetpoint := 50.0;END_IF
Fixed: the rule is silent
PROGRAM HeatCurveVAR    rOutdoor : REAL;    rSetpoint : REAL;END_VARIF rOutdoor < 0.0 THEN    rSetpoint := 70.0;ELSIF rOutdoor < 10.0 THEN    rSetpoint := 60.0;ELSE    rSetpoint := 50.0;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

  1. Order the thresholds ascending with non-overlapping ranges: IF x < T1 THEN … ELSIF x < T2 THEN … ELSE …
  2. Replace the ELSIF chain with an array of curve points and interpolation.
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