free quality report for PLCopenXML exports

Rules / always-false-condition

An alarm can never trip: the condition is always false after substitution

Once the assignments made in the same scan are substituted, the condition becomes NOT X AND X, which is FALSE for any X. Typically one program derives a command from a sensor while another checks "command present, sensor absent".

Severity: Critical Rule id: always-false-condition Condition can never be true

What the rule checks

A condition that becomes identically false (or identically true) once same-scan assignments are substituted. The classic shape: one program derives a command from a sensor, another checks the alarm “command present but sensor absent”, and substitution turns it into NOT X AND X, i.e. FALSE for any X. The alarm physically cannot fire: it is listed in the log, but there is no protection. The eye does not catch it because the assignment and the check live in different POUs, with the PLC_PRG call order between them. The rule substitutes only what is known for certain within the scan: the assignment must cover every execution path, and the source program must be called earlier. If a variable is assigned in several branches, every value is substituted and the rule fires only when the result is constant for all of them.

What it does to the plant

The alarm has a line in the log but no protection behind it: it physically cannot trip.

Example

Bad: the rule fires
VAR_GLOBAL    xPressureOk : BOOL;    xRunMakeup : BOOL;    alarm_pressure : BOOL;END_VARPROGRAM PLC_PRGMakeup();Alarms();PROGRAM Makeupgvl.xRunMakeup := gvl.xPressureOk;PROGRAM AlarmsVAR    tmrPressure : TON;END_VARtmrPressure(IN := NOT gvl.xPressureOk AND gvl.xRunMakeup, PT := T#5S);gvl.alarm_pressure := tmrPressure.Q;
Fixed: the rule is silent
VAR_GLOBAL    xPressureOk : BOOL;    xMakeupDemand : BOOL;    xRunMakeup : BOOL;    alarm_pressure : BOOL;END_VARPROGRAM PLC_PRGMakeup();Alarms();PROGRAM Makeupgvl.xRunMakeup := gvl.xMakeupDemand;PROGRAM AlarmsVAR    tmrPressure : TON;END_VARtmrPressure(IN := NOT gvl.xPressureOk AND gvl.xRunMakeup, PT := T#5S);gvl.alarm_pressure := tmrPressure.Q;

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. Take the command from a source other than the signal being checked: the alarm “command present, sensor absent” only works when the command does not contain that sensor as a factor.
  2. Check the intermediate variable as well, not just the final expression: the same defect came back a second time in the same place through a one-line edit of the source.
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