Skip to content

False negative in IgnoredReturnValue #3170

Description

@BraisGabin

Expected Behavior

A use of an annotated method with @CheckReturnValue at the end of an if expression should be flagged by IgnoredReturnValue if the output of the if is not used.

Same for the when.

Steps to Reproduce

package test

import kotlin.random.Random

@CheckReturnValue
fun returnsInt() = 42

if (Random.nextBoolean()) {
    println("hello")
} else {
    returnsInt()
}

Your Environment

  • Version of detekt used: master (1.14.2)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions