kotlin-result icon indicating copy to clipboard operation
kotlin-result copied to clipboard

Detekt rule to detect missing `.bind()` calls inside `suspendBinding` and `binding`

Open kirillzh opened this issue 1 year ago • 3 comments

It's very easy to forget calling .bind() on a method especially when the rest of the binding block doesn't depend on the return result of this method (eg a Result<Unit, Error> fire and forget call):

binding {
  val a = getSomeValue().bind()
  saveValue(a) // forgot .bind() here
  doSomethingElse(a).bind()
}

It would be very helpful if we provided an out of the box Detekt rule to catch this, similar to how Arrow has it implemented here.

kirillzh avatar May 14 '24 23:05 kirillzh

Seems like a good idea. I wonder if there are any other Detekt rules worth writing for the library? Is there good documentation on how you write a Detekt rule + plug it in?

michaelbull avatar May 15 '24 09:05 michaelbull

Ping @kirillzh.

michaelbull avatar Jun 05 '24 07:06 michaelbull

I couldn't think of any other rules that might be helpful to write!

Here are some links that could be helpful here:

  • https://detekt.dev/docs/introduction/extensions/
  • https://github.com/woltapp/arrow-detekt-rules

kirillzh avatar Jun 05 '24 15:06 kirillzh

@michaelbull, are there no plans to implement this? Just curious why this was closed. Thanks!

kirillzh avatar Dec 16 '24 17:12 kirillzh

@kirillzh a PR is welcome. It was closed as its a stale issue that no active discussion is happening on.

If you would like to pick up the work to implement this in a PR, I am happy to be involved and review to get it across the line.

Do you have any plans to progress the feature you are requesting?

michaelbull avatar Dec 16 '24 19:12 michaelbull