Skip to content

Latest commit

 

History

History
25 lines (15 loc) · 624 Bytes

IgnoredReturnValue.md

File metadata and controls

25 lines (15 loc) · 624 Bytes

Pattern: Ignored return value

Issue: -

Description

Warns on instances where a function, annotated with either @CheckReturnValue or @CheckResult, returns a value but that value is not used in any way. The Kotlin compiler gives no warning for this scenario normally so that's the rationale behind this rule.

Example of incorrect code:

    returnsValue()

Example of correct code:

    if (42 == returnsValue()) {}

    val x = returnsValue()

Further Reading