2023-10-16 12:04:08 +02:00
include::../why-fields.adoc[]
2023-05-03 11:06:20 +02:00
2023-10-16 12:04:08 +02:00
=== Noncompliant code example
2020-06-30 12:47:33 +02:00
2022-02-04 17:28:24 +01:00
[source,java]
2020-06-30 12:47:33 +02:00
----
class Foo {
public int myField;
public void doSomething() {
2023-06-15 17:09:18 +02:00
int myField = 0; // Noncompliant
2023-10-16 12:04:08 +02:00
// ...
2020-06-30 12:47:33 +02:00
}
}
----
2023-05-03 11:06:20 +02:00
== Resources
2021-09-21 15:40:35 +02:00
2023-06-15 17:09:18 +02:00
=== Documentation
2023-10-16 12:04:08 +02:00
* 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]
2021-06-02 20:44:38 +02:00
2023-10-16 12:04:08 +02:00
=== 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[]