Open jdussouillez opened 1 year ago
This is a specific case when you can't use method reference because of ambiguous context (because of overloaded methods for example).
Yes, we can not anything in this case. Checkstyle is not type aware tool, and no access to other files (whole validation is done based on code of single file) https://checkstyle.org/writingchecks.html#Limitations
I can suggest to use more advanced filters/suppressions to make it less aggressive in code to work around such problems: https://checkstyle.org/config_filters.html attention to xpath, and comments based with "influence", single suppression modules ( to keep suppressions in config , not in code - no pollution in code from tool)
http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/PreferMethodReferenceCheck.html
We get some false positive using rule
PreferMethodReference
. This is a specific case when you can't use method reference because of ambiguous context (because of overloaded methods for example).I guess it'll be complicated to fix as the rule should detect when a method reference is usable or not. No big deal though, the
CHECKSTYLE:OFF: <rule>
syntax works fine for the few errors we have with this.Test.java :
Checkstyle.xml :