RDC01015: Constant not used
Severity: Information · Family: RDC (Rubberduck Core analyzers) ·
Raised by: ConstantNotUsedAnalyzer
Nothing refers to a constant.
A constant that is never used does nothing for the program. It is often left over from code that changed, or a name typed where another was meant.
A statement, the value of another constant and the bounds of an array all use a constant. A constant of a procedure is counted over the code of the
procedure, and a Private constant of the module (declared Private, or with no access keyword) over the code and the declarations of the module. A
Public constant of a module that is Option Private Module is counted over every module of the project. A Public constant that other projects can
use is not reported.
The finding is the name of the constant.
How it is raised
| Situation | Example | Resolution |
|---|---|---|
| A constant of a procedure that nothing refers to. | Const Limit As Long = 10 |
Remove it, or use it where it was meant to be used. |
A Private constant of the module that nothing refers to. |
Private Const Limit As Long = 10 |
Same. |
Quick fix
The finding comes with a quick fix, Remove the declaration of 'Limit'. It removes the lines of the declaration, and the program does the same. It is offered when the statement declares no other constant and nothing else is written on its lines (no comment, label or other statement).
See also
ACCUEIL • HOME | ℹ️ BIENVENUE • WELCOME | 🧩 BÂTISSONS • BUILD | RD-VBAL | SDK | 🌐 rubberduckvba.ca