Rules / naming
Single-letter variable names in PLC code: why they hurt
Names like a, x or t (apart from loop counters i, j, k, n) say nothing about what the variable holds. Six months later, during a callout, someone has to decode them from the code.
Severity: Minor
Rule id: naming
Cryptic variable name
What the rule checks
Single-character names (other than counters i/j/k/n) are unreadable during maintenance. I/O tags and FB pins are left alone.
What it does to the plant
Slower troubleshooting and a higher chance of editing the wrong variable.
Example
PROGRAM ScaleVAR rRaw : REAL; a : REAL;END_VARa := rRaw * 2.0;
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
- Give it a meaningful name by purpose (e.g.
iRetryCountinstead ofn).
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