All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.sonar.l10n.java.rules.squid.S1452.html Maven / Gradle / Ivy

There is a newer version: 8.9.0.37768
Show newest version

Using a wildcard as a return type implicitly means that the return parameter should be considered as read-only but without any way to enforce this contract.

Let's take the example of method returning a "List<? extends Animal>". Is it possible on this list to add a Dog, a Cat, ... we simply don't know. The consumer of a method should not have to deal with such disruptive questions.

Noncompliant Code Example

List<? extends Animal> getAnimals(){...}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy