free quality report for PLCopenXML exports

Rules / unused-local

Unused local variable in a POU

A variable is declared in VAR but appears neither in the body nor in its actions and methods. It is leftover logic or a typo, with a different name used in the body.

Severity: Minor Rule id: unused-local Unused local variable

What the rule checks

A local variable is declared in VAR but never appears in the POU body or its actions or methods: a leftover from deleted logic, or a typo in the body (in which case a different variable is doing the work).

What it does to the plant

If it is a typo, the program reads and writes the wrong variable while the intended one stays at zero.

Example

Bad: the rule fires
PROGRAM ScaleVAR    rRaw : REAL;    rScaled : REAL;    rOldScaled : REAL;END_VARrScaled := rRaw * 2.0;
Fixed: the rule is silent
PROGRAM ScaleVAR    rRaw : REAL;    rScaled : REAL;END_VARrScaled := rRaw * 2.0;

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. Remove the unused declaration.
  2. Or wire the variable into the logic if it was forgotten.
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