Skip to content

Commit f3f2f4c

Browse files
authored
Add @CanIgnoreReturnValue annotations, inspired by cl/457735855 (#3872)
1 parent 3c323f2 commit f3f2f4c

File tree

3 files changed

+14
-0
lines changed

3 files changed

+14
-0
lines changed

firebase-firestore/src/androidTest/java/com/google/firebase/firestore/TransactionTest.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
import com.google.android.gms.tasks.Task;
3030
import com.google.android.gms.tasks.TaskCompletionSource;
3131
import com.google.android.gms.tasks.Tasks;
32+
import com.google.errorprone.annotations.CanIgnoreReturnValue;
3233
import com.google.firebase.firestore.FirebaseFirestoreException.Code;
3334
import com.google.firebase.firestore.testutil.IntegrationTestUtil;
3435
import com.google.firebase.firestore.util.AsyncQueue.TimerId;
@@ -88,16 +89,19 @@ private static class TransactionTester {
8889
db = inputDb;
8990
}
9091

92+
@CanIgnoreReturnValue
9193
public TransactionTester withExistingDoc() {
9294
fromExistingDoc = true;
9395
return this;
9496
}
9597

98+
@CanIgnoreReturnValue
9699
public TransactionTester withNonexistentDoc() {
97100
fromExistingDoc = false;
98101
return this;
99102
}
100103

104+
@CanIgnoreReturnValue
101105
public TransactionTester run(TransactionStage... inputStages) {
102106
stages = Arrays.asList(inputStages);
103107
return this;

firebase-firestore/src/test/java/com/google/firebase/firestore/local/LocalSerializerTest.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
import static org.junit.Assert.assertEquals;
3030
import static org.junit.Assert.assertTrue;
3131

32+
import com.google.errorprone.annotations.CanIgnoreReturnValue;
3233
import com.google.firebase.Timestamp;
3334
import com.google.firebase.firestore.bundle.BundledQuery;
3435
import com.google.firebase.firestore.core.Query;
@@ -81,6 +82,7 @@ static class TestWriteBuilder {
8182
this.builder = Write.newBuilder();
8283
}
8384

85+
@CanIgnoreReturnValue
8486
TestWriteBuilder addSet() {
8587
builder.setUpdate(
8688
com.google.firestore.v1.Document.newBuilder()
@@ -90,6 +92,7 @@ TestWriteBuilder addSet() {
9092
return this;
9193
}
9294

95+
@CanIgnoreReturnValue
9396
TestWriteBuilder addPatch() {
9497
builder
9598
.setUpdate(
@@ -102,11 +105,13 @@ TestWriteBuilder addPatch() {
102105
return this;
103106
}
104107

108+
@CanIgnoreReturnValue
105109
TestWriteBuilder addDelete() {
106110
builder.setDelete("projects/p/databases/d/documents/baz/quux");
107111
return this;
108112
}
109113

114+
@CanIgnoreReturnValue
110115
TestWriteBuilder addUpdateTransforms() {
111116
builder
112117
.addUpdateTransforms(
@@ -120,6 +125,7 @@ TestWriteBuilder addUpdateTransforms() {
120125
return this;
121126
}
122127

128+
@CanIgnoreReturnValue
123129
TestWriteBuilder addLegacyTransform() {
124130
builder
125131
.setTransform(

firebase-firestore/src/testUtil/java/com/google/firebase/firestore/testutil/ComparatorTester.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import com.google.common.collect.ImmutableList;
2323
import com.google.common.collect.Lists;
2424
import com.google.common.primitives.Ints;
25+
import com.google.errorprone.annotations.CanIgnoreReturnValue;
2526
import com.google.firebase.firestore.util.Preconditions;
2627
import java.util.Comparator;
2728
import java.util.List;
@@ -101,6 +102,7 @@ public ComparatorTester(@Nullable Comparator<?> comparator) {
101102
* Activates enforcement of {@code a.equals(b) == (a.compareTo(b) == 0)}. This is off by default
102103
* when testing {@link Comparator}s, but can be turned on if required.
103104
*/
105+
@CanIgnoreReturnValue
104106
public ComparatorTester requireConsistencyWithEquals() {
105107
testForEqualsCompatibility = true;
106108
return this;
@@ -110,6 +112,7 @@ public ComparatorTester requireConsistencyWithEquals() {
110112
* Deactivates enforcement of {@code a.equals(b) == (a.compareTo(b) == 0)}. This is on by default
111113
* when testing {@link Comparable}s, but can be turned off if required.
112114
*/
115+
@CanIgnoreReturnValue
113116
public ComparatorTester permitInconsistencyWithEquals() {
114117
testForEqualsCompatibility = false;
115118
return this;
@@ -122,6 +125,7 @@ public ComparatorTester permitInconsistencyWithEquals() {
122125
*
123126
* @return {@code this} (to allow chaining of calls)
124127
*/
128+
@CanIgnoreReturnValue
125129
public ComparatorTester addEqualityGroup(Object... objects) {
126130
Preconditions.checkNotNull(objects);
127131
Preconditions.checkArgument(objects.length > 0, "Array must not be empty");

0 commit comments

Comments
 (0)