saveourtool/diktat

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

Open

#1699 aperta il 22 giu 2023

Vedi su GitHub
 (2 commenti) (0 reazioni) (1 assegnatario)Kotlin (40 fork)github user discovery
buggood first issue

Metriche repository

Star
 (571 star)
Metriche merge PR
 (Metriche PR in attesa)

Descrizione

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

Guida contributor