Minimize the scope of local variables 

es.uniovi.reflection.analyses.bloch.8.45


This rule detects both initialized and non-initialized local variable declarations which are not used in the following statement of the program. The rule makes the recommendation of moving these declarations before the statements in which are used for the first time. In case these first uses are located inside a try-catch block or other inner scopes (for instance, inisde if or for blocks), the declaration should be moved before the statement in which the scope changes (unless this variable is only used inside this scope).

Computational Reflection Research Group
12-03-2025 17:14
Bad Practice
Local Variable Declaration