assertk icon indicating copy to clipboard operation
assertk copied to clipboard

Add `@CheckResult`/`@CheckReturnValue` to `assertThat`

Open yogurtearl opened this issue 4 years ago • 1 comments

Add @CheckResult/@CheckReturnValue to assertThat so that Detekt can makes sure that you do something with the result of the assertThat methods.

See https://detekt.github.io/detekt/potential-bugs.html#ignoredreturnvalue

You could use an existing annotation from another dependency, or even just assertk.annotation.CheckReturnValue would be good enough to use with the detekt rule.

Related:

  • Errorprone check: https://errorprone.info/bugpattern/CheckReturnValue
  • Jspecify might add an annotation: https://github.com/jspecify/jspecify/issues/200
  • Kotlin might add something related: https://youtrack.jetbrains.com/issue/KT-12719

yogurtearl avatar Nov 27 '21 06:11 yogurtearl

Looks like there's traction for something official in kotlin for this https://youtrack.jetbrains.com/issue/KT-12719/Add-CheckResultMustUseReturnValueDiscardableResult-to-warn-about-unused-return-value#focus=Comments-27-6530269.0-0, will probably use that when it's available.

evant avatar Oct 31 '22 21:10 evant