Back to Intellij Community

ReplaceGuardClauseWithFunctionCall

plugins/kotlin/code-insight/descriptions/resources-en/inspectionDescriptions/ReplaceGuardClauseWithFunctionCall.html

2025.3-rc-2288 B
Original Source

Reports guard clauses that can be replaced with a function call.

Example:

fun test(foo: Int?) {
      if (foo == null) throw IllegalArgumentException("foo") // replaceable clause
  }

After the quick-fix is applied:

fun test(foo: Int?) {
      checkNotNull(foo)
  }