Modify rule S4838: Fix typos (#2906)

This commit is contained in:
Alban Auzeill 2023-08-18 15:55:15 +02:00 committed by GitHub
parent 2808713f12
commit a25eaee927
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -19,7 +19,7 @@ Remove the explicit downcasts in the loop body.
----
for (Object item : getPersons()) { // Noncompliant, iteration element is implicitly upcast here
Person person = (Person) item; // Noncompliant, item is explicitly downcast here
person.getAdress();
person.getAddress();
}
----
@ -28,7 +28,7 @@ for (Object item : getPersons()) { // Noncompliant, iteration element is implici
[source,java,diff-id=1,diff-type=compliant]
----
for (Person person : getPersons()) { // Compliant
person.getAddress() ;
person.getAddress();
}
----
@ -40,7 +40,7 @@ Alternatively, use the `var` keyword to automatically infer the variable type (s
----
for (Object item : getPersons()) { // Noncompliant, iteration element is implicitly upcast here
Person person = (Person) item; // Noncompliant, item is explicitly downcast here
person.getAdress();
person.getAddress();
}
----
@ -49,7 +49,7 @@ for (Object item : getPersons()) { // Noncompliant, iteration element is implici
[source,java,diff-id=2,diff-type=compliant]
----
for (var person : getPersons()) { // Compliant
person.getAddress() ;
person.getAddress();
}
----
@ -57,7 +57,7 @@ for (var person : getPersons()) { // Compliant
The implicit upcast in the loop header is not reported when there is no downcast in the loop body.
[source,java,diff-id=2,diff-type=noncompliant]
[source,java]
----
for (Object item : getPersons()) { // Compliant
System.out.println(item);