I have this function that I use for testing quite often:
inline fun <reified T> assertThrows(block: () -> Unit): AbstractThrowableAssert<*, out Throwable> {
try {
block()
} catch (e: Throwable) {
if (e is T) {
return assertThat(e)
} else {
throw e
}
}
throw AssertionError("Expected ${T::class.simpleName}")
}
Detekt is going wild on it and flagging all of these: TooGenericExceptionCaught, InstanceOfCheckForException, RethrowCaughtException.
Instead of @Suppress("Detekt.TooGenericExceptionCaught", "Detekt.InstanceOfCheckForException", "Detekt.RethrowCaughtException") - I know Detekt is optional but I like to see where things are coming from - it would be cool if I could just do @Suppress("Detekt.exceptions").
I have this function that I use for testing quite often:
Detekt is going wild on it and flagging all of these:
TooGenericExceptionCaught,InstanceOfCheckForException,RethrowCaughtException.Instead of
@Suppress("Detekt.TooGenericExceptionCaught", "Detekt.InstanceOfCheckForException", "Detekt.RethrowCaughtException")- I knowDetektis optional but I like to see where things are coming from - it would be cool if I could just do@Suppress("Detekt.exceptions").