Rules / index-mismatch
One line in a group of similar assignments writes to another channel
In a group of identical lines the channel numbers match everywhere except one: xRunPump5 := xCmdPump4. It is the trace of a copied line that was only partly renumbered.
Severity: Warning
Rule id: index-mismatch
Line indexes differently from its group
What the rule checks
Across a group of similar lines the relation between index positions holds nearly everywhere but is broken in one line: eleven lines write to their own channel, the twelfth writes to someone else's. That is what a copied neighbouring branch with partial renumbering looks like. The rule does not compare whole lines: numbers from different dimensions (boiler number and alarm block number) coincide routinely, and that case is accounted for. This is a heuristic, so before changing anything check whether the line is a deliberate exception.
What it does to the plant
One unit's command drives another: pump 5 runs together with pump 4 and never on its own.
Example
VAR_GLOBAL xCmdPump1, xCmdPump2, xCmdPump3, xCmdPump4, xCmdPump5 : BOOL; xRunPump1, xRunPump2, xRunPump3, xRunPump4, xRunPump5 : BOOL;END_VARPROGRAM Outputsgvl.xRunPump1 := gvl.xCmdPump1;gvl.xRunPump2 := gvl.xCmdPump2;gvl.xRunPump3 := gvl.xCmdPump3;gvl.xRunPump4 := gvl.xCmdPump4;gvl.xRunPump5 := gvl.xCmdPump4;
VAR_GLOBAL xCmdPump1, xCmdPump2, xCmdPump3, xCmdPump4, xCmdPump5 : BOOL; xRunPump1, xRunPump2, xRunPump3, xRunPump4, xRunPump5 : BOOL;END_VARPROGRAM Outputsgvl.xRunPump1 := gvl.xCmdPump1;gvl.xRunPump2 := gvl.xCmdPump2;gvl.xRunPump3 := gvl.xCmdPump3;gvl.xRunPump4 := gvl.xCmdPump4;gvl.xRunPump5 := gvl.xCmdPump5;
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
- Compare the line with its neighbours in the group: usually the destination was not renumbered:
w_cascadK4 := r_cascadK4instead ofw_cascadK3 := r_cascadK4. - If the line is a deliberate exception, put a comment next to it. That saves the next reader, and you in six months, an investigation.
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
2026-11-26