saveourtool/diktat

New rule: Empty functions should be one-liner and return `Unit`

Open

#1701 aperta il 29 giu 2023

Vedi su GitHub
 (2 commenti) (1 reazione) (1 assegnatario)Kotlin (40 fork)github user discovery
enhancementgood first issue

Metriche repository

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

Descrizione

If for some reasons, function have no any logic, but exists only for some kind of execution: in cases of testing via JUnit Runners or JUnit Rules or some other purposes, it shouldn't have any body and should be fixed in the following way

@Test
@SomeAnnotation
fun foo() {
// no-op here
}
// no-op here
@Test
@SomeAnnotation
fun foo() = Unit

Guida contributor