Please provide
- Operating system: MacOS (Sequoia 15.7.1)
- SonarQube for IntelliJ plugin version:
- IntelliJ version: 11.2.0.82481
- Programming language you’re coding in: Java
- Is connected mode used: No
- SonarQube Cloud, SonarQube Server, or SonarQube Community Build? (if one of the latter two, which version?):
And a thorough description of the problem / question:
I frequently get warnings to “Remove useless assignments”. These are frequently false positives:
For example:
class Partial {
private final Map<Class<?>, Supplier<?>> registry = new HashMap<>();
...
private <T> T build(Class<?> clazz, Supplier<T> supplier) {
return (T) registry.computeIfAbsent(clazz, k -> supplier).get();
}
public void activateSubdomain(Subdomain.ActivateSubdomainRequest ... requests) {
// WARNING: Remove this useless assignment to local variable "subdomains".
var subdomains = build(SubdomainsDAO.class, () -> new PostgresSubdomainsDAO(jdbi, ids));
for (var request : requests) {
subdomains.activateSubdomain(request.subdomainId(), request.labelId(), null);
}
}
}