Skip to content

Commit 3df0ac2

Browse files
committed
Remove unnecessary null check
1 parent 2b0d6f1 commit 3df0ac2

File tree

4 files changed

+8
-9
lines changed

4 files changed

+8
-9
lines changed

app/src/androidTest/java/com/duckduckgo/app/browser/BrowserWebViewClientTest.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1342,7 +1342,7 @@ class BrowserWebViewClientTest {
13421342
}
13431343

13441344
override fun register(
1345-
jsMessageCallback: JsMessageCallback?,
1345+
jsMessageCallback: JsMessageCallback,
13461346
webView: WebView,
13471347
) {
13481348
registered = true

content-scope-scripts/content-scope-scripts-impl/src/main/java/com/duckduckgo/contentscopescripts/impl/messaging/WebViewCompatWebCompatMessagingPlugin.kt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,12 +83,11 @@ class WebViewCompatWebCompatMessagingPlugin @Inject constructor(
8383
}
8484

8585
override fun register(
86-
jsMessageCallback: JsMessageCallback?,
86+
jsMessageCallback: JsMessageCallback,
8787
webView: WebView,
8888
) {
8989
coroutineScope.launch {
9090
if (!webViewCompatContentScopeScripts.isEnabled()) return@launch
91-
if (jsMessageCallback == null) throw Exception("Callback cannot be null")
9291

9392
runCatching {
9493
return@runCatching webViewCompatWrapper.addWebMessageListener(

js-messaging/js-messaging-api/src/main/java/com/duckduckgo/js/messaging/api/WebMessagingPlugin.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import android.webkit.WebView
2020

2121
interface WebMessagingPlugin {
2222
fun register(
23-
jsMessageCallback: JsMessageCallback?,
23+
jsMessageCallback: JsMessageCallback,
2424
webView: WebView,
2525
)
2626

lint-rules/src/main/java/com/duckduckgo/lint/WebViewCompatApisUsageDetector.kt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ class WebViewCompatApisUsageDetector : Detector(), SourceCodeScanner {
3434
companion object {
3535
val ISSUE_ADD_WEB_MESSAGE_LISTENER_USAGE: Issue = Issue.create(
3636
id = "AddWebMessageListenerUsage",
37-
briefDescription = "Use safe WebMessageListener methods",
38-
explanation = "Use `safeAddWebMessageListener` instead of `WebViewCompat.addWebMessageListener`",
37+
briefDescription = "Use safe WebViewCompatWrapper methods",
38+
explanation = "Use `WebViewCompatWrapper#addWebMessageListener` instead",
3939
category = Category.CORRECTNESS,
4040
severity = Severity.ERROR,
4141
implementation = Implementation(
@@ -46,8 +46,8 @@ class WebViewCompatApisUsageDetector : Detector(), SourceCodeScanner {
4646

4747
val ISSUE_REMOVE_WEB_MESSAGE_LISTENER_USAGE: Issue = Issue.create(
4848
id = "RemoveWebMessageListenerUsage",
49-
briefDescription = "Use safe WebMessageListener methods",
50-
explanation = "Use `safeRemoveWebMessageListener` instead of `WebViewCompat.removeWebMessageListener`",
49+
briefDescription = "Use safe WebViewCompatWrapper methods",
50+
explanation = "Use `WebViewCompatWrapper#removeWebMessageListener` instead",
5151
category = Category.CORRECTNESS,
5252
severity = Severity.ERROR,
5353
implementation = Implementation(
@@ -59,7 +59,7 @@ class WebViewCompatApisUsageDetector : Detector(), SourceCodeScanner {
5959
val ISSUE_ADD_DOCUMENT_START_JAVASCRIPT_USAGE: Issue = Issue.create(
6060
id = "AddDocumentStartJavaScriptUsage",
6161
briefDescription = "Use safe WebViewCompatWrapper methods",
62-
explanation = "Use `WebViewCompatWrapper#addDocumentStartJavaScript` instead of `WebViewCompat.addDocumentStartJavaScript`",
62+
explanation = "Use `WebViewCompatWrapper#addDocumentStartJavaScript` instead",
6363
category = Category.CORRECTNESS,
6464
severity = Severity.ERROR,
6565
implementation = Implementation(

0 commit comments

Comments
 (0)