Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[stable-20.1] Improve detekt score #4524

Merged
merged 4 commits into from
Dec 6, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
style(detekt): Accept current use of TooGenericExceptionCaught cases
Signed-off-by: Andy Scherzinger <info@andy-scherzinger.de>
AndyScherzinger authored and backportbot[bot] committed Dec 6, 2024
commit a0d00857e56e987353eb31ddc8cff3d87f2683f5
Original file line number Diff line number Diff line change
@@ -745,6 +745,7 @@ class CallActivity : CallBaseActivity() {
binding!!.endCallPopupMenu.text = context.getString(R.string.leave_call)
}

@Suppress("Detekt.TooGenericExceptionCaught")
private fun createCameraEnumerator() {
var camera2EnumeratorIsSupported = false
try {
Original file line number Diff line number Diff line change
@@ -180,6 +180,7 @@ class IncomingDeckCardViewHolder(incomingView: View, payload: Any) : MessageHold
viewThemeUtils.talk.themeIncomingMessageBubble(bubble, message.isGrouped, message.isDeleted)
}

@Suppress("Detekt.TooGenericExceptionCaught")
private fun setParentMessageDataOnMessageItem(message: ChatMessage) {
if (message.parentMessageId != null && !message.isDeleted) {
CoroutineScope(Dispatchers.Main).launch {
Original file line number Diff line number Diff line change
@@ -158,6 +158,7 @@ class IncomingLinkPreviewMessageViewHolder(incomingView: View, payload: Any) :
viewThemeUtils.talk.themeIncomingMessageBubble(bubble, message.isGrouped, message.isDeleted)
}

@Suppress("Detekt.TooGenericExceptionCaught")
private fun setParentMessageDataOnMessageItem(message: ChatMessage) {
if (message.parentMessageId != null && !message.isDeleted) {
CoroutineScope(Dispatchers.Main).launch {
Original file line number Diff line number Diff line change
@@ -143,6 +143,7 @@ class IncomingLocationMessageViewHolder(incomingView: View, payload: Any) :
viewThemeUtils.talk.themeIncomingMessageBubble(bubble, message.isGrouped, message.isDeleted)
}

@Suppress("Detekt.TooGenericExceptionCaught")
private fun setParentMessageDataOnMessageItem(message: ChatMessage) {
if (message.parentMessageId != null && !message.isDeleted) {
CoroutineScope(Dispatchers.Main).launch {
Original file line number Diff line number Diff line change
@@ -165,6 +165,7 @@ class IncomingPollMessageViewHolder(incomingView: View, payload: Any) :
viewThemeUtils.talk.themeIncomingMessageBubble(bubble, message.isGrouped, message.isDeleted)
}

@Suppress("Detekt.TooGenericExceptionCaught")
private fun setParentMessageDataOnMessageItem(message: ChatMessage) {
if (message.parentMessageId != null && !message.isDeleted) {
CoroutineScope(Dispatchers.Main).launch {
Original file line number Diff line number Diff line change
@@ -165,6 +165,7 @@ class IncomingTextMessageViewHolder(itemView: View, payload: Any) :
viewThemeUtils.talk.themeIncomingMessageBubble(bubble, message.isGrouped, message.isDeleted)
}

@Suppress("Detekt.TooGenericExceptionCaught")
private fun processParentMessage(message: ChatMessage) {
if (message.parentMessageId != null && !message.isDeleted) {
CoroutineScope(Dispatchers.Main).launch {
Original file line number Diff line number Diff line change
@@ -261,6 +261,7 @@ class IncomingVoiceMessageViewHolder(incomingView: View, payload: Any) :
viewThemeUtils.talk.themeIncomingMessageBubble(bubble, message.isGrouped, message.isDeleted)
}

@Suppress("Detekt.TooGenericExceptionCaught")
private fun setParentMessageDataOnMessageItem(message: ChatMessage) {
if (message.parentMessageId != null && !message.isDeleted) {
CoroutineScope(Dispatchers.Main).launch {
Original file line number Diff line number Diff line change
@@ -171,6 +171,7 @@ class OutcomingDeckCardViewHolder(
commonMessageInterface.onClickReaction(chatMessage, emoji)
}

@Suppress("Detekt.TooGenericExceptionCaught")
private fun setParentMessageDataOnMessageItem(message: ChatMessage) {
if (message.parentMessageId != null && !message.isDeleted) {
CoroutineScope(Dispatchers.Main).launch {
Original file line number Diff line number Diff line change
@@ -146,6 +146,7 @@ class OutcomingLinkPreviewMessageViewHolder(outcomingView: View, payload: Any) :
commonMessageInterface.onClickReaction(chatMessage, emoji)
}

@Suppress("Detekt.TooGenericExceptionCaught")
private fun setParentMessageDataOnMessageItem(message: ChatMessage) {
if (message.parentMessageId != null && !message.isDeleted) {
CoroutineScope(Dispatchers.Main).launch {
Original file line number Diff line number Diff line change
@@ -198,6 +198,7 @@ class OutcomingLocationMessageViewHolder(incomingView: View) :
})
}

@Suppress("Detekt.TooGenericExceptionCaught")
private fun setParentMessageDataOnMessageItem(message: ChatMessage) {
if (message.parentMessageId != null && !message.isDeleted) {
CoroutineScope(Dispatchers.Main).launch {
Original file line number Diff line number Diff line change
@@ -158,6 +158,7 @@ class OutcomingPollMessageViewHolder(outcomingView: View, payload: Any) :
}
}

@Suppress("Detekt.TooGenericExceptionCaught")
private fun setParentMessageDataOnMessageItem(message: ChatMessage) {
if (message.parentMessageId != null && !message.isDeleted) {
CoroutineScope(Dispatchers.Main).launch {
Original file line number Diff line number Diff line change
@@ -157,6 +157,7 @@ class OutcomingTextMessageViewHolder(itemView: View) :
commonMessageInterface.onClickReaction(chatMessage, emoji)
}

@Suppress("Detekt.TooGenericExceptionCaught")
private fun processParentMessage(message: ChatMessage) {
if (message.parentMessageId != null && !message.isDeleted) {
CoroutineScope(Dispatchers.Main).launch {
Original file line number Diff line number Diff line change
@@ -274,6 +274,7 @@ class OutcomingVoiceMessageViewHolder(outcomingView: View) :
binding.progressBar.visibility = View.VISIBLE
}

@Suppress("Detekt.TooGenericExceptionCaught")
private fun setParentMessageDataOnMessageItem(message: ChatMessage) {
if (message.parentMessageId != null && !message.isDeleted) {
CoroutineScope(Dispatchers.Main).launch {
Original file line number Diff line number Diff line change
@@ -112,6 +112,7 @@ class TemporaryMessageViewHolder(outgoingView: View, payload: Any) :
ViewCompat.setBackground(bubble, bubbleDrawable)
}

@Suppress("Detekt.TooGenericExceptionCaught")
private fun processParentMessage(message: ChatMessage) {
if (message.parentMessageId != null && !message.isDeleted) {
CoroutineScope(Dispatchers.Main).launch {
Original file line number Diff line number Diff line change
@@ -399,7 +399,7 @@ class OfflineFirstChatRepository @Inject constructor(
.map(ChatMessageEntity::asModel)
}

@Suppress("UNCHECKED_CAST", "MagicNumber")
@Suppress("UNCHECKED_CAST", "MagicNumber", "Detekt.TooGenericExceptionCaught")
private fun getMessagesFromServer(bundle: Bundle): Pair<Int, List<ChatMessageJson>>? {
val fieldMap = bundle.getSerializable(BundleKeys.KEY_FIELD_MAP) as HashMap<String, Int>

Original file line number Diff line number Diff line change
@@ -69,6 +69,7 @@ class ContactsViewModel @Inject constructor(
_isAddParticipantsView.value = value
}

@Suppress("Detekt.TooGenericExceptionCaught")
fun getContactsFromSearchParams() {
_contactsViewState.value = ContactsUiState.Loading
viewModelScope.launch {
@@ -84,6 +85,8 @@ class ContactsViewModel @Inject constructor(
}
}
}

@Suppress("Detekt.TooGenericExceptionCaught")
fun createRoom(roomType: String, sourceType: String, userId: String, conversationName: String?) {
viewModelScope.launch {
try {
Original file line number Diff line number Diff line change
@@ -75,6 +75,7 @@ class ConversationCreationViewModel @Inject constructor(
_conversationDescription.value = conversationDescription
}

@Suppress("Detekt.TooGenericExceptionCaught")
fun createRoomAndAddParticipants(
roomType: String,
conversationName: String,
@@ -142,6 +143,7 @@ class ConversationCreationViewModel @Inject constructor(
return repository.getImageUri(avatarId, requestBigSize)
}

@Suppress("Detekt.TooGenericExceptionCaught")
fun createRoom(roomType: String, conversationName: String?) {
viewModelScope.launch {
try {
Original file line number Diff line number Diff line change
@@ -150,6 +150,7 @@ class ConversationInfoViewModel @Inject constructor(
}
}

@Suppress("Detekt.TooGenericExceptionCaught")
fun listBans(user: User, token: String) {
val url = ApiUtils.getUrlForBans(user.baseUrl!!, token)
viewModelScope.launch {
@@ -163,6 +164,7 @@ class ConversationInfoViewModel @Inject constructor(
}
}

@Suppress("Detekt.TooGenericExceptionCaught")
fun banActor(user: User, token: String, actorType: String, actorId: String, internalNote: String) {
val url = ApiUtils.getUrlForBans(user.baseUrl!!, token)
viewModelScope.launch {
@@ -182,6 +184,7 @@ class ConversationInfoViewModel @Inject constructor(
}
}

@Suppress("Detekt.TooGenericExceptionCaught")
fun setConversationReadOnly(roomToken: String, state: Int) {
viewModelScope.launch {
try {
@@ -193,6 +196,7 @@ class ConversationInfoViewModel @Inject constructor(
}
}

@Suppress("Detekt.TooGenericExceptionCaught")
fun unbanActor(user: User, token: String, banId: Int) {
val url = ApiUtils.getUrlForUnban(user.baseUrl!!, token, banId)
viewModelScope.launch {
@@ -206,6 +210,7 @@ class ConversationInfoViewModel @Inject constructor(
}
}

@Suppress("Detekt.TooGenericExceptionCaught")
fun allowGuests(token: String, allow: Boolean) {
viewModelScope.launch {
try {
@@ -217,6 +222,7 @@ class ConversationInfoViewModel @Inject constructor(
}
}

@Suppress("Detekt.TooGenericExceptionCaught")
@SuppressLint("SuspiciousIndentation")
fun setPassword(password: String, token: String) {
viewModelScope.launch {
@@ -241,6 +247,7 @@ class ConversationInfoViewModel @Inject constructor(
conversationsRepository.unarchiveConversation(user.getCredentials(), url)
}

@Suppress("Detekt.TooGenericExceptionCaught")
fun clearChatHistory(apiVersion: Int, roomToken: String) {
viewModelScope.launch {
try {
Original file line number Diff line number Diff line change
@@ -75,6 +75,7 @@ class ConversationInfoEditViewModel @Inject constructor(
?.subscribe(DeleteConversationAvatarObserver())
}

@Suppress("Detekt.TooGenericExceptionCaught")
fun renameRoom(roomToken: String, newRoomName: String) {
viewModelScope.launch {
try {
@@ -86,6 +87,7 @@ class ConversationInfoEditViewModel @Inject constructor(
}
}

@Suppress("Detekt.TooGenericExceptionCaught")
fun setConversationDescription(roomToken: String, conversationDescription: String?) {
viewModelScope.launch {
try {
Original file line number Diff line number Diff line change
@@ -102,6 +102,7 @@ class OfflineFirstConversationsRepository @Inject constructor(
}
}

@Suppress("Detekt.TooGenericExceptionCaught")
private suspend fun getRoomsFromServer(): List<ConversationEntity>? {
var conversationsFromSync: List<ConversationEntity>? = null

Original file line number Diff line number Diff line change
@@ -13,6 +13,7 @@ import com.bluelinelabs.logansquare.LoganSquare

class ArrayListConverter {

@Suppress("Detekt.TooGenericExceptionCaught")
@TypeConverter
fun arrayListToString(list: ArrayList<String>?): String? {
return if (list == null) {
Original file line number Diff line number Diff line change
@@ -36,6 +36,7 @@ import java.net.URLConnection
class SaveFileToStorageWorker(val context: Context, workerParameters: WorkerParameters) :
Worker(context, workerParameters) {

@Suppress("Detekt.TooGenericExceptionCaught")
override fun doWork(): Result {
try {
val sourceFilePath = inputData.getString(KEY_SOURCE_FILE_PATH)
Original file line number Diff line number Diff line change
@@ -1130,6 +1130,7 @@ class SettingsActivity :
}
}

@Suppress("Detekt.TooGenericExceptionCaught")
override fun onRequestPermissionsResult(requestCode: Int, permissions: Array<String>, grantResults: IntArray) {
super.onRequestPermissionsResult(requestCode, permissions, grantResults)

@@ -1349,6 +1350,7 @@ class SettingsActivity :
})
}

@Suppress("Detekt.TooGenericExceptionCaught")
private fun observeReadPrivacy() {
lifecycleScope.launch {
var state = appPreferences.readPrivacy
@@ -1384,6 +1386,7 @@ class SettingsActivity :
}
}

@Suppress("Detekt.TooGenericExceptionCaught")
private fun observeTypingStatus() {
lifecycleScope.launch {
var state = appPreferences.typingStatus
Original file line number Diff line number Diff line change
@@ -202,6 +202,7 @@ class ConversationsListBottomDialog(
}
}

@Suppress("Detekt.TooGenericExceptionCaught")
@SuppressLint("StringFormatInvalid", "TooGenericExceptionCaught")
private fun addConversationToFavorites() {
val apiVersion = ApiUtils.getConversationApiVersion(currentUser, intArrayOf(ApiUtils.API_V4, ApiUtils.API_V1))
@@ -228,6 +229,7 @@ class ConversationsListBottomDialog(
}
}

@Suppress("Detekt.TooGenericExceptionCaught")
@SuppressLint("StringFormatInvalid", "TooGenericExceptionCaught")
private fun removeConversationFromFavorites() {
val apiVersion = ApiUtils.getConversationApiVersion(currentUser, intArrayOf(ApiUtils.API_V4, ApiUtils.API_V1))
Original file line number Diff line number Diff line change
@@ -517,6 +517,7 @@ class AppPreferencesImpl(val context: Context) : AppPreferences {
}
}

@Suppress("Detekt.TooGenericExceptionCaught")
override fun getMessageQueue(internalConversationId: String): MutableList<MessageInputViewModel.QueuedMessage> {
val queueStr =
runBlocking { async { readString(internalConversationId + MESSAGE_QUEUE).first() } }.getCompleted()
Original file line number Diff line number Diff line change
@@ -8,7 +8,6 @@
*/
package com.nextcloud.talk.utils.preferences.preferencestorage

import android.annotation.SuppressLint
import android.text.TextUtils
import android.util.Log
import autodagger.AutoInjector
@@ -64,7 +63,7 @@ class DatabaseStorageModule(conversationUser: User, conversationToken: String) {
this.conversationToken = conversationToken
}

@SuppressLint("TooGenericExceptionCaught")
@Suppress("Detekt.TooGenericExceptionCaught")
suspend fun saveBoolean(key: String, value: Boolean) {
if ("call_notifications_switch" == key) {
val apiVersion = getConversationApiVersion(conversationUser, intArrayOf(ApiUtils.API_V4))
@@ -92,7 +91,7 @@ class DatabaseStorageModule(conversationUser: User, conversationToken: String) {
}
}

@SuppressLint("TooGenericExceptionCaught")
@Suppress("Detekt.TooGenericExceptionCaught")
suspend fun saveString(key: String, value: String) {
when (key) {
"conversation_settings_dropdown" -> {
2 changes: 1 addition & 1 deletion detekt.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# SPDX-FileCopyrightText: 2017-2024 Nextcloud GmbH and Nextcloud contributors
# SPDX-License-Identifier: GPL-3.0-or-later
build:
maxIssues: 167
maxIssues: 125
weights:
# complexity: 2
# LongParameterList: 1