I have the following logic;
..
if(list.stream()
.filter(MyClass::isEnabled)
.filter(this::isActive)
.count() > 0) {
//do smth
}
..
private boolean isActive(MyClass obj) {
return bool;
}
As you see, isActive
method is being used in the stream structure, but when I build this class on Jenkins, I get the unused private method issue from SonarQube, it says you should delete this redundant private method. Is this a bug? If not, why haven't they still included lambda logic in their analyze structure?
Only solution is, obviously, to do this;
.filter(obj -> isActive(obj))
, but it destroys the uniformity, and even the readability (imo).
This is a known issue of SonarQube java analyzer : https://jira.sonarsource.com/browse/SONARJAVA-583
This is due to a lack of semantic analysis to resolve properly method reference (thus identify to which method this::isActive refers to).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With