saveourtool/diktat

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

Open

#1.699 geöffnet am 22. Juni 2023

Auf GitHub ansehen
 (2 Kommentare) (0 Reaktionen) (1 zugewiesene Person)Kotlin (40 Forks)github user discovery
buggood first issue

Repository-Metriken

Stars
 (571 Stars)
PR-Merge-Metriken
 (PR-Metriken ausstehend)

Beschreibung

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

Contributor Guide