Java build or lint should fail when not all IntDef enum values are handled in a switch |
||
Issue descriptionIt might be neat for the Java build or lint to fail when not all IntDef enum values are handled in a switch statement. Adding some people on CC that might be interested.
,
Oct 22
FIY: I've run AS inspection and found ~70 warnings for this issue. Some of these warnings can be fixed by adding missing values to the switch, but some require @SuppressLint("SwitchIntDef").
,
Oct 23
I have no strong objections to this.
,
Oct 23
Another FIY: this came up during a code review. I hope that adding this check would remove the need for comments like this one: https://chromium-review.googlesource.com/c/chromium/src/+/1262644/3/chrome/android/java/src/org/chromium/chrome/browser/preferences/privacy/ClearBrowsingDataPreferences.java#200. |
||
►
Sign in to add a comment |
||
Comment 1 by bsazonov@chromium.org
, Oct 22Reviving this issue and cc-ing Ted. I agree with Michael that we should enforce that all IntDef values are handled by switches. suppressions.xml has a comment about this warning: "We have many C++ enums that we don't care about in java". I think we should suppress these cases with explicit @SuppressLint("SwitchIntDef"). [1] https://cs.chromium.org/chromium/src/build/android/lint/suppressions.xml?l=290&rcl=6be377dc25152e14ae50fd87c388712c27367712