SonarQube (Version 8.0 (build 29455) ) reports code smell with “Functional Interfaces should be as specialised as possible” when I use Function<T, Integer>
instead of ToIntFunction<T>
. But the specialised implementation is not allowed by the compiler. I’m using it inside Collectors.toMap
.
Hello Master Ping Po,
First, let me welcome you in this forum, and thank you for your feedback.
Indeed, in such case, rule S4276 is raising a False Positive (FP), and the rule should not recommend to use the more specialized interface. I created the following ticket to improve the rule: SONARJAVA-3265
Cheers,
Michael