You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In checkstyle/checkstyle#14229 we are enabling the CollectorMutability check in the Checkstyle repository. The Checkstyle team tries to minimize the dependencies they have on Guava. Therefore, the rewrite to Immutable{List,Map,Set}.toImmutable{List,Map,Set}() is not desirable. An alternative would be to use the Collectors.toUnmodifiable{List,Map,Set}(). This is a good alternative as this also clearly communicates that a list is used that should not be modified.
Description of the proposed new feature
Support a stylistic preference.
Avoid a common gotcha, or potential problem.
Improve performance.
I would like to rewrite the following code:
.collect(Collectors.toSet());
to:
.collect(Collectors.toUnmodifiableSet());
Considerations
Two things:
As @Stephan202 notes, this should take into account that this rewrite is only valid when JDK > 9.
This XXX in ThirdPartyLibrary should be resolved as well.
Participation
I am willing to submit a pull request to implement this improvement.
The text was updated successfully, but these errors were encountered:
Problem
In checkstyle/checkstyle#14229 we are enabling the
CollectorMutability
check in the Checkstyle repository. The Checkstyle team tries to minimize the dependencies they have on Guava. Therefore, the rewrite toImmutable{List,Map,Set}.toImmutable{List,Map,Set}()
is not desirable. An alternative would be to use theCollectors.toUnmodifiable{List,Map,Set}()
. This is a good alternative as this also clearly communicates that a list is used that should not be modified.Description of the proposed new feature
I would like to rewrite the following code:
to:
Considerations
Two things:
ThirdPartyLibrary
should be resolved as well.Participation
The text was updated successfully, but these errors were encountered: