Skip to content

Commit c119960

Browse files
Lint
1 parent 51a9af1 commit c119960

32 files changed

+150
-124
lines changed

firebase-database/src/main/java/com/google/firebase/database/DatabaseError.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ public static DatabaseError fromCode(int code) {
165165
*/
166166
@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
167167
public static DatabaseError fromStatus(String status, String reason, String details) {
168-
Integer code = errorCodes.get(status.toLowerCase(Locale.US)));
168+
Integer code = errorCodes.get(status.toLowerCase(Locale.US));
169169
if (code == null) {
170170
code = UNKNOWN_ERROR;
171171
}

firebase-database/src/main/java/com/google/firebase/database/android/SqlPersistenceStorageEngine.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,8 @@ public void onCreate(SQLiteDatabase db) {
171171

172172
@Override
173173
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
174-
hardAssert(newVersion == DATABASE_VERSION, "Why is onUpgrade() called with a different version?");
174+
hardAssert(
175+
newVersion == DATABASE_VERSION, "Why is onUpgrade() called with a different version?");
175176
if (oldVersion <= 1) {
176177
// Leave old writes table.
177178

@@ -1036,7 +1037,7 @@ private static String pathToKey(Path path) {
10361037
}
10371038

10381039
private static String pathPrefixStartToPrefixEnd(String prefix) {
1039-
hardAssert(prefix.endsWith("/") : "Path keys must end with a '/'"_;
1040+
hardAssert(prefix.endsWith("/"), "Path keys must end with a '/'");
10401041
return prefix.substring(0, prefix.length() - 1) + (char) ('/' + 1);
10411042
}
10421043

firebase-database/src/main/java/com/google/firebase/database/connection/PersistentConnectionImpl.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1010,7 +1010,8 @@ private void putInternal(
10101010
}
10111011

10121012
private void sendPut(final long putId) {
1013-
hardAssert(canSendWrites(),
1013+
hardAssert(
1014+
canSendWrites(),
10141015
"sendPut called when we can't send writes (we're disconnected or writes are paused).");
10151016
final OutstandingPut put = outstandingPuts.get(putId);
10161017
final RequestResultCallback onComplete = put.getOnComplete();

firebase-database/src/main/java/com/google/firebase/database/core/CompoundWrite.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414

1515
package com.google.firebase.database.core;
1616

17+
import static com.google.firebase.database.core.utilities.Utilities.hardAssert;
18+
1719
import com.google.firebase.database.core.utilities.ImmutableTree;
1820
import com.google.firebase.database.snapshot.ChildKey;
1921
import com.google.firebase.database.snapshot.NamedNode;
@@ -25,8 +27,6 @@
2527
import java.util.List;
2628
import java.util.Map;
2729

28-
import static com.google.firebase.database.core.utilities.Utilities.hardAssert;
29-
3030
/**
3131
* This class holds a collection of writes that can be applied to nodes in unison. It abstracts away
3232
* the logic with dealing with priority writes and multiple nested writes. At any given path there
@@ -229,7 +229,7 @@ private Node applySubtreeWrite(Path relativePath, ImmutableTree<Node> writeTree,
229229
if (childKey.isPriorityChildName()) {
230230
// Apply priorities at the end so we don't update priorities for either empty nodes or
231231
// forget to apply priorities to empty nodes that are later filled
232-
hardAssert( childTree.getValue() != null, "Priority writes must always be leaf nodes");
232+
hardAssert(childTree.getValue() != null, "Priority writes must always be leaf nodes");
233233
priorityWrite = childTree.getValue();
234234
} else {
235235
node = applySubtreeWrite(relativePath.child(childKey), childTree, node);

firebase-database/src/main/java/com/google/firebase/database/core/EventRegistration.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414

1515
package com.google.firebase.database.core;
1616

17+
import static com.google.firebase.database.core.utilities.Utilities.hardAssert;
18+
1719
import com.google.firebase.database.DatabaseError;
1820
import com.google.firebase.database.annotations.NotNull;
1921
import com.google.firebase.database.core.view.Change;
@@ -22,8 +24,6 @@
2224
import com.google.firebase.database.core.view.QuerySpec;
2325
import java.util.concurrent.atomic.AtomicBoolean;
2426

25-
import static com.google.firebase.database.core.utilities.Utilities.hardAssert;
26-
2727
public abstract class EventRegistration {
2828
private AtomicBoolean zombied = new AtomicBoolean(false);
2929
private EventRegistrationZombieListener listener;

firebase-database/src/main/java/com/google/firebase/database/core/Path.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414

1515
package com.google.firebase.database.core;
1616

17+
import static com.google.firebase.database.core.utilities.Utilities.hardAssert;
18+
1719
import com.google.firebase.database.DatabaseException;
1820
import com.google.firebase.database.snapshot.ChildKey;
1921
import java.util.ArrayList;
@@ -22,8 +24,6 @@
2224
import java.util.List;
2325
import java.util.NoSuchElementException;
2426

25-
import static com.google.firebase.database.core.utilities.Utilities.hardAssert;
26-
2727
public class Path implements Iterable<ChildKey>, Comparable<Path> {
2828

2929
public static Path getRelative(Path from, Path to) {

firebase-database/src/main/java/com/google/firebase/database/core/Repo.java

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -920,7 +920,7 @@ private void sendReadyTransactions(Tree<List<TransactionData>> node) {
920920
List<TransactionData> queue = node.getValue();
921921
if (queue != null) {
922922
queue = buildTransactionQueue(node);
923-
hardAssert( queue.size() > 0); // Sending zero length transaction queue
923+
hardAssert(queue.size() > 0); // Sending zero length transaction queue
924924

925925
Boolean allRun = true;
926926
for (TransactionData transaction : queue) {
@@ -959,8 +959,9 @@ private void sendTransactionQueue(final List<TransactionData> queue, final Path
959959
}
960960

961961
for (TransactionData txn : queue) {
962-
hardAssert( txn.status
963-
== TransactionStatus.RUN); // sendTransactionQueue: items in queue should all be run.'
962+
hardAssert(
963+
txn.status
964+
== TransactionStatus.RUN); // sendTransactionQueue: items in queue should all be run.'
964965
txn.status = TransactionStatus.SENT;
965966
txn.retryCount++;
966967
Path relativePath = Path.getRelative(path, txn.path);
@@ -1116,7 +1117,7 @@ private void rerunTransactionQueue(List<TransactionData> queue, Path path) {
11161117
DatabaseError abortReason = null;
11171118
List<Event> events = new ArrayList<Event>();
11181119

1119-
hardAssert( relativePath != null); // rerunTransactionQueue: relativePath should not be null.
1120+
hardAssert(relativePath != null); // rerunTransactionQueue: relativePath should not be null.
11201121

11211122
if (transaction.status == TransactionStatus.NEEDS_ABORT) {
11221123
abortTransaction = true;
@@ -1321,14 +1322,15 @@ private void abortTransactionsAtNode(Tree<List<TransactionData>> node, int reaso
13211322
if (transaction.status == TransactionStatus.SENT_NEEDS_ABORT) {
13221323
// No-op. Already marked
13231324
} else if (transaction.status == TransactionStatus.SENT) {
1324-
hardAssert( lastSent == i - 1); // All SENT items should be at beginning of queue.
1325+
hardAssert(lastSent == i - 1); // All SENT items should be at beginning of queue.
13251326
lastSent = i;
13261327
// Mark transaction for abort when it comes back.
13271328
transaction.status = TransactionStatus.SENT_NEEDS_ABORT;
13281329
transaction.abortReason = abortError;
13291330
} else {
1330-
hardAssert( transaction.status
1331-
== TransactionStatus.RUN); // Unexpected transaction status in abort
1331+
hardAssert(
1332+
transaction.status
1333+
== TransactionStatus.RUN); // Unexpected transaction status in abort
13321334
// We can abort this immediately.
13331335
removeEventCallback(
13341336
new ValueEventRegistration(

firebase-database/src/main/java/com/google/firebase/database/core/SyncPoint.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414

1515
package com.google.firebase.database.core;
1616

17+
import static com.google.firebase.database.core.utilities.Utilities.hardAssert;
18+
1719
import com.google.firebase.database.DatabaseError;
1820
import com.google.firebase.database.annotations.NotNull;
1921
import com.google.firebase.database.annotations.Nullable;
@@ -40,8 +42,6 @@
4042
import java.util.Map;
4143
import java.util.Set;
4244

43-
import static com.google.firebase.database.core.utilities.Utilities.hardAssert;
44-
4545
/**
4646
* SyncPoint represents a single location in a SyncTree with 1 or more event registrations, meaning
4747
* we need to maintain 1 or more Views at this location to cache server data and raise appropriate
@@ -100,7 +100,7 @@ public List<DataEvent> applyOperation(
100100
QueryParams queryParams = operation.getSource().getQueryParams();
101101
if (queryParams != null) {
102102
View view = this.views.get(queryParams);
103-
hardAssert( view != null);
103+
hardAssert(view != null);
104104
return applyOperationToView(view, operation, writesCache, optCompleteServerCache);
105105
} else {
106106
List<DataEvent> events = new ArrayList<DataEvent>();

firebase-database/src/main/java/com/google/firebase/database/core/SyncTree.java

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -348,11 +348,11 @@ public List<? extends Event> applyTaggedRangeMerges(
348348
Path path, List<RangeMerge> rangeMerges, Tag tag) {
349349
QuerySpec query = queryForTag(tag);
350350
if (query != null) {
351-
hardAssert( path.equals(query.getPath()));
351+
hardAssert(path.equals(query.getPath()));
352352
SyncPoint syncPoint = syncPointTree.get(query.getPath());
353-
hardAssert( syncPoint != null, "Missing sync point for query tag that we're tracking");
353+
hardAssert(syncPoint != null, "Missing sync point for query tag that we're tracking");
354354
View view = syncPoint.viewForQuery(query);
355-
hardAssert( view != null, "Missing view for query tag that we're tracking");
355+
hardAssert(view != null, "Missing view for query tag that we're tracking");
356356
Node serverNode = view.getServerCache();
357357
for (RangeMerge merge : rangeMerges) {
358358
serverNode = merge.applyTo(serverNode);
@@ -400,7 +400,7 @@ public List<? extends Event> call() {
400400
private List<? extends Event> applyTaggedOperation(QuerySpec query, Operation operation) {
401401
Path queryPath = query.getPath();
402402
SyncPoint syncPoint = syncPointTree.get(queryPath);
403-
hardAssert( syncPoint != null, "Missing sync point for query tag that we're tracking");
403+
hardAssert(syncPoint != null, "Missing sync point for query tag that we're tracking");
404404
WriteTreeRef writesCache = pendingWriteTree.childWrites(queryPath);
405405
return syncPoint.applyOperation(operation, writesCache, /*serverCache*/ null);
406406
}
@@ -542,7 +542,8 @@ public List<? extends Event> call() {
542542
boolean viewAlreadyExists = syncPoint.viewExistsForQuery(query);
543543
if (!viewAlreadyExists && !query.loadsAllData()) {
544544
// We need to track a tag for this query
545-
hardAssert( !queryToTagMap.containsKey(query) , "View does not exist but we have a tag");
545+
hardAssert(
546+
!queryToTagMap.containsKey(query), "View does not exist but we have a tag");
546547
Tag tag = getNextQueryTag();
547548
queryToTagMap.put(query, tag);
548549
tagToQueryMap.put(tag, query);
@@ -663,7 +664,7 @@ public List<Event> call() {
663664
} else {
664665
for (QuerySpec queryToRemove : removed) {
665666
Tag tag = tagForQuery(queryToRemove);
666-
hardAssert( tag != null);
667+
hardAssert(tag != null);
667668
listenProvider.stopListening(queryForListening(queryToRemove), tag);
668669
}
669670
}
@@ -770,7 +771,7 @@ private void removeTags(List<QuerySpec> queries) {
770771
if (!removedQuery.loadsAllData()) {
771772
// We should have a tag for this
772773
Tag tag = this.tagForQuery(removedQuery);
773-
hardAssert( tag != null);
774+
hardAssert(tag != null);
774775
this.queryToTagMap.remove(removedQuery);
775776
this.tagToQueryMap.remove(tag);
776777
}
@@ -798,8 +799,9 @@ private void setupListener(QuerySpec query, View view) {
798799
// The root of this subtree has our query. We're here because we definitely need to send a
799800
// listen for that, but we may need to shadow other listens as well.
800801
if (tag != null) {
801-
hardAssert( !subtree.getValue().hasCompleteView(),
802-
"If we're adding a query, it shouldn't be shadowed");
802+
hardAssert(
803+
!subtree.getValue().hasCompleteView(),
804+
"If we're adding a query, it shouldn't be shadowed");
803805
} else {
804806
// Shadow everything at or below this location, this is a default listener.
805807
subtree.foreach(

firebase-database/src/main/java/com/google/firebase/database/core/WriteTree.java

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414

1515
package com.google.firebase.database.core;
1616

17+
import static com.google.firebase.database.core.utilities.Utilities.hardAssert;
18+
1719
import com.google.firebase.database.core.utilities.Predicate;
1820
import com.google.firebase.database.core.view.CacheNode;
1921
import com.google.firebase.database.snapshot.ChildKey;
@@ -25,8 +27,6 @@
2527
import java.util.List;
2628
import java.util.Map;
2729

28-
import static com.google.firebase.database.core.utilities.Utilities.hardAssert;
29-
3030
/**
3131
* Defines a single user-initiated write operation. May be the result of a set(), transaction(), or
3232
* update() call. In the case of a set() or transaction, snap wil be non-null. In the case of an
@@ -69,7 +69,7 @@ public WriteTreeRef childWrites(Path path) {
6969

7070
/** Record a new overwrite from user code. */
7171
public void addOverwrite(Path path, Node snap, Long writeId, boolean visible) {
72-
hardAssert( writeId > this.lastWriteId); // Stacking an older write on top of newer ones
72+
hardAssert(writeId > this.lastWriteId); // Stacking an older write on top of newer ones
7373
this.allWrites.add(new UserWriteRecord(writeId, path, snap, visible));
7474
if (visible) {
7575
this.visibleWrites = this.visibleWrites.addWrite(path, snap);
@@ -79,7 +79,7 @@ public void addOverwrite(Path path, Node snap, Long writeId, boolean visible) {
7979

8080
/** Record a new merge from user code. */
8181
public void addMerge(Path path, CompoundWrite changedChildren, Long writeId) {
82-
hardAssert( writeId > this.lastWriteId); // Stacking an older write on top of newer ones
82+
hardAssert(writeId > this.lastWriteId); // Stacking an older write on top of newer ones
8383
this.allWrites.add(new UserWriteRecord(writeId, path, changedChildren));
8484
this.visibleWrites = this.visibleWrites.addWrites(path, changedChildren);
8585
this.lastWriteId = writeId;
@@ -128,7 +128,7 @@ public boolean removeWrite(long writeId) {
128128
}
129129
idx++;
130130
}
131-
hardAssert( writeToRemove != null , "removeWrite called with nonexistent writeId");
131+
hardAssert(writeToRemove != null, "removeWrite called with nonexistent writeId");
132132

133133
this.allWrites.remove(writeToRemove);
134134

@@ -302,8 +302,9 @@ public Node calcEventCacheAfterServerOverwrite(
302302
final Path childPath,
303303
final Node existingEventSnap,
304304
final Node existingServerSnap) {
305-
hardAssert( existingEventSnap != null || existingServerSnap != null,
306-
"Either existingEventSnap or existingServerSnap must exist");
305+
hardAssert(
306+
existingEventSnap != null || existingServerSnap != null,
307+
"Either existingEventSnap or existingServerSnap must exist");
307308
Path path = treePath.child(childPath);
308309
if (this.visibleWrites.hasCompleteWrite(path)) {
309310
// At this point we can probably guarantee that we're in case 2, meaning no events

0 commit comments

Comments
 (0)