cats
cats copied to clipboard
Suppress Compiler Warnings (kernel)
This is an ongoing effort for suppressing compiler warnings that keep plaguing the project.
Suppresses the warnings in kernel* modules for all Scala versions.
Seems there can be some issues with @nowarn("cat=unused-params")
while upgrading to Scala 3.1.x versions (see discussion in https://github.com/http4s/http4s/pull/6300#pullrequestreview-943891503)
Perhaps, it may make sense to make use of val _ = someUnusedParam
pattern in this PR as well...
The other option is we continue to keep fatal warnings disabled on Scala 3 π
I don't think it's going to help... Scala 3.0 silently ignores unused parameters along with any kind of @nowarn
annotation. Whereas Scala 3.1 will be failing on @nowarn("cat=unused-params")
anyway regardless of the fatal warnings option.
Added more thoughts on how to overcome the compatibility issue: https://github.com/http4s/http4s/pull/6300#discussion_r851824642
I'm considering to take that approach, but sincerely open to discussion :)
Hi @armanbilge. I realized that warnings for Scala 2.12 for unused .. well, everything .. were suppressed entirely in sbt-typelevel:
val warnings212 = Seq("-Xlint:-unused,_")
So.. I wonder βΒ was it made intentionally and can we assume now that the warnings regarding unused stuff will never show up for Scala 2.12?
Oh, interesting π sbt-typelevel inherited those settings from sbt-spiewak which derived them from sbt-tpolecat. So probably intentional. In any case, it's what all the builds are using now, and many were using before too, so it probably works just fine.
That's fine... Just curious though βΒ is it just because 2.12 is sunsetting and no one likes messing around with it? Or is it something more special...
Here's the original commit. https://github.com/djspiewak/sbt-spiewak/commit/95a45d0ea91a015c1e38e9f56d5533bb3acd8f28
Oh that's interesting... It was introduced even before Scala 2.13.0 was released. Seems like Daniel just didn't like that sort of warnings at all π
Btw, remember sbt-typelevel hosts itself and sbt uses Scala 2.12. I'll have to check later but I'm pretty sure I have unused warnings when I develop it. So maybe it's enabled by something else π€
Well, for Cats it's definitely disabled because when I enable it temporarily and re-compile for 2.12, then the "unused" warnings begin coming in numbers.
You're right. I was dreaming about sbt-typelevel, seems I don't have unused warnings there at all π
@satorg I've bumped sbt-typelevel to a snapshot with your PR (thanks again for doing that!). That should unblock your work, and we'll make sure to get on a stable release before we merge :)
@armanbilge Initially I intended to fix compiler warnings in a bulk. And I completed with "kernel" modules quite a long ago. But turned out that "core" modules have quite a lot of warnings like these:
[warn] /Users/.../typelevel/cats/core/src/main/scala/cats/syntax/bitraverse.scala:26:22: parameter value evidence$1 in method catsSyntaxBitraverse is never used
[warn] implicit final def catsSyntaxBitraverse[F[_, _]: Bitraverse, A, B](fab: F[A, B]): BitraverseOps[F, A, B] =
[warn] ^
[warn] /Users/.../typelevel/cats/core/src/main/scala/cats/syntax/bitraverse.scala:31:22: parameter value evidence$2 in method catsSyntaxNestedBitraverse is never used
[warn] implicit final def catsSyntaxNestedBitraverse[F[_, _]: Bitraverse, G[_], A, B](
[warn] ^
[warn] /Users/.../typelevel/cats/core/src/main/scala/cats/syntax/bitraverse.scala:48:22: parameter value evidence$4 in method catsSyntaxBitraverseBinCompat0 is never use
[warn] implicit final def catsSyntaxBitraverseBinCompat0[F[_, _]: Bitraverse, A, B](
[warn] ^
which require quite gentle and precise handling I think.
But since the "kernel" modules seem to be ready, I'd like to separate the work into multiple PRs and thus keep the kernel-related part within this PR to let it being reviewed and hopefully merged. Meanwhile I can continue working on the "core" part.
Would it work, wdyt?
Yup, that sounds like a very good plan to me! We can re-enable fatal warnings module-by-module.
Ok nice, thank you. I think this PR is pretty much ready then.
@satorg I'm sorry, I haven't forgotten about this PR.
The truth is I've been hesitating, because I'm weighing what I think are fairly straightforward changes here with the fact it requires putting Cats on an sbt-typelevel milestone. There are some non-trivial changes coming to sbt-typelevel and I'd rather not have to worry about accidentally breaking the Cats build (the fact that Cats Effect is stuck on the milestone is stress enough!).
- upgrade to laika 0.19
- rework to use scalac-options
- replacing the sonatype client
In theory we could backport your scalac warning fixes to sbt-tl 0.4.x. However if you're eager to work on that what I'd actually love help with is integrating with the scalac-options library for 0.5.x.
@armanbilge yeah, no worries. I also feel a bit hesitant about pushing this work out. Because before continuing it would be better to stabilize the build system itself.
However if you're eager to work on that what I'd actually love help with is integrating with the scalac-options library for 0.5.x.
Ah ok, I think I can help with that. Thanks.
Converted to "Draft" to put on hold until work on scalac compiler options is stabilized.
I arrived via good first issues [sic]. I know about options on Scala 2 and somewhat on Scala 3, and I generally endorse using -Xlint
, also it's not "fatal warnings" but -Werror
which I pronounce "worry". I'm interested in learning how cats can be supported by the options cross-compilation, but maybe you're already working out a solution.
@satorg @som-snytt if there are folks motivated to work on this, I'm thinking we should just update Cats to the sbt-typelevel milestone to unblock this work.
In https://github.com/typelevel/cats/pull/4187#issuecomment-1243184576 I was worried about too many changes happening in sbt-typelevel, but besides the Laika upgrade the other objectives have been dormant, and I don't think that they are going to land in 0.5 after all. That's okay π
@armanbilge @som-snytt if I remember correctly, there are quite a few warnings that are handled differently in different Scala versions (i.e. 2.12, 2.13, 3). And that is what we tried to address with scalac-compat. I think, it could come handy for Cats too. Are we fine with bringing it in there?
Yes, scalac-compat has been wonderful! We are using it in Cats Effect now as well.