Skip to content

Commit c125f30

Browse files
mateoguzmanafacebook-github-bot
authored andcommitted
Kotlin: fix static code analysis weak warnings (4/n) (#52207)
Summary: Static code analysis reports several weak warnings, many of which seem to be leftovers after Kotlin migration. This PR addresses quite a few: - [Redundant curly braces in string template](https://www.jetbrains.com/help/inspectopedia/RemoveCurlyBracesFromTemplate.html) - [Redundant call to toString() in string template](https://www.jetbrains.com/help/inspectopedia/RemoveToStringInStringTemplate.html) ## Changelog: [INTERNAL] - Kotlin: fix static code analysis weak warnings (4/n) Pull Request resolved: #52207 Test Plan: ```sh yarn android yarn test-android ``` Reviewed By: javache Differential Revision: D77209873 Pulled By: cortinico fbshipit-source-id: 2bf5fcf7dcbf02632e721aab0688f73d15f220b9
1 parent 03ab6a3 commit c125f30

File tree

4 files changed

+18
-23
lines changed

4 files changed

+18
-23
lines changed

packages/react-native/ReactAndroid/src/main/java/com/facebook/react/animated/NativeAnimatedModule.kt

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -485,16 +485,14 @@ public class NativeAnimatedModule(reactContext: ReactApplicationContext) :
485485
override fun createAnimatedNode(tagDouble: Double, config: ReadableMap) {
486486
val tag = tagDouble.toInt()
487487
if (ANIMATED_MODULE_DEBUG) {
488-
FLog.d(NAME, "queue createAnimatedNode: ${tag} config: ${config.toHashMap().toString()}")
488+
FLog.d(NAME, "queue createAnimatedNode: $tag config: ${config.toHashMap()}")
489489
}
490490

491491
addOperation(
492492
object : UIThreadOperation() {
493493
override fun execute(animatedNodesManager: NativeAnimatedNodesManager) {
494494
if (ANIMATED_MODULE_DEBUG) {
495-
FLog.d(
496-
NAME,
497-
("execute createAnimatedNode: ${tag} config: ${config.toHashMap().toString()}"))
495+
FLog.d(NAME, ("execute createAnimatedNode: $tag config: ${config.toHashMap()}"))
498496
}
499497
animatedNodesManager.createAnimatedNode(tag, config)
500498
}
@@ -504,17 +502,14 @@ public class NativeAnimatedModule(reactContext: ReactApplicationContext) :
504502
override fun updateAnimatedNodeConfig(tagDouble: Double, config: ReadableMap) {
505503
val tag = tagDouble.toInt()
506504
if (ANIMATED_MODULE_DEBUG) {
507-
FLog.d(
508-
NAME, "queue updateAnimatedNodeConfig: ${tag} config: ${config.toHashMap().toString()}")
505+
FLog.d(NAME, "queue updateAnimatedNodeConfig: $tag config: ${config.toHashMap()}")
509506
}
510507

511508
addOperation(
512509
object : UIThreadOperation() {
513510
override fun execute(animatedNodesManager: NativeAnimatedNodesManager) {
514511
if (ANIMATED_MODULE_DEBUG) {
515-
FLog.d(
516-
NAME,
517-
("execute updateAnimatedNodeConfig: ${tag} config: ${config.toHashMap().toString()}"))
512+
FLog.d(NAME, ("execute updateAnimatedNodeConfig: $tag config: ${config.toHashMap()}"))
518513
}
519514
animatedNodesManager.updateAnimatedNodeConfig(tag, config)
520515
}
@@ -705,7 +700,7 @@ public class NativeAnimatedModule(reactContext: ReactApplicationContext) :
705700
if (ANIMATED_MODULE_DEBUG) {
706701
FLog.d(
707702
NAME,
708-
("execute connectAnimatedNodes: parent: ${parentNodeTag} child: ${childNodeTag}"))
703+
("execute connectAnimatedNodes: parent: $parentNodeTag child: $childNodeTag"))
709704
}
710705
animatedNodesManager.connectAnimatedNodes(parentNodeTag, childNodeTag)
711706
}
@@ -725,7 +720,7 @@ public class NativeAnimatedModule(reactContext: ReactApplicationContext) :
725720
if (ANIMATED_MODULE_DEBUG) {
726721
FLog.d(
727722
NAME,
728-
("execute disconnectAnimatedNodes: parent: ${parentNodeTag} child: ${childNodeTag}"))
723+
("execute disconnectAnimatedNodes: parent: $parentNodeTag child: $childNodeTag"))
729724
}
730725
animatedNodesManager.disconnectAnimatedNodes(parentNodeTag, childNodeTag)
731726
}
@@ -738,7 +733,7 @@ public class NativeAnimatedModule(reactContext: ReactApplicationContext) :
738733
if (ANIMATED_MODULE_DEBUG) {
739734
FLog.d(
740735
NAME,
741-
("queue connectAnimatedNodeToView: animatedNodeTag: ${animatedNodeTag} viewTag: ${viewTag}"))
736+
("queue connectAnimatedNodeToView: animatedNodeTag: $animatedNodeTag viewTag: $viewTag"))
742737
}
743738

744739
initializeLifecycleEventListenersForViewTag(viewTag)
@@ -749,7 +744,7 @@ public class NativeAnimatedModule(reactContext: ReactApplicationContext) :
749744
if (ANIMATED_MODULE_DEBUG) {
750745
FLog.d(
751746
NAME,
752-
("execute connectAnimatedNodeToView: animatedNodeTag: ${animatedNodeTag} viewTag: ${viewTag}"))
747+
("execute connectAnimatedNodeToView: animatedNodeTag: $animatedNodeTag viewTag: $viewTag"))
753748
}
754749
animatedNodesManager.connectAnimatedNodeToView(animatedNodeTag, viewTag)
755750
}
@@ -774,7 +769,7 @@ public class NativeAnimatedModule(reactContext: ReactApplicationContext) :
774769
if (ANIMATED_MODULE_DEBUG) {
775770
FLog.d(
776771
NAME,
777-
("execute disconnectAnimatedNodeFromView: ${animatedNodeTag} viewTag: ${viewTag}"))
772+
("execute disconnectAnimatedNodeFromView: $animatedNodeTag viewTag: $viewTag"))
778773
}
779774
animatedNodesManager.disconnectAnimatedNodeFromView(animatedNodeTag, viewTag)
780775
}
@@ -807,7 +802,7 @@ public class NativeAnimatedModule(reactContext: ReactApplicationContext) :
807802
if (ANIMATED_MODULE_DEBUG) {
808803
FLog.d(
809804
NAME,
810-
("queue addAnimatedEventToView: ${viewTag} eventName: ${eventName} eventMapping: ${eventMapping.toHashMap().toString()}"))
805+
("queue addAnimatedEventToView: $viewTag eventName: $eventName eventMapping: ${eventMapping.toHashMap()}"))
811806
}
812807

813808
initializeLifecycleEventListenersForViewTag(viewTag)
@@ -818,7 +813,7 @@ public class NativeAnimatedModule(reactContext: ReactApplicationContext) :
818813
if (ANIMATED_MODULE_DEBUG) {
819814
FLog.d(
820815
NAME,
821-
("execute addAnimatedEventToView: ${viewTag} eventName: ${eventName} eventMapping: ${eventMapping.toHashMap().toString()}"))
816+
("execute addAnimatedEventToView: $viewTag eventName: $eventName eventMapping: ${eventMapping.toHashMap()}"))
822817
}
823818
animatedNodesManager.addAnimatedEventToView(viewTag, eventName, eventMapping)
824819
}
@@ -835,7 +830,7 @@ public class NativeAnimatedModule(reactContext: ReactApplicationContext) :
835830
if (ANIMATED_MODULE_DEBUG) {
836831
FLog.d(
837832
NAME,
838-
("queue removeAnimatedEventFromView: viewTag: ${viewTag} eventName: ${eventName} animatedValueTag: ${animatedValueTag}"))
833+
("queue removeAnimatedEventFromView: viewTag: $viewTag eventName: $eventName animatedValueTag: $animatedValueTag"))
839834
}
840835

841836
decrementInFlightAnimationsForViewTag(viewTag)
@@ -846,7 +841,7 @@ public class NativeAnimatedModule(reactContext: ReactApplicationContext) :
846841
if (ANIMATED_MODULE_DEBUG) {
847842
FLog.d(
848843
NAME,
849-
("execute removeAnimatedEventFromView: viewTag: ${viewTag} eventName: ${eventName} animatedValueTag: ${animatedValueTag}"))
844+
("execute removeAnimatedEventFromView: viewTag: $viewTag eventName: $eventName animatedValueTag: $animatedValueTag"))
850845
}
851846
animatedNodesManager.removeAnimatedEventFromView(viewTag, eventName, animatedValueTag)
852847
}

packages/react-native/ReactAndroid/src/main/java/com/facebook/react/animated/NativeAnimatedNodesManager.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -381,15 +381,15 @@ public class NativeAnimatedNodesManager(
381381
("connectAnimatedNodeToView: Animated node connected to view [${viewTag}] should be of type ${PropsAnimatedNode::class.java.name}"))
382382
}
383383
checkNotNull(reactApplicationContext) {
384-
("connectAnimatedNodeToView: Animated node could not be connected, no ReactApplicationContext: ${viewTag}")
384+
("connectAnimatedNodeToView: Animated node could not be connected, no ReactApplicationContext: $viewTag")
385385
}
386386

387387
val uiManager = UIManagerHelper.getUIManagerForReactTag(reactApplicationContext, viewTag)
388388
if (uiManager == null) {
389389
ReactSoftExceptionLogger.logSoftException(
390390
TAG,
391391
ReactNoCrashSoftException(
392-
("connectAnimatedNodeToView: Animated node could not be connected to UIManager - uiManager disappeared for tag: ${viewTag}")))
392+
("connectAnimatedNodeToView: Animated node could not be connected to UIManager - uiManager disappeared for tag: $viewTag")))
393393
return
394394
}
395395

@@ -751,7 +751,7 @@ public class NativeAnimatedNodesManager(
751751
val reason = if (cyclesDetected > 0) ("cycles ($cyclesDetected)") else "disconnected regions"
752752
val ex =
753753
IllegalStateException(
754-
("Looks like animated nodes graph has ${reason}, there are ${activeNodesCount} but toposort visited only ${updatedNodesCount}"))
754+
("Looks like animated nodes graph has ${reason}, there are $activeNodesCount but toposort visited only $updatedNodesCount"))
755755
if (eventListenerInitializedForFabric && cyclesDetected == 0) {
756756
// TODO T71377544: investigate these SoftExceptions and see if we can remove entirely
757757
// or fix the root cause

packages/react-native/ReactAndroid/src/main/java/com/facebook/react/devsupport/PackagerStatusCheck.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ internal class PackagerStatusCheck {
7676
if (PACKAGER_OK_STATUS != bodyString) {
7777
FLog.e(
7878
ReactConstants.TAG,
79-
"Got unexpected response from packager when requesting status: ${bodyString}")
79+
"Got unexpected response from packager when requesting status: $bodyString")
8080
callback.onPackagerStatusFetched(false)
8181
return
8282
}

packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/style/BoxShadow.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public data class BoxShadow(
3838
when (val type = boxShadow.getType("color")) {
3939
ReadableType.Number -> boxShadow.getInt("color")
4040
ReadableType.Map -> ColorPropConverter.getColor(boxShadow.getMap("color"), context)
41-
else -> throw JSApplicationCausedNativeException("Unsupported color type ${type}")
41+
else -> throw JSApplicationCausedNativeException("Unsupported color type $type")
4242
}
4343
} else null
4444
val blurRadius =

0 commit comments

Comments
 (0)