
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
12 lines
447 B
Plaintext
12 lines
447 B
Plaintext
This can lead to three main problems:
|
|
|
|
* Confusion:
|
|
The same name can refer to different variables in different parts of the scope, making the code hard to read and understand.
|
|
|
|
* Unintended Behavior:
|
|
You might accidentally use the wrong variable, leading to hard-to-detect bugs.
|
|
|
|
* Maintenance Issues:
|
|
If the inner variable is removed or renamed, the code's behavior might change unexpectedly because the outer variable is now being used.
|
|
|