saveourtool/diktat

[`INVERSE_FUNCTION_PREFERRED`] should not replace `!ClosedRange.isEmpty()`

Open

#1,699 创建于 2023年6月22日

在 GitHub 查看
 (2 评论) (0 反应) (1 负责人)Kotlin (40 fork)github user discovery
buggood first issue

仓库指标

Star
 (571 star)
PR 合并指标
 (PR 指标待抓取)

描述

Describe the bug

Given the following code:

val range: ClosedRange<Int> = 0..1
check(!range.isEmpty())

Diktat suggests replacing this with the nonexistent ClosedRange.isNotEmpty() function:

[INVERSE_FUNCTION_PREFERRED] it is better to use inverse function: isNotEmpty() instead of !isEmpty() (diktat-ruleset:inverse-method)

Expected behavior

Rule should not be triggered when the isNotEmpty function does not exist.

Environment information

  • diktat version: 1.2.5
  • how is diktat run (CLI, plugin, etc.): CLI

贡献者指南