proposal: avoid_add_all_with_singleton_collection
#5094
Labels
lint-proposal
P3
A lower priority bug or feature request
status-pending
type-enhancement
A request for a change that isn't a bug
avoid_add_all_with_singleton_collection
Description
Call
add(foo)
overaddAll([foo])
.Details
Give a detailed description that should provide context and motivation. Ideally this could be used directly in the rule's documentation.
Kind
Style. Potentially performance with the unnecessary list allocation.
Bad Examples
collection.addAll([a]);
Good Examples
Discussion
This has around 1.5k occurrences (when checked by regex) internally. The number is likely much smaller if we only consider collection types from the SDK.
One potential downside to this lint is the editing cliff when going from 1 to multiple items, or multiple to 1 item.
The other factor that may make this not worthwhile, is whether we would apply it to the
ListBuilder
interface frompackage:built_collection
. Internally I see this pattern used onListBuilder
quite a bit - and that class does not implement any interface from the SDK.Discussion checklist
No prior discussion I can find.
The text was updated successfully, but these errors were encountered: