Skip to content

Commit 7e48219

Browse files
committed
Rename "old" state variables to "current" state, as suggested by Copilot: #6840 (review)
1 parent a02618e commit 7e48219

File tree

3 files changed

+34
-34
lines changed

3 files changed

+34
-34
lines changed

firebase-dataconnect/src/main/kotlin/com/google/firebase/dataconnect/core/DataConnectCredentialsTokenManager.kt

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -193,12 +193,12 @@ internal sealed class DataConnectCredentialsTokenManager<T : Any>(
193193
fun forceRefresh() {
194194
logger.debug { "forceRefresh()" }
195195
val oldState =
196-
state.getAndUpdate { oldState ->
197-
when (oldState) {
196+
state.getAndUpdate { currentState ->
197+
when (currentState) {
198198
is State.Closed -> State.Closed
199-
is State.New -> oldState.copy(forceTokenRefresh = true)
200-
is State.Idle -> oldState.copy(forceTokenRefresh = true)
201-
is State.Active -> State.Idle(oldState.provider, forceTokenRefresh = true)
199+
is State.New -> currentState.copy(forceTokenRefresh = true)
200+
is State.Idle -> currentState.copy(forceTokenRefresh = true)
201+
is State.Active -> State.Idle(currentState.provider, forceTokenRefresh = true)
202202
}
203203
}
204204

@@ -340,11 +340,11 @@ internal sealed class DataConnectCredentialsTokenManager<T : Any>(
340340
addTokenListener(newProvider)
341341

342342
val oldState =
343-
state.getAndUpdate { oldState ->
344-
when (oldState) {
343+
state.getAndUpdate { currentState ->
344+
when (currentState) {
345345
is State.Closed -> State.Closed
346-
is State.New -> State.Idle(newProvider, oldState.forceTokenRefresh)
347-
is State.Idle -> State.Idle(newProvider, oldState.forceTokenRefresh)
346+
is State.New -> State.Idle(newProvider, currentState.forceTokenRefresh)
347+
is State.Idle -> State.Idle(newProvider, currentState.forceTokenRefresh)
348348
is State.Active -> State.Idle(newProvider, forceTokenRefresh = false)
349349
}
350350
}

firebase-dataconnect/src/main/kotlin/com/google/firebase/dataconnect/core/FirebaseDataConnectImpl.kt

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -162,17 +162,17 @@ internal class FirebaseDataConnectImpl(
162162

163163
private fun initialize(): State.Initialized {
164164
val newState =
165-
state.updateAndGet { oldState ->
166-
when (oldState) {
165+
state.updateAndGet { currentState ->
166+
when (currentState) {
167167
is State.New -> {
168-
val grpcRPCs = createDataConnectGrpcRPCs(oldState.emulatorSettings)
168+
val grpcRPCs = createDataConnectGrpcRPCs(currentState.emulatorSettings)
169169
val grpcClient = createDataConnectGrpcClient(grpcRPCs)
170170
val queryManager = createQueryManager(grpcClient)
171171
State.Initialized(grpcRPCs, grpcClient, queryManager)
172172
}
173-
is State.Initialized -> oldState
174-
is State.Closing -> oldState
175-
is State.Closed -> oldState
173+
is State.Initialized -> currentState
174+
is State.Closing -> currentState
175+
is State.Closed -> currentState
176176
}
177177
}
178178

@@ -294,16 +294,16 @@ internal class FirebaseDataConnectImpl(
294294
}
295295

296296
override fun useEmulator(host: String, port: Int): Unit = runBlocking {
297-
state.update { oldState ->
298-
when (oldState) {
297+
state.update { currentState ->
298+
when (currentState) {
299299
is State.New ->
300-
oldState.copy(emulatorSettings = EmulatedServiceSettings(host = host, port = port))
300+
currentState.copy(emulatorSettings = EmulatedServiceSettings(host = host, port = port))
301301
is State.Initialized ->
302302
throw IllegalStateException(
303303
"Cannot call useEmulator() after instance has already been initialized."
304304
)
305-
is State.Closing -> oldState
306-
is State.Closed -> oldState
305+
is State.Closing -> currentState
306+
is State.Closed -> currentState
307307
}
308308
}
309309
}
@@ -443,12 +443,12 @@ internal class FirebaseDataConnectImpl(
443443
logger.warn(exception) { "close() failed" }
444444
} else {
445445
logger.debug { "close() completed successfully" }
446-
state.update { oldState ->
447-
check(oldState is State.Closing) {
448-
"oldState is ${oldState}, but expected Closing (error code hsee7gfxvz)"
446+
state.update { currentState ->
447+
check(currentState is State.Closing) {
448+
"currentState is ${currentState}, but expected Closing (error code hsee7gfxvz)"
449449
}
450-
check(oldState.closeJob === closeJob) {
451-
"oldState.closeJob is ${oldState.closeJob}, but expected $closeJob " +
450+
check(currentState.closeJob === closeJob) {
451+
"currentState.closeJob is ${currentState.closeJob}, but expected $closeJob " +
452452
"(error code n3x86pr6qn)"
453453
}
454454
State.Closed
@@ -459,16 +459,16 @@ internal class FirebaseDataConnectImpl(
459459
}
460460

461461
val newState =
462-
state.updateAndGet { oldState ->
463-
when (oldState) {
462+
state.updateAndGet { currentState ->
463+
when (currentState) {
464464
is State.New -> State.Closed
465465
is State.Initialized ->
466-
State.Closing(oldState.grpcRPCs, createCloseJob(oldState.grpcRPCs))
466+
State.Closing(currentState.grpcRPCs, createCloseJob(currentState.grpcRPCs))
467467
is State.Closing ->
468-
if (oldState.closeJob.isCancelled) {
469-
oldState.copy(closeJob = createCloseJob(oldState.grpcRPCs))
468+
if (currentState.closeJob.isCancelled) {
469+
currentState.copy(closeJob = createCloseJob(currentState.grpcRPCs))
470470
} else {
471-
oldState
471+
currentState
472472
}
473473
is State.Closed -> State.Closed
474474
}

firebase-dataconnect/testutil/src/main/kotlin/com/google/firebase/dataconnect/testutil/SuspendingCountDownLatch.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,9 @@ class SuspendingCountDownLatch(count: Int) {
6161
* @throws IllegalStateException if called when the count has already reached zero.
6262
*/
6363
fun countDown(): SuspendingCountDownLatch {
64-
_count.update { oldValue ->
65-
check(oldValue > 0) { "countDown() called too many times (oldValue=$oldValue)" }
66-
oldValue - 1
64+
_count.update { currentValue ->
65+
check(currentValue > 0) { "countDown() called too many times (currentValue=$currentValue)" }
66+
currentValue - 1
6767
}
6868
return this
6969
}

0 commit comments

Comments
 (0)