google / google/error-prone

New check proposal: use of `Enum.compareTo`

Open
#4,720 10 comments 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
7.2k
Forks
820
Avg merge
5h 9m
Merged PRs (30d)
50

Description

The `EnumOrdinal` check wisely says that "You should almost never invoke the `Enum.ordinal()` method" because it's not guaranteed to be stable. I think there should be a similar `EnumCompareTo` check since `Enum.compareTo()` compares by ordinal, and the same considerations about lack of stability apply.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.