Why this matters
Improves readability and prevents accidental mutation.
Extract repeated inline collections to unmodifiable static constants.
Improves readability and prevents accidental mutation.
Side-by-side examples engineers can pattern-match during review.
if (Set.of("A","B","C").contains(t)) { ... }private static final Set<String> ALLOWED = Set.of("A","B","C");
if (ALLOWED.contains(t)) { ... }List.of("x","y") scatteredstatic final List<String> KEYS = List.of("x","y")From the same buckets as this rule.