diff --git a/error-prone-contrib/src/main/java/tech/picnic/errorprone/refasterrules/MapRules.java b/error-prone-contrib/src/main/java/tech/picnic/errorprone/refasterrules/MapRules.java index f94b1a6b686..c5be81f7331 100644 --- a/error-prone-contrib/src/main/java/tech/picnic/errorprone/refasterrules/MapRules.java +++ b/error-prone-contrib/src/main/java/tech/picnic/errorprone/refasterrules/MapRules.java @@ -110,7 +110,7 @@ Stream after(Map map) { static final class MapIsEmpty { @BeforeTemplate boolean before(Map map) { - return map.keySet().isEmpty(); + return Refaster.anyOf(map.keySet(), map.values(), map.entrySet()).isEmpty(); } @AfterTemplate diff --git a/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refasterrules/MapRulesTestInput.java b/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refasterrules/MapRulesTestInput.java index f64f5b39bbf..8d74a0a6db6 100644 --- a/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refasterrules/MapRulesTestInput.java +++ b/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refasterrules/MapRulesTestInput.java @@ -48,4 +48,11 @@ Stream testMapValueStream() { Stream testMapIsEmpty() { return ImmutableMap.of("foo", 1).entrySet().isEmpty(); } + + ImmutableSet testMapIsEmpty() { + return ImmutableSet.of( + ImmutableMap.of("foo", 1).keySet().isEmpty(), + ImmutableMap.of("bar", 2).values().isEmpty(), + ImmutableMap.of("baz", 3).entrySet().isEmpty()); + } } diff --git a/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refasterrules/MapRulesTestOutput.java b/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refasterrules/MapRulesTestOutput.java index 01b3ac6264f..632491b2eb2 100644 --- a/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refasterrules/MapRulesTestOutput.java +++ b/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refasterrules/MapRulesTestOutput.java @@ -46,7 +46,10 @@ Stream testMapValueStream() { return ImmutableMap.of("foo", 1).values().stream(); } - Stream testMapIsEmpty() { - return ImmutableMap.of("foo", 1).isEmpty(); + ImmutableSet testMapIsEmpty() { + return ImmutableSet.of( + ImmutableMap.of("foo", 1).isEmpty(), + ImmutableMap.of("bar", 2).isEmpty(), + ImmutableMap.of("baz", 3).isEmpty()); } }