It’s sad that such a good rule as LOD triggers so many false-positives.
It would be great if PMD could handle both these two issues (factories, builders) without relying on naming conventions but if that is very hard I would like it if an exception would be made for variables ending with “Builder” as well
Last edit: Alix Warnke 2015-10-07
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
With the next release, objects that are created by something called "...factory..." won't trigger this anymore.
This is also a problem using the Builder pattern.
There are many discussions on this topic, e.g. http://stackoverflow.com/questions/67561/do-fluent-interfaces-violate-the-law-of-demeter
It’s sad that such a good rule as LOD triggers so many false-positives.
It would be great if PMD could handle both these two issues (factories, builders) without relying on naming conventions but if that is very hard I would like it if an exception would be made for variables ending with “Builder” as well
Last edit: Alix Warnke 2015-10-07
Suggestion: A more general solution to identify the Builder pattern is to check if the last method name is "build()". Example:
javax.ws.rs.core.Response.<http status="">().build()
Alternatively make it possible to configure class exceptions for this rule
Last edit: Alix Warnke 2015-10-09
See https://github.com/pmd/pmd/issues/2160
Last edit: Andreas Dangel 2019-12-20