magic-io-unit (C032)
What it does
Checks for literal integers as units in IO statements.
Why is this bad?
Hardcoding unit numbers makes programs more brittle as it becomes harder to
verify units have been opened before reading/writing. Instead, units should
be passed in to procedures as arguments, or the newunit= argument used for
open statements. Having a named variable also makes it much clearer what a
given IO statement is for, and allows tools like LSP and IDEs to find all
references.
Bad:
Good: