Skip to content

Commit d547d9e

Browse files
mateoguzmanafacebook-github-bot
authored andcommitted
Kotlin: redundant unit return type [1/2] (#52993)
Summary: Fixing some warnings from static code analysis regarding [redundant unit return type](https://www.jetbrains.com/help/inspectopedia/RedundantUnitReturnType.html). ## Changelog: [INTERNAL] - Kotlin: redundant unit return type [1/2] Pull Request resolved: #52993 Test Plan: ```sh yarn test-android yarn android ``` Reviewed By: cortinico Differential Revision: D79546007 Pulled By: rshest fbshipit-source-id: 017cb3b70333fe652ecb1bdca751fa4f56f737fd
1 parent e39fd8f commit d547d9e

32 files changed

Lines changed: 100 additions & 114 deletions

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public class MemoryPressureRouter(context: Context) : ComponentCallbacks2 {
2121
context.applicationContext.registerComponentCallbacks(this)
2222
}
2323

24-
public fun destroy(context: Context): Unit {
24+
public fun destroy(context: Context) {
2525
context.applicationContext.unregisterComponentCallbacks(this)
2626
}
2727

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ public open class ReactFragment : Fragment(), PermissionAwareActivity {
161161
permissions: Array<String>,
162162
requestCode: Int,
163163
listener: PermissionListener?
164-
): Unit {
164+
) {
165165
permissionListener = listener
166166
requestPermissions(permissions, requestCode)
167167
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import com.facebook.react.common.annotations.internal.LegacyArchitectureLogLevel
1414
@Deprecated("This class is deprecated and will be removed in the next major release.")
1515
@LegacyArchitecture(logLevel = LegacyArchitectureLogLevel.ERROR)
1616
internal interface ReactPackageLogger {
17-
fun startProcessPackage(): Unit
17+
fun startProcessPackage()
1818

19-
fun endProcessPackage(): Unit
19+
fun endProcessPackage()
2020
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public abstract class AnimatedNode {
2727
@JvmField internal var BFSColor: Int = INITIAL_BFS_COLOR
2828
@JvmField internal var tag: Int = -1
2929

30-
internal fun addChild(child: AnimatedNode): Unit {
30+
internal fun addChild(child: AnimatedNode) {
3131
val currentChildren =
3232
children
3333
?: ArrayList<AnimatedNode>(DEFAULT_ANIMATED_NODE_CHILD_COUNT).also { children = it }

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ internal class DecayAnimation(config: ReadableMap) : AnimationDriver() {
2828
resetConfig(config)
2929
}
3030

31-
override fun resetConfig(config: ReadableMap): Unit {
31+
override fun resetConfig(config: ReadableMap) {
3232
velocity = config.getDouble("velocity")
3333
deceleration = config.getDouble("deceleration")
3434
startFrameTimeMillis = -1

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ public class NativeAnimatedModule(reactContext: ReactApplicationContext) :
219219
*
220220
* @param viewTag The tag of the scroll view that has stopped scrolling
221221
*/
222-
public fun userDrivenScrollEnded(viewTag: Int): Unit {
222+
public fun userDrivenScrollEnded(viewTag: Int) {
223223
// ask to the Node Manager for all the native nodes listening to OnScroll event
224224
val nodeManager = nodesManagerRef.get() ?: return
225225

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

Lines changed: 21 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ public class NativeAnimatedNodesManager(
7272
*
7373
* @param uiManagerType
7474
*/
75-
public fun initializeEventListenerForUIManagerType(@UIManagerType uiManagerType: Int): Unit {
75+
public fun initializeEventListenerForUIManagerType(@UIManagerType uiManagerType: Int) {
7676
val isEventListenerInitialized =
7777
when (uiManagerType) {
7878
UIManagerType.FABRIC -> eventListenerInitializedForFabric
@@ -100,7 +100,7 @@ public class NativeAnimatedNodesManager(
100100
public fun hasActiveAnimations(): Boolean = activeAnimations.size() > 0 || updatedNodes.size() > 0
101101

102102
@UiThread
103-
public fun createAnimatedNode(tag: Int, config: ReadableMap): Unit {
103+
public fun createAnimatedNode(tag: Int, config: ReadableMap) {
104104
if (animatedNodes.get(tag) != null) {
105105
throw JSApplicationIllegalArgumentException(
106106
"createAnimatedNode: Animated node [$tag] already exists")
@@ -129,7 +129,7 @@ public class NativeAnimatedNodesManager(
129129
}
130130

131131
@UiThread
132-
public fun updateAnimatedNodeConfig(tag: Int, config: ReadableMap?): Unit {
132+
public fun updateAnimatedNodeConfig(tag: Int, config: ReadableMap?) {
133133
val node =
134134
animatedNodes.get(tag)
135135
?: throw JSApplicationIllegalArgumentException(
@@ -143,16 +143,13 @@ public class NativeAnimatedNodesManager(
143143
}
144144

145145
@UiThread
146-
public fun dropAnimatedNode(tag: Int): Unit {
146+
public fun dropAnimatedNode(tag: Int) {
147147
animatedNodes.remove(tag)
148148
updatedNodes.remove(tag)
149149
}
150150

151151
@UiThread
152-
public fun startListeningToAnimatedNodeValue(
153-
tag: Int,
154-
listener: AnimatedNodeValueListener?
155-
): Unit {
152+
public fun startListeningToAnimatedNodeValue(tag: Int, listener: AnimatedNodeValueListener?) {
156153
val node = animatedNodes[tag]
157154
if (node == null || node !is ValueAnimatedNode) {
158155
throw JSApplicationIllegalArgumentException(
@@ -162,7 +159,7 @@ public class NativeAnimatedNodesManager(
162159
}
163160

164161
@UiThread
165-
public fun stopListeningToAnimatedNodeValue(tag: Int): Unit {
162+
public fun stopListeningToAnimatedNodeValue(tag: Int) {
166163
val node = animatedNodes.get(tag)
167164
if (node == null || node !is ValueAnimatedNode) {
168165
throw JSApplicationIllegalArgumentException(
@@ -172,7 +169,7 @@ public class NativeAnimatedNodesManager(
172169
}
173170

174171
@UiThread
175-
public fun setAnimatedNodeValue(tag: Int, value: Double): Unit {
172+
public fun setAnimatedNodeValue(tag: Int, value: Double) {
176173
val node = animatedNodes.get(tag)
177174
if (node == null || node !is ValueAnimatedNode) {
178175
throw JSApplicationIllegalArgumentException(
@@ -184,7 +181,7 @@ public class NativeAnimatedNodesManager(
184181
}
185182

186183
@UiThread
187-
public fun setAnimatedNodeOffset(tag: Int, offset: Double): Unit {
184+
public fun setAnimatedNodeOffset(tag: Int, offset: Double) {
188185
val node = animatedNodes.get(tag)
189186
if (node == null || node !is ValueAnimatedNode) {
190187
throw JSApplicationIllegalArgumentException(
@@ -195,7 +192,7 @@ public class NativeAnimatedNodesManager(
195192
}
196193

197194
@UiThread
198-
public fun flattenAnimatedNodeOffset(tag: Int): Unit {
195+
public fun flattenAnimatedNodeOffset(tag: Int) {
199196
val node = animatedNodes.get(tag)
200197
if (node == null || node !is ValueAnimatedNode) {
201198
throw JSApplicationIllegalArgumentException(
@@ -205,7 +202,7 @@ public class NativeAnimatedNodesManager(
205202
}
206203

207204
@UiThread
208-
public fun extractAnimatedNodeOffset(tag: Int): Unit {
205+
public fun extractAnimatedNodeOffset(tag: Int) {
209206
val node = animatedNodes.get(tag)
210207
if (node == null || node !is ValueAnimatedNode) {
211208
throw JSApplicationIllegalArgumentException(
@@ -220,7 +217,7 @@ public class NativeAnimatedNodesManager(
220217
animatedNodeTag: Int,
221218
animationConfig: ReadableMap,
222219
endCallback: Callback?
223-
): Unit {
220+
) {
224221
val node =
225222
animatedNodes.get(animatedNodeTag)
226223
?: throw JSApplicationIllegalArgumentException(
@@ -298,7 +295,7 @@ public class NativeAnimatedNodesManager(
298295
}
299296

300297
@UiThread
301-
public fun stopAnimation(animationId: Int): Unit {
298+
public fun stopAnimation(animationId: Int) {
302299
// in most of the cases there should never be more than a few active animations running at the
303300
// same time. Therefore it does not make much sense to create an animationId -> animation
304301
// object map that would require additional memory just to support the use-case of stopping
@@ -342,7 +339,7 @@ public class NativeAnimatedNodesManager(
342339
}
343340

344341
@UiThread
345-
public fun connectAnimatedNodes(parentNodeTag: Int, childNodeTag: Int): Unit {
342+
public fun connectAnimatedNodes(parentNodeTag: Int, childNodeTag: Int) {
346343
val parentNode =
347344
animatedNodes.get(parentNodeTag)
348345
?: throw JSApplicationIllegalArgumentException(
@@ -355,7 +352,7 @@ public class NativeAnimatedNodesManager(
355352
updatedNodes.put(childNodeTag, childNode)
356353
}
357354

358-
public fun disconnectAnimatedNodes(parentNodeTag: Int, childNodeTag: Int): Unit {
355+
public fun disconnectAnimatedNodes(parentNodeTag: Int, childNodeTag: Int) {
359356
val parentNode =
360357
animatedNodes.get(parentNodeTag)
361358
?: throw JSApplicationIllegalArgumentException(
@@ -369,7 +366,7 @@ public class NativeAnimatedNodesManager(
369366
}
370367

371368
@UiThread
372-
public fun connectAnimatedNodeToView(animatedNodeTag: Int, viewTag: Int): Unit {
369+
public fun connectAnimatedNodeToView(animatedNodeTag: Int, viewTag: Int) {
373370
val node =
374371
animatedNodes.get(animatedNodeTag)
375372
?: throw JSApplicationIllegalArgumentException(
@@ -396,7 +393,7 @@ public class NativeAnimatedNodesManager(
396393
}
397394

398395
@UiThread
399-
public fun disconnectAnimatedNodeFromView(animatedNodeTag: Int, viewTag: Int): Unit {
396+
public fun disconnectAnimatedNodeFromView(animatedNodeTag: Int, viewTag: Int) {
400397
val node =
401398
animatedNodes.get(animatedNodeTag)
402399
?: throw JSApplicationIllegalArgumentException(
@@ -409,7 +406,7 @@ public class NativeAnimatedNodesManager(
409406
}
410407

411408
@UiThread
412-
public fun getValue(tag: Int, callback: Callback?): Unit {
409+
public fun getValue(tag: Int, callback: Callback?) {
413410
val node = animatedNodes.get(tag)
414411
if (node == null || node !is ValueAnimatedNode) {
415412
throw JSApplicationIllegalArgumentException(
@@ -436,7 +433,7 @@ public class NativeAnimatedNodesManager(
436433
}
437434

438435
@UiThread
439-
public fun restoreDefaultValues(animatedNodeTag: Int): Unit {
436+
public fun restoreDefaultValues(animatedNodeTag: Int) {
440437
val node = animatedNodes.get(animatedNodeTag) ?: return
441438
// Restoring default values needs to happen before UIManager operations so it is
442439
// possible the node hasn't been created yet if it is being connected and
@@ -454,7 +451,7 @@ public class NativeAnimatedNodesManager(
454451
viewTag: Int,
455452
eventHandlerName: String,
456453
eventMapping: ReadableMap
457-
): Unit {
454+
) {
458455
val nodeTag = eventMapping.getInt("animatedValueTag")
459456
val node =
460457
animatedNodes.get(nodeTag)
@@ -487,7 +484,7 @@ public class NativeAnimatedNodesManager(
487484
viewTag: Int,
488485
eventHandlerName: String,
489486
animatedValueTag: Int
490-
): Unit {
487+
) {
491488
val eventName = normalizeEventName(eventHandlerName)
492489

493490
eventDrivers
@@ -550,7 +547,7 @@ public class NativeAnimatedNodesManager(
550547
* have already been visited.
551548
*/
552549
@UiThread
553-
public fun runUpdates(frameTimeNanos: Long): Unit {
550+
public fun runUpdates(frameTimeNanos: Long) {
554551
UiThreadUtil.assertOnUiThread()
555552
var hasFinishedAnimations = false
556553

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,21 +27,21 @@ internal open class ValueAnimatedNode(config: ReadableMap? = null) : AnimatedNod
2727

2828
open fun getAnimatedObject(): Any? = null
2929

30-
fun flattenOffset(): Unit {
30+
fun flattenOffset() {
3131
nodeValue += offset
3232
offset = 0.0
3333
}
3434

35-
fun extractOffset(): Unit {
35+
fun extractOffset() {
3636
offset += nodeValue
3737
nodeValue = 0.0
3838
}
3939

40-
fun onValueUpdate(): Unit {
40+
fun onValueUpdate() {
4141
valueListener?.onValueUpdate(getValue() - offset, offset)
4242
}
4343

44-
fun setValueListener(listener: AnimatedNodeValueListener?): Unit {
44+
fun setValueListener(listener: AnimatedNodeValueListener?) {
4545
valueListener = listener
4646
}
4747

packages/react-native/ReactAndroid/src/main/java/com/facebook/react/bridge/Dynamic.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,5 +28,5 @@ public interface Dynamic {
2828

2929
public fun asString(): String?
3030

31-
public fun recycle(): Unit
31+
public fun recycle()
3232
}

packages/react-native/ReactAndroid/src/main/java/com/facebook/react/bridge/ReactMarker.kt

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ public object ReactMarker {
7878
instanceKey: Int,
7979
timestamp: Long,
8080
counter: Int
81-
): Unit {
81+
) {
8282
for (listener in fabricMarkerListeners) {
8383
listener.logFabricMarker(name, tag, instanceKey, timestamp, counter)
8484
}
@@ -145,12 +145,7 @@ public object ReactMarker {
145145
@JvmStatic
146146
@DoNotStrip
147147
@AnyThread
148-
public fun logMarker(
149-
name: ReactMarkerConstants,
150-
tag: String?,
151-
instanceKey: Int,
152-
time: Long?
153-
): Unit {
148+
public fun logMarker(name: ReactMarkerConstants, tag: String?, instanceKey: Int, time: Long?) {
154149
logFabricMarker(name, tag, instanceKey)
155150
for (listener in listeners) {
156151
listener.logMarker(name, tag, instanceKey)
@@ -161,7 +156,7 @@ public object ReactMarker {
161156

162157
@JvmStatic
163158
@DoNotStrip
164-
private fun notifyNativeMarker(name: ReactMarkerConstants, time: Long?): Unit {
159+
private fun notifyNativeMarker(name: ReactMarkerConstants, time: Long?) {
165160
if (!name.hasMatchingNameMarker) {
166161
return
167162
}
@@ -199,7 +194,7 @@ public object ReactMarker {
199194
tag: String?,
200195
instanceKey: Int,
201196
timestamp: Long
202-
): Unit
197+
)
203198

204199
public fun logFabricMarker(
205200
name: ReactMarkerConstants,

0 commit comments

Comments
 (0)