Skip to content

Commit d340e52

Browse files
AlvaroBreyJZDesign
authored andcommitted
Fix detekt violations in web_view components
1 parent bd81d42 commit d340e52

5 files changed

Lines changed: 14 additions & 10 deletions

File tree

purchases/src/main/kotlin/com/revenuecat/purchases/paywalls/components/WebViewComponent.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import com.revenuecat.purchases.InternalRevenueCatAPI
55
import com.revenuecat.purchases.paywalls.components.properties.Size
66
import com.revenuecat.purchases.paywalls.components.properties.SizeConstraint
77
import com.revenuecat.purchases.paywalls.components.properties.SizeConstraint.Fill
8-
import com.revenuecat.purchases.paywalls.components.StackComponent
98
import dev.drewhamilton.poko.Poko
109
import kotlinx.serialization.SerialName
1110
import kotlinx.serialization.Serializable

ui/revenuecatui/src/main/kotlin/com/revenuecat/purchases/ui/revenuecatui/components/webview/WebViewComponentView.kt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@ import androidx.compose.runtime.setValue
2020
import androidx.compose.ui.Modifier
2121
import androidx.compose.ui.viewinterop.AndroidView
2222
import com.revenuecat.purchases.paywalls.components.properties.Size
23-
import com.revenuecat.purchases.paywalls.components.properties.SizeConstraint
24-
import com.revenuecat.purchases.paywalls.components.properties.SizeConstraint.Fill
2523
import com.revenuecat.purchases.paywalls.components.properties.SizeConstraint.Fit
2624
import com.revenuecat.purchases.paywalls.components.properties.SizeConstraint.Fixed
2725
import com.revenuecat.purchases.ui.revenuecatui.components.PaywallAction
@@ -34,7 +32,7 @@ import java.net.URL
3432

3533
@JvmSynthetic
3634
@Composable
37-
@Suppress("LongMethod")
35+
@Suppress("LongMethod", "ReturnCount")
3836
internal fun WebViewComponentView(
3937
style: WebViewComponentStyle,
4038
state: PaywallState.Loaded.Components,

ui/revenuecatui/src/main/kotlin/com/revenuecat/purchases/ui/revenuecatui/components/webview/WebViewEnvelope.kt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ internal object WebViewEnvelope {
3636
KIND_ERROR,
3737
)
3838

39-
data class Parsed(
39+
internal data class Parsed(
4040
val kind: String,
4141
val protocolVersion: Int,
4242
val componentId: String,
@@ -46,7 +46,7 @@ internal object WebViewEnvelope {
4646
val error: String?,
4747
)
4848

49-
@Suppress("ReturnCount")
49+
@Suppress("ReturnCount", "CyclomaticComplexMethod")
5050
fun parse(rawJson: String): Parsed? {
5151
val json = try {
5252
JSONObject(rawJson)
@@ -90,6 +90,7 @@ internal object WebViewEnvelope {
9090
)
9191
}
9292

93+
@Suppress("LongParameterList")
9394
fun build(
9495
kind: String,
9596
protocolVersion: Int,

ui/revenuecatui/src/main/kotlin/com/revenuecat/purchases/ui/revenuecatui/components/webview/WebViewJavaScriptBridge.kt

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,10 @@ internal class WebViewJavaScriptBridge(
114114
val webView = webViewRef.get() ?: return
115115

116116
if (json.toByteArray(Charsets.UTF_8).size > WebViewMessageParser.MAX_PAYLOAD_BYTES) {
117-
Logger.w("Dropping inbound web view message: payload exceeds ${WebViewMessageParser.MAX_PAYLOAD_BYTES} bytes.")
117+
Logger.w(
118+
"Dropping inbound web view message: payload exceeds " +
119+
"${WebViewMessageParser.MAX_PAYLOAD_BYTES} bytes.",
120+
)
118121
return
119122
}
120123

@@ -127,7 +130,8 @@ internal class WebViewJavaScriptBridge(
127130
WebViewEnvelope.KIND_CONNECT -> {
128131
if (!isOriginTrusted(webView, allowBeforeNavigation = true)) {
129132
Logger.w(
130-
"Dropping inbound web view connect: current origin does not match the resolved component origin.",
133+
"Dropping inbound web view connect: current origin does not match the " +
134+
"resolved component origin.",
131135
)
132136
return
133137
}
@@ -138,7 +142,8 @@ internal class WebViewJavaScriptBridge(
138142
-> {
139143
if (!isOriginTrusted(webView, allowBeforeNavigation = false)) {
140144
Logger.w(
141-
"Dropping inbound web view message: current origin does not match the resolved component origin.",
145+
"Dropping inbound web view message: current origin does not match the " +
146+
"resolved component origin.",
142147
)
143148
return
144149
}
@@ -194,6 +199,7 @@ internal class WebViewJavaScriptBridge(
194199
}
195200

196201
@MainThread
202+
@Suppress("ReturnCount")
197203
private fun handleAppFrame(rawJson: String) {
198204
if (!channelOpen) return
199205

ui/revenuecatui/src/main/kotlin/com/revenuecat/purchases/ui/revenuecatui/components/webview/WebViewMessageParser.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ internal object WebViewMessageParser {
2323
const val MAX_PAYLOAD_BYTES: Int = 65_536
2424
const val MAX_NESTING_DEPTH: Int = 16
2525

26-
data class ParsedAppMessage(
26+
internal data class ParsedAppMessage(
2727
val message: PaywallWebViewMessage,
2828
/** Set when the inbound frame is a transport `request` that expects a `response`. */
2929
val requestId: String? = null,

0 commit comments

Comments
 (0)