Placeholder description for now. Let's make a list of annoyances and clean them up.
Some proposed crufty idioms:
Collections.singleton
Collections.singletonMap
Collections.emptyMap
Collections.emptyList
Collections.emptySet
Arrays.asList(foo, bar, baz) when it can just be List.of(foo, bar, baz) (but not Arrays.asList(someArray))
new ArrayList<>(Arrays.asList(foo, bar, baz)) might warrant an audit beyond just the above (if the mutability of the resulting list isn't actually necessary)
String.format(Locale.ROOT, ...) probably should be org.elasticsearch.core.Strings.format(...)
someStream.collect(Collectors.toList()) can be someStream.toList()
Strings.collectionToDelimitedString( can be a joining() in some cases
$stream$.map($x$ -> $x$.$method$()) (hat tip to @jbaiera)
...
Discussion
Question: should we (the Data Management team) limit this to just 'our' sections of the code or should it be an Elasticsearch-wide effort? My immediate answer I suppose is that we may as well do it across the whole codebase if the cost of doing a particular cleanup is low enough. Also if we do it across the whole codebase then we can mark the bad thing as being forbidden.
Source of additional issues: some of the various core/ and common/ could be used in more places, e.g. org.elasticsearch.core.Strings.format as mentioned above.
Placeholder description for now. Let's make a list of annoyances and clean them up.
Some proposed crufty idioms:
Collections.singleton
Collections.singletonMap
Collections.emptyMap
Collections.emptyList
Collections.emptySet
Arrays.asList(foo, bar, baz)
when it can just beList.of(foo, bar, baz)
(but notArrays.asList(someArray)
)new ArrayList<>(Arrays.asList(foo, bar, baz))
might warrant an audit beyond just the above (if the mutability of the resulting list isn't actually necessary)String.format(Locale.ROOT, ...)
probably should beorg.elasticsearch.core.Strings.format(...)
someStream.collect(Collectors.toList())
can besomeStream.toList()
Strings.collectionToDelimitedString(
can be ajoining()
in some cases$stream$.map($x$ -> $x$.$method$())
(hat tip to @jbaiera)...
Discussion
Question: should we (the Data Management team) limit this to just 'our' sections of the code or should it be an Elasticsearch-wide effort? My immediate answer I suppose is that we may as well do it across the whole codebase if the cost of doing a particular cleanup is low enough. Also if we do it across the whole codebase then we can mark the bad thing as being forbidden.
Source of additional issues: some of the various
core/
andcommon/
could be used in more places, e.g.org.elasticsearch.core.Strings.format
as mentioned above.