Enable detekt rule ThrowingExceptionsWithoutMessageOrCause and fix existing issues.

This commit is contained in:
Benoit Marty 2023-07-26 10:33:51 +02:00
parent d82b47beeb
commit f055a25457
7 changed files with 9 additions and 9 deletions

View file

@ -41,7 +41,7 @@ open class CreateRoomRootStateProvider : PreviewParameterProvider<CreateRoomRoot
} }
), ),
aCreateRoomRootState().copy( aCreateRoomRootState().copy(
startDmAction = Async.Failure(Throwable()), startDmAction = Async.Failure(Throwable("error")),
userListState = aMatrixUser().let { userListState = aMatrixUser().let {
aUserListState().copy( aUserListState().copy(
searchQuery = it.userId.value, searchQuery = it.userId.value,

View file

@ -25,7 +25,7 @@ open class WaitListStateProvider : PreviewParameterProvider<WaitListState> {
get() = sequenceOf( get() = sequenceOf(
aWaitListState(loginAction = Async.Uninitialized), aWaitListState(loginAction = Async.Uninitialized),
aWaitListState(loginAction = Async.Loading()), aWaitListState(loginAction = Async.Loading()),
aWaitListState(loginAction = Async.Failure(Throwable())), aWaitListState(loginAction = Async.Failure(Throwable("error"))),
aWaitListState(loginAction = Async.Failure(Throwable(message = "IO_ELEMENT_X_WAIT_LIST"))), aWaitListState(loginAction = Async.Failure(Throwable(message = "IO_ELEMENT_X_WAIT_LIST"))),
aWaitListState(loginAction = Async.Success(SessionId("@alice:element.io"))), aWaitListState(loginAction = Async.Success(SessionId("@alice:element.io"))),
// Add other state here // Add other state here

View file

@ -30,7 +30,7 @@ open class AttachmentsPreviewStateProvider : PreviewParameterProvider<Attachment
anAttachmentsPreviewState(), anAttachmentsPreviewState(),
anAttachmentsPreviewState(mediaInfo = aFileInfo()), anAttachmentsPreviewState(mediaInfo = aFileInfo()),
anAttachmentsPreviewState(sendActionState = SendActionState.Sending.Uploading(0.5f)), anAttachmentsPreviewState(sendActionState = SendActionState.Sending.Uploading(0.5f)),
anAttachmentsPreviewState(sendActionState = SendActionState.Failure(RuntimeException())), anAttachmentsPreviewState(sendActionState = SendActionState.Failure(RuntimeException("error"))),
) )
} }

View file

@ -32,7 +32,7 @@ open class MediaViewerStateProvider : PreviewParameterProvider<MediaViewerState>
get() = sequenceOf( get() = sequenceOf(
aMediaViewerState(), aMediaViewerState(),
aMediaViewerState(Async.Loading()), aMediaViewerState(Async.Loading()),
aMediaViewerState(Async.Failure(IllegalStateException())), aMediaViewerState(Async.Failure(IllegalStateException("error"))),
aMediaViewerState( aMediaViewerState(
Async.Success( Async.Success(
LocalMedia(Uri.EMPTY, anImageInfo()) LocalMedia(Uri.EMPTY, anImageInfo())

View file

@ -26,7 +26,7 @@ open class ReportMessageStateProvider : PreviewParameterProvider<ReportMessageSt
aReportMessageState(reason = "This user is making the chat very toxic."), aReportMessageState(reason = "This user is making the chat very toxic."),
aReportMessageState(reason = "This user is making the chat very toxic.", blockUser = true), aReportMessageState(reason = "This user is making the chat very toxic.", blockUser = true),
aReportMessageState(reason = "This user is making the chat very toxic.", blockUser = true, result = Async.Loading()), aReportMessageState(reason = "This user is making the chat very toxic.", blockUser = true, result = Async.Loading()),
aReportMessageState(reason = "This user is making the chat very toxic.", blockUser = true, result = Async.Failure(Throwable())), aReportMessageState(reason = "This user is making the chat very toxic.", blockUser = true, result = Async.Failure(Throwable("error"))),
aReportMessageState(reason = "This user is making the chat very toxic.", blockUser = true, result = Async.Success(Unit)), aReportMessageState(reason = "This user is making the chat very toxic.", blockUser = true, result = Async.Success(Unit)),
// Add other states here // Add other states here
) )

View file

@ -95,9 +95,9 @@ object PermalinkParser {
return if (signUrl.isNullOrEmpty().not() && email.isNullOrEmpty().not()) { return if (signUrl.isNullOrEmpty().not() && email.isNullOrEmpty().not()) {
try { try {
val signValidUri = Uri.parse(signUrl) val signValidUri = Uri.parse(signUrl)
val identityServerHost = signValidUri.authority ?: throw IllegalArgumentException() val identityServerHost = signValidUri.authority ?: throw IllegalArgumentException("missing `authority`")
val token = signValidUri.getQueryParameter("token") ?: throw IllegalArgumentException() val token = signValidUri.getQueryParameter("token") ?: throw IllegalArgumentException("missing `token`")
val privateKey = signValidUri.getQueryParameter("private_key") ?: throw IllegalArgumentException() val privateKey = signValidUri.getQueryParameter("private_key") ?: throw IllegalArgumentException("missing `private_key`")
PermalinkData.RoomEmailInviteLink( PermalinkData.RoomEmailInviteLink(
roomId = identifier, roomId = identifier,
email = email!!, email = email!!,

View file

@ -56,7 +56,7 @@ exceptions:
SwallowedException: SwallowedException:
active: false active: false
ThrowingExceptionsWithoutMessageOrCause: ThrowingExceptionsWithoutMessageOrCause:
active: false active: true
TooGenericExceptionThrown: TooGenericExceptionThrown:
active: false active: false
InstanceOfCheckForException: InstanceOfCheckForException: