Affects PMD Version:
Future
Rule:
Description:
The current naming default configuration for final Java classes only containing static methods (utility classes) is [A-Z][a-zA-Z]+Util
. I concur with @asarkar, that argues in #1096 that the choice is too draconian. There a number of patterns that, I believe, are worth adding, and also some patterns that should trigger a warning. This issue is opened for discussing which naming patterns should be allowed for utility classes, here are my proposals.
main
method should get excluded from detection, as the name may match the executable name.App(lication)?
, Util(s)?
, Factory
er
. This is maybe too strict, but I cannot find any counterexample to that at the moment. Names like Builder
, Helper
, Manager
, Analyzer
, etc. should be discouraged, as they sound like entities performing a task, rather than a collection of utilities.java.util.Collections
, java.util.Arrays
, com.google.common.collect.Sets
, and so on. This rule is all but trivial to enforce. Just checking for an ending s
is probably too weak. One strategy could be, for classes ending in s
, to search the code for repeated usage of the class name without s
in parameter and return types. For instance, a Tuples
class should contain many (only?) methods that take or return a Tuple
, whatever that is.RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4