Status of linting/warnings in Scala 3

Our team relied almost solely on fatal warnings coming directly from the Scala 2 compiler. Moving to Scala 3, we feel like flying without a parachute. There’s nothing in the Scala 2 warnings we couldn’t manually detect with enough time, but in reality lots of thing creep all the way from merge request through review and into the main branch. Often it’s not bugs directly, but slowly and surely, the code health seems to deteriorate.

A few very warnings which could go a long way:

  • Unused imports
  • Unused local value/parameters
  • Pure expression in statement position (not sure if this one was ever from the compiler or IntelliJ, feels like I haven’t seen it in a while)

For the first one above, I would settle for a working “optimize imports” functionality, but that also seems out of reach with both Metals and IntelliJ at the moment.

I fear the usage of this approach might be underestimated? You would previously get so much mileage out of just adding e.g. GitHub - typelevel/sbt-tpolecat: scalac options for the enlightened which just enables more or less everything.

I’m hopeful this could get prioritized more in the near future :slight_smile:


There’s an open pull request for unused imports: Warn unused imports by som-snytt · Pull Request #14524 · lampepfl/dotty · GitHub, it still needs a bit of tweaking.


Pure expression in statement position is covered, I think. For instance

def test = 


-- [E129] Potential Issue Warning: test.scala:4:4 ------------------------------
4 |    1
  |    ^
  |A pure expression does nothing in statement position; you may be omitting necessary parentheses

Or maybe there’s something else missing?

1 Like

I think you’re right about the pure expressions - it was never clear to me which cases it could detect since there’s no effect tracking in the current type system.