typelevel-scalafix icon indicating copy to clipboard operation
typelevel-scalafix copied to clipboard

Add linter for any discarded value

Open bplommer opened this issue 3 years ago • 6 comments

I suggest adding a linter that will warn for any discarded value, regardless of its type. This would both catch unused effectful code that's not concrete IO - it would need to be disabled for blocks of side-effecting code, but I see this as an extra advantage since side-effecting code would have to be explicitly marked as such.

bplommer avatar Jun 20 '22 13:06 bplommer

Do you think this is something we could upstream to scalafix itself?

I've been staring at your general linters in http4s wondering if they might take them too.

armanbilge avatar Jun 20 '22 14:06 armanbilge

Good point! The "redundant final object" rule has already been upstreamed and scalafix itself seems to be more actively maintained than it was a while back.

bplommer avatar Jun 20 '22 15:06 bplommer

I saw that! Nice work on it :) yes, they've been responsive to my ideas to upstream some stuff from our build here too.

armanbilge avatar Jun 20 '22 15:06 armanbilge

Linking to:

  • https://github.com/scalacenter/scalafix/issues/1620

armanbilge avatar Jun 20 '22 15:06 armanbilge

If someone points me to a repo that demonstrates a gotcha, I will test -Wnonunit-statement against it. Currently, I'm just running it over the compiler project to avoid noise, as opposed to demonstrating utility. I think it noticed one or two possible bugs, but the imperative compiler and library are freely side-effecting.

som-snytt avatar Jun 30 '22 16:06 som-snytt

I think this is obsolete now that -Wnonunit-statement exists

Daenyth avatar Jul 24 '23 18:07 Daenyth