报告 if 条件为常数的表达式,因此可以简化表达式。

虽然偶尔是有意为之,但这种构造非常混乱,并且通常是由拼写错误导致的。

示例:


  fun example() {
      if (true) {
          throw IllegalStateException("Unexpected state")
      }
  }

建议通过快速修复移除 if 条件:


  fun example() {
      throw IllegalStateException("Unexpected state")
  }