
The languages for this rule fall into two categories: * CFamily, JS, and PLSQL: "Variables should not be shadowed" (general case of shadowing) * C#, Flex, Java, PHP, Swift: "Local variables should not shadow field/property/enum case/..." (narrow case of shadowing) For CFamily, these tickets are also handled: CPP-2785 CPP-3589
10 lines
369 B
Plaintext
10 lines
369 B
Plaintext
== Why is this an issue?
|
|
|
|
Shadowing occurs when a local variable has the same name as a variable or a field in an outer scope.
|
|
|
|
include::./problems.adoc[]
|
|
|
|
To avoid these problems, rename the shadowing, shadowed, or both identifiers to accurately represent their purpose with unique and meaningful names.
|
|
|
|
This rule focuses on variables in methods that shadow a field.
|