rspec/rules/S1117/java/rule.adoc
Marco Borgeaud 98517de0ff
Modify rule S1117: Migrate To LayC - shadow variables (#3270)
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
2023-10-16 12:04:08 +02:00

30 lines
666 B
Plaintext

include::../why-fields.adoc[]
=== Noncompliant code example
[source,java]
----
class Foo {
public int myField;
public void doSomething() {
int myField = 0; // Noncompliant
// ...
}
}
----
== Resources
=== Documentation
* CERT - https://wiki.sei.cmu.edu/confluence/display/java/DCL51-J.+Do+not+shadow+or+obscure+identifiers+in+subscopes[DCL51-J. Do not shadow or obscure identifiers in subscopes]
=== Related rules
* S2176 - Class names should not shadow interfaces or superclasses
* S2387 - Child class fields should not shadow parent class fields
* S4977 - Type parameters should not shadow other type parameters
include::../rspecator.adoc[]