Skip to content

Clean up warnings #216

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 11 commits into from
Jan 29, 2019
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,9 @@ public LLRBValueNode<K, V> copy(
LLRBNode<K, V> newLeft = left == null ? this.left : left;
LLRBNode<K, V> newRight = right == null ? this.right : right;
if (color == Color.RED) {
return new LLRBRedValueNode<K, V>(newKey, newValue, newLeft, newRight);
return new LLRBRedValueNode<>(newKey, newValue, newLeft, newRight);
} else {
return new LLRBBlackValueNode<K, V>(newKey, newValue, newLeft, newRight);
return new LLRBBlackValueNode<>(newKey, newValue, newLeft, newRight);
}
}

Expand Down Expand Up @@ -221,7 +221,7 @@ private LLRBValueNode<K, V> fixUp() {
if (n.right.isRed() && !n.left.isRed()) {
n = n.rotateLeft();
}
if (n.left.isRed() && ((LLRBValueNode<K, V>) (n.left)).left.isRed()) {
if (n.left.isRed() && ((LLRBValueNode<K, V>) n.left).left.isRed()) {
n = n.rotateRight();
}
if (n.left.isRed() && n.right.isRed()) {
Expand All @@ -232,13 +232,13 @@ private LLRBValueNode<K, V> fixUp() {

private LLRBValueNode<K, V> rotateLeft() {
LLRBValueNode<K, V> newLeft =
this.copy(null, null, Color.RED, null, ((LLRBValueNode<K, V>) (this.right)).left);
this.copy(null, null, Color.RED, null, ((LLRBValueNode<K, V>) this.right).left);
return (LLRBValueNode<K, V>) this.right.copy(null, null, this.getColor(), newLeft, null);
}

private LLRBValueNode<K, V> rotateRight() {
LLRBValueNode<K, V> newRight =
this.copy(null, null, Color.RED, ((LLRBValueNode<K, V>) (this.left)).right, null);
this.copy(null, null, Color.RED, ((LLRBValueNode<K, V>) this.left).right, null);
return (LLRBValueNode<K, V>) this.left.copy(null, null, this.getColor(), null, newRight);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ static class Base1_2 implements Iterable<BooleanChunk> {
public Base1_2(int size) {
int toCalc = size + 1;
length = (int) Math.floor(Math.log(toCalc) / Math.log(2));
long mask = (long) (Math.pow(2, length)) - 1;
long mask = ((long) Math.pow(2, length)) - 1;
value = toCalc & mask;
}

Expand Down Expand Up @@ -340,7 +340,7 @@ public static <A, B, C> RBTreeSortedMap<A, C> buildFrom(
Comparator<A> comparator) {
Builder<A, B, C> builder = new Builder<>(keys, values, translator);
Collections.sort(keys, comparator);
Iterator<BooleanChunk> iter = (new Base1_2(keys.size())).iterator();
Iterator<BooleanChunk> iter = new Base1_2(keys.size()).iterator();
int index = keys.size();
while (iter.hasNext()) {
BooleanChunk next = iter.next();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ public static class StopListenerSupportFragment extends android.support.v4.app.F
CallbackList callbacks = new CallbackList();

@Override
@SuppressWarnings("SynchronizeOnNonFinalField")
public void onStop() {
super.onStop();

Expand All @@ -100,6 +101,7 @@ public static class StopListenerFragment extends android.app.Fragment {
CallbackList callbacks = new CallbackList();

@Override
@SuppressWarnings("SynchronizeOnNonFinalField")
public void onStop() {
super.onStop();

Expand All @@ -116,6 +118,9 @@ public void onStop() {
@Nullable
private static <T> T castFragment(Class<T> fragmentClass, @Nullable Object fragment, String tag) {
try {
if (fragment == null) {
return null;
}
return fragmentClass.cast(fragment);
} catch (ClassCastException e) {
throw new IllegalStateException(
Expand All @@ -132,8 +137,8 @@ private static <T> T castFragment(Class<T> fragmentClass, @Nullable Object fragm
private static final String FRAGMENT_TAG = "FirestoreOnStopObserverFragment";

/**
* Implementation for non-FragmentActivity Activity's. Unfortunatly, all Fragment related
* classes/methods with nonFragmentActivityActivity's are deprecated, implying that almost
* Implementation for non-FragmentActivity Activities. Unfortunately, all Fragment related
* classes/methods with nonFragmentActivityActivities are deprecated, implying that almost
* everything in this function is deprecated.
*/
@SuppressWarnings("deprecation")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
import static com.google.firebase.firestore.testutil.TestUtil.path;
import static com.google.firebase.firestore.testutil.TestUtil.targetChange;
import static java.util.Arrays.asList;
import static junit.framework.Assert.assertEquals;
import static org.junit.Assert.assertEquals;
import static org.mockito.Mockito.mock;

import com.google.firebase.database.collection.ImmutableSortedMap;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import junit.framework.Assert;
import org.junit.Assert;
import org.robolectric.Robolectric;

public class TestUtil {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
package com.google.firebase.firestore.core;

import static com.google.firebase.firestore.testutil.TestUtil.path;
import static junit.framework.Assert.assertEquals;
import static org.mockito.Matchers.any;
import static org.junit.Assert.assertEquals;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.doAnswer;
import static org.mockito.Mockito.inOrder;
import static org.mockito.Mockito.mock;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ private QueryData addNextQuery() {
}

private DocumentKey nextTestDocumentKey() {
return DocumentKey.fromPathString("docs/doc_" + (++previousDocNum));
return DocumentKey.fromPathString("docs/doc_" + ++previousDocNum);
}

private Document nextTestDocument() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ public void testReadSeveralDocumentsIncludingMissingDocument() {
}
written.put(DocumentKey.fromPathString("foo/nonexistent"), null);

List<String> keys = new ArrayList(Arrays.asList(paths));
List<String> keys = new ArrayList<>(Arrays.asList(paths));
keys.add("foo/nonexistent");
Map<DocumentKey, MaybeDocument> read = getAll(keys);
assertEquals(written, read);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ public void addsSentinelRows() {
String path = row.getString(0);
long sequenceNumber = row.getLong(1);

int docNum = Integer.parseInt(path.split("_")[1]);
int docNum = Integer.parseInt(path.split("_", -1)[1]);
// The even documents were missing sequence numbers, they should now be filled in
// to have the new sequence number. The odd documents should have their
// sequence number unchanged, and so be the old value.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@
import static com.google.firebase.firestore.testutil.TestUtil.docSet;
import static com.google.firebase.firestore.testutil.TestUtil.field;
import static com.google.firebase.firestore.testutil.TestUtil.map;
import static junit.framework.Assert.assertFalse;
import static junit.framework.Assert.assertNull;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;

import com.google.firebase.firestore.model.value.FieldValue;
Expand All @@ -38,13 +38,10 @@
public class DocumentSetTest {

private static final Comparator<Document> TEST_COMPARATOR =
new Comparator<Document>() {
@Override
public int compare(Document left, Document right) {
FieldValue leftValue = left.getField(field("sort"));
FieldValue rightValue = right.getField(field("sort"));
return leftValue.compareTo(rightValue);
}
(left, right) -> {
FieldValue leftValue = left.getField(field("sort"));
FieldValue rightValue = right.getField(field("sort"));
return leftValue.compareTo(rightValue);
};

private static final Document DOC1 = doc("docs/1", 0, map("sort", 2));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ public void testExtractsFields() {
FieldValue val = wrapObject("foo", map("a", 1, "b", true, "c", "string"));
assertTrue(val instanceof ObjectValue);
ObjectValue obj = (ObjectValue) val;
assertTrue((obj.get(field("foo"))) instanceof ObjectValue);
assertTrue(obj.get(field("foo")) instanceof ObjectValue);
assertEquals(wrap(1), obj.get(field("foo.a")));
assertEquals(wrap(true), obj.get(field("foo.b")));
assertEquals(wrap("string"), obj.get(field("foo.c")));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@
import static com.google.firebase.firestore.testutil.TestUtil.version;
import static java.util.Arrays.asList;
import static java.util.Collections.emptyList;
import static junit.framework.Assert.fail;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;

import com.google.firebase.database.collection.ImmutableSortedSet;
import com.google.firebase.firestore.TestUtil.TestTargetMetadataProvider;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
@Config(manifest = Config.NONE)
@SuppressWarnings({"unused", "WeakerAccess", "SpellCheckingInspection"})
public class MapperTest {
private static final double EPSILON = 0.00001f;
private static final double EPSILON = 0.0003;

private static class StringBean {
private String value;
Expand Down