Skip to content

Commit

Permalink
style(detekt): Accept current use of TooGenericExceptionCaught cases
Browse files Browse the repository at this point in the history
Signed-off-by: Andy Scherzinger <[email protected]>
  • Loading branch information
AndyScherzinger committed Dec 4, 2024
1 parent 171ee26 commit e5af4b5
Show file tree
Hide file tree
Showing 27 changed files with 41 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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>

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

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

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

@Suppress("Detekt.TooGenericExceptionCaught")
fun createRoomAndAddParticipants(
roomType: String,
conversationName: String,
Expand Down Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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 {
Expand All @@ -182,6 +184,7 @@ class ConversationInfoViewModel @Inject constructor(
}
}

@Suppress("Detekt.TooGenericExceptionCaught")
fun setConversationReadOnly(roomToken: String, state: Int) {
viewModelScope.launch {
try {
Expand All @@ -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 {
Expand All @@ -206,6 +210,7 @@ class ConversationInfoViewModel @Inject constructor(
}
}

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

@Suppress("Detekt.TooGenericExceptionCaught")
@SuppressLint("SuspiciousIndentation")
fun setPassword(password: String, token: String) {
viewModelScope.launch {
Expand All @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ class ConversationInfoEditViewModel @Inject constructor(
?.subscribe(DeleteConversationAvatarObserver())
}

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

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

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1130,6 +1130,7 @@ class SettingsActivity :
}
}

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

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

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

@Suppress("Detekt.TooGenericExceptionCaught")
private fun observeTypingStatus() {
lifecycleScope.launch {
var state = appPreferences.typingStatus
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand All @@ -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))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -522,6 +522,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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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))
Expand Down Expand Up @@ -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" -> {
Expand Down
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
Expand Down

0 comments on commit e5af4b5

Please sign in to comment.