scalacenter / scalafix

Refactoring and linting tool for Scala
https://scalacenter.github.io/scalafix/
BSD 3-Clause "New" or "Revised" License
830 stars 186 forks source link

Rules for ADTs and case classes #1621

Open armanbilge opened 2 years ago

armanbilge commented 2 years ago

Back again, with more potential upstream candidates :)

@bplommer wrote us some very nice internal scalafix rules for http4s. They are generally applicable, particularly for OSS libraries that must be mindful about binary compatibility. So we would like to give you the right of first refusal before we upstream it to typelevel-scalafix 😉

Thanks, appreciate your time to look into these!

bjaglin commented 2 years ago

Welcome back ;)

A lot of interesting linter rules! I am all in for accepting them upstream (same pros and cons as described in https://github.com/scalacenter/scalafix/issues/1620#issuecomment-1167865240). Actually, I had started implementing https://nrinaudo.github.io/scala-best-practices/adts/ as rules but never published my WIP.

Maybe we could group them under some kind of SafeADT rule, with some configuration allowing opt-out?

armanbilge commented 2 years ago

Fantastic! Glad to hear that :) thank you so much.

Maybe we could group them under some kind of SafeADT rule, with some configuration allowing opt-out?

Yes, that makes sense to me. Those ADT best practices look good too, although I'm curious about whether the advice to mark case objects as final is still relevant in modern Scala, and if so how it relates to the RedundantSyntax.finalObject rule.

Edit: ah, I think that's covered in the docs :) https://github.com/scalacenter/scalafix/blob/3f6ebebe88095ad7009cf9eb95536226a812aeb4/docs/rules/RedundantSyntax.md?plain=1#L16