scala-wartremover

Should I use the final modifier when declaring case classes?

丶灬走出姿态 提交于 2019-11-27 18:28:14
According to scala-wartremover static analysis tool I have to put "final" in front of every case classes I create: error message says "case classes must be final". According to scapegoat (another static analysis tool for Scala) instead I shouldn't (error message: "Redundant final modifier on case class") Who is right, and why? It is not redundant in the sense that using it does change things. As one would expect, you cannot extend a final case class, but you can extend a non-final one. Why does wartremover suggest that case classes should be final? Well, because extending them isn't really a

Should I use the final modifier when declaring case classes?

风流意气都作罢 提交于 2019-11-26 22:41:05
问题 According to scala-wartremover static analysis tool I have to put "final" in front of every case classes I create: error message says "case classes must be final". According to scapegoat (another static analysis tool for Scala) instead I shouldn't (error message: "Redundant final modifier on case class") Who is right, and why? 回答1: It is not redundant in the sense that using it does change things. As one would expect, you cannot extend a final case class, but you can extend a non-final one.