MutableMethodReturnTypeMethod return type should use the immutable type (such as ImmutableList) instead of the general collection interface type (such as List)

Severity

WARNING

Has Fix?

REQUIRES_HUMAN_ATTENTION

The problem

For method return type, you should use the immutable type (such as
ImmutableList) instead of the general collection interface type (such as
List). This communicates to your callers important semantic
guarantees.

This is consistent with Effective Java Item 52, which says to refer to
objects by their interfaces. Guava’s immutable collection classes offer
meaningful behavioral guarantees – they are not merely a specific
implementation as in the case of, say, ArrayList. They should be treated as
interfaces in every important sense of the word.