rspec/rules/S1117/java/rule.adoc

30 lines
666 B
Plaintext
Raw Permalink Normal View History

include::../why-fields.adoc[]
=== 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() {
int myField = 0; // Noncompliant
// ...
2020-06-30 12:47:33 +02:00
}
}
----
== 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[]