Skip to content

@Suppress("Detekt.ruleset") feature #766

@vanniktech

Description

@vanniktech

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").

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions