free quality report for PLCopenXML exports

Rules / self-assignment

Assigning a variable to itself, x := x, in Structured Text

The line x := x does nothing. It is almost always a typo: another variable was meant on the right, such as a setpoint from the HMI.

Severity: Warning Rule id: self-assignment Assignment of a variable to itself

What the rule checks

A line like x := x; assigns a variable to itself and does nothing. Usually a typo on the right-hand side (another variable was meant) or a leftover from deleted logic.

What it does to the plant

The value never updates: the setpoint is changed on the screen while the program keeps using the old one.

Example

Bad: the rule fires
PROGRAM SetpointsVAR    rSetpoint : REAL;    rSetpointHmi : REAL;END_VARrSetpoint := rSetpoint;
Fixed: the rule is silent
PROGRAM SetpointsVAR    rSetpoint : REAL;    rSetpointHmi : REAL;END_VARrSetpoint := rSetpointHmi;

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. The right-hand side probably should be another variable (a typo); check the intent.
  2. If the line is redundant, remove it.
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