From 8d0c6b0ce3c1ab55fb69d06782bfce69ede8b2da Mon Sep 17 00:00:00 2001 From: Andy Scherzinger Date: Fri, 13 Dec 2024 18:23:41 +0100 Subject: [PATCH] style(detekt): Restrict the number of return statements in methods Signed-off-by: Andy Scherzinger --- .../main/java/com/nextcloud/talk/utils/PushUtils.kt | 13 ++++++------- detekt.yml | 2 +- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/app/src/main/java/com/nextcloud/talk/utils/PushUtils.kt b/app/src/main/java/com/nextcloud/talk/utils/PushUtils.kt index 7c48eae98..95e59b214 100644 --- a/app/src/main/java/com/nextcloud/talk/utils/PushUtils.kt +++ b/app/src/main/java/com/nextcloud/talk/utils/PushUtils.kt @@ -117,15 +117,14 @@ class PushUtils { private fun saveKeyToFile(key: Key, path: String): Int { val encoded = key.encoded try { - if (!File(path).exists()) { - if (!File(path).createNewFile()) { - return -1 + return if (!File(path).exists() && !File(path).createNewFile()) { + -1 + } else { + FileOutputStream(path).use { keyFileOutputStream -> + keyFileOutputStream.write(encoded) + 0 } } - FileOutputStream(path).use { keyFileOutputStream -> - keyFileOutputStream.write(encoded) - return 0 - } } catch (e: FileNotFoundException) { Log.d(TAG, "Failed to save key to file") } catch (e: IOException) { diff --git a/detekt.yml b/detekt.yml index feafeb301..7ad14df30 100644 --- a/detekt.yml +++ b/detekt.yml @@ -1,7 +1,7 @@ # SPDX-FileCopyrightText: 2017-2024 Nextcloud GmbH and Nextcloud contributors # SPDX-License-Identifier: GPL-3.0-or-later build: - maxIssues: 83 + maxIssues: 82 weights: # complexity: 2 # LongParameterList: 1