From 31dcb2c5dd6a0546209f74dab49f5282f0a5bda4 Mon Sep 17 00:00:00 2001 From: pacien Date: Tue, 8 Sep 2020 20:21:26 +0200 Subject: treewide: fix trivial null assertion warnings --- .../activities/common/FragmentListPagerAdapter.kt | 4 ++-- .../tools/ConfigurationToolDialogFragment.kt | 6 +++--- .../VpnInterfaceConfigurationFormatter.kt | 4 ++-- .../tincapp/activities/status/nodes/NodeInfo.kt | 22 +++++++++++----------- .../java/org/pacien/tincapp/commands/TincApp.kt | 7 ++++--- 5 files changed, 22 insertions(+), 21 deletions(-) (limited to 'app/src/main/java/org/pacien') diff --git a/app/src/main/java/org/pacien/tincapp/activities/common/FragmentListPagerAdapter.kt b/app/src/main/java/org/pacien/tincapp/activities/common/FragmentListPagerAdapter.kt index 7603fa7..3c17afd 100644 --- a/app/src/main/java/org/pacien/tincapp/activities/common/FragmentListPagerAdapter.kt +++ b/app/src/main/java/org/pacien/tincapp/activities/common/FragmentListPagerAdapter.kt @@ -1,6 +1,6 @@ /* * Tinc App, an Android binding and user interface for the tinc mesh VPN daemon - * Copyright (C) 2017-2019 Pacien TRAN-GIRARD + * Copyright (C) 2017-2020 Pacien TRAN-GIRARD * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -32,7 +32,7 @@ class FragmentListPagerAdapter(private val pages: List>, private val resources by lazy { App.getResources() } - override fun getPageTitle(position: Int) = resources.getString(pages[position].first)!! + override fun getPageTitle(position: Int) = resources.getString(pages[position].first) override fun getItem(position: Int) = pages[position].second override fun getCount() = pages.size } diff --git a/app/src/main/java/org/pacien/tincapp/activities/configure/tools/ConfigurationToolDialogFragment.kt b/app/src/main/java/org/pacien/tincapp/activities/configure/tools/ConfigurationToolDialogFragment.kt index cfb365c..d95a1f7 100644 --- a/app/src/main/java/org/pacien/tincapp/activities/configure/tools/ConfigurationToolDialogFragment.kt +++ b/app/src/main/java/org/pacien/tincapp/activities/configure/tools/ConfigurationToolDialogFragment.kt @@ -1,6 +1,6 @@ /* * Tinc App, an Android binding and user interface for the tinc mesh VPN daemon - * Copyright (C) 2017-2019 Pacien TRAN-GIRARD + * Copyright (C) 2017-2020 Pacien TRAN-GIRARD * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -33,7 +33,7 @@ import java.util.regex.Pattern * @author pacien */ abstract class ConfigurationToolDialogFragment : BaseDialogFragment() { - private val networkNamePattern by lazy { Pattern.compile("^[^\\x00/]*$")!! } + private val networkNamePattern by lazy { Pattern.compile("^[^\\x00/]*$") } protected fun makeDialog(@LayoutRes layout: Int, @StringRes title: Int, @StringRes applyButton: Int, applyAction: (View) -> Unit) = makeDialog(inflate(layout), title, applyButton, applyAction) @@ -51,7 +51,7 @@ abstract class ConfigurationToolDialogFragment : BaseDialogFragment() { action .whenComplete { _, _ -> progressDialog.dismiss() } .thenAccept { parentActivity.notify(R.string.configure_tools_message_network_configuration_written) } - .exceptionallyAccept { parentActivity.runOnUiThread { parentActivity.showErrorDialog(it.cause!!.localizedMessage) } } + .exceptionallyAccept { parentActivity.runOnUiThread { parentActivity.showErrorDialog(it.cause!!.localizedMessage!!) } } } } diff --git a/app/src/main/java/org/pacien/tincapp/activities/status/networkinfo/VpnInterfaceConfigurationFormatter.kt b/app/src/main/java/org/pacien/tincapp/activities/status/networkinfo/VpnInterfaceConfigurationFormatter.kt index 2956cb4..dcab449 100644 --- a/app/src/main/java/org/pacien/tincapp/activities/status/networkinfo/VpnInterfaceConfigurationFormatter.kt +++ b/app/src/main/java/org/pacien/tincapp/activities/status/networkinfo/VpnInterfaceConfigurationFormatter.kt @@ -1,6 +1,6 @@ /* * Tinc App, an Android binding and user interface for the tinc mesh VPN daemon - * Copyright (C) 2017-2018 Pacien TRAN-GIRARD + * Copyright (C) 2017-2020 Pacien TRAN-GIRARD * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -30,7 +30,7 @@ object VpnInterfaceConfigurationFormatter { fun formatList(list: List?) = when { list != null && list.isNotEmpty() -> list.joinToString("\n", transform = this::formatListElement) - else -> resources.getString(R.string.status_network_info_value_none)!! + else -> resources.getString(R.string.status_network_info_value_none) } private fun formatListElement(element: Any) = when (element) { diff --git a/app/src/main/java/org/pacien/tincapp/activities/status/nodes/NodeInfo.kt b/app/src/main/java/org/pacien/tincapp/activities/status/nodes/NodeInfo.kt index 06725dc..6523250 100644 --- a/app/src/main/java/org/pacien/tincapp/activities/status/nodes/NodeInfo.kt +++ b/app/src/main/java/org/pacien/tincapp/activities/status/nodes/NodeInfo.kt @@ -1,6 +1,6 @@ /* * Tinc App, an Android binding and user interface for the tinc mesh VPN daemon - * Copyright (C) 2017-2018 Pacien TRAN-GIRARD + * Copyright (C) 2017-2020 Pacien TRAN-GIRARD * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -80,18 +80,18 @@ data class NodeInfo(val name: String, id = matcher[2], ip = matcher[3], port = matcher[4], - cipher = matcher[5].toInt(), - digest = matcher[6].toInt(), - macLength = matcher[7].toInt(), - compression = matcher[8].toInt(), - options = matcher[9].toInt(16), - status = matcher[10].toInt(16), + cipher = matcher[5]!!.toInt(), + digest = matcher[6]!!.toInt(), + macLength = matcher[7]!!.toInt(), + compression = matcher[8]!!.toInt(), + options = matcher[9]!!.toInt(16), + status = matcher[10]!!.toInt(16), nextHop = matcher[11], via = matcher[12], - distance = matcher[13].toInt(), - pMtu = matcher[14].toInt(), - minMtu = matcher[15].toInt(), - maxMtu = matcher[16].toInt() + distance = matcher[13]!!.toInt(), + pMtu = matcher[14]!!.toInt(), + minMtu = matcher[15]!!.toInt(), + maxMtu = matcher[16]!!.toInt() ) private operator fun Matcher.get(index: Int) = group(index) diff --git a/app/src/main/java/org/pacien/tincapp/commands/TincApp.kt b/app/src/main/java/org/pacien/tincapp/commands/TincApp.kt index e7ad8e5..032b20e 100644 --- a/app/src/main/java/org/pacien/tincapp/commands/TincApp.kt +++ b/app/src/main/java/org/pacien/tincapp/commands/TincApp.kt @@ -1,6 +1,6 @@ /* * Tinc App, an Android binding and user interface for the tinc mesh VPN daemon - * Copyright (C) 2017-2018 Pacien TRAN-GIRARD + * Copyright (C) 2017-2020 Pacien TRAN-GIRARD * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -34,8 +34,9 @@ object TincApp { private val SCRIPT_SUFFIXES = listOf("-up", "-down", "-created", "-accepted") private val STATIC_SCRIPTS = listOf("tinc", "host", "subnet", "invitation").flatMap { s -> SCRIPT_SUFFIXES.map { s + it } } - private fun listScripts(netName: String) = AppPaths.confDir(netName).listFiles { f -> f.name in STATIC_SCRIPTS } + - AppPaths.hostsDir(netName).listFiles { f -> SCRIPT_SUFFIXES.any { f.name.endsWith(it) } } + private fun listScripts(netName: String) = + AppPaths.confDir(netName).listFiles { f -> f.name in STATIC_SCRIPTS }!! + + AppPaths.hostsDir(netName).listFiles { f -> SCRIPT_SUFFIXES.any { f.name.endsWith(it) } }!! fun listPrivateKeys(netName: String) = try { TincConfiguration.fromTincConfiguration(AppPaths.existing(AppPaths.tincConfFile(netName))).let { -- cgit v1.2.3