Replacement for -Xlint in Scala3?

Following up on a conversation in scala/bug#12441, is there a selected mechanism for getting -Xlint-style warnings?

If this is being moved out of the compiler into a plugin, possibly backed by something like semanticdb, that makes sense to me, I just haven’t found any documentation about it (the compiler options lookup table just lists X for those, for instance).

Thanks for your work on dotty/scala3, looking forward to moving my projects to it.

6 Likes

There isn’t one so far, and no one has stepped up to port the Scala 2 linting warnings to Scala 3 yet. I think the first step here would be to figure out which -Xlint warnings are the most popular. Then, for each of these warnings we should ask ourselves:

  • Why isn’t it enabled by default? If it’s because the false positive rate is too high or the performance impact is too important, can we solve that?
  • Is this lint only needed because of a defect in the language? If so can we fix the language instead of adding a warning?

See also this related thread in users.scala-lang: Is there an explanation of the reasoning behind various -Xlint options? - Question - Scala Users

4 Likes

I just noticed that -Xlint:deprecation is not supported yet as an alias for -deprecation.

I don’t especially like deprecations, but -Xlint is a convenient gateway for all such “not a language thing but did you notice?”

I’ll try to PR the minimal -Xlint, perhaps after that with a mechanism for extension.

Well, having multiple different flags with the same meaning isn’t great, so I’d say if we add it back it should itself be deprecated and point to -deprecation. (Also since lints are warnings -W would be more appropriate than -X, but that’s maybe too much bikeshedding.)

1 Like

Can’t have too much bike-shedding, by definition.

-Wlint to enable linting plug-ins. -Xlint was only due to java and the pun on excellent.

Deprecate -deprecation because compiler should not be emitting deprecations, which have nothing to do with correctness.

One open ticket in this area is https://github.com/lampepfl/dotty/issues/12785, about “unused” warnings specifically (“add support for -Wunused”)

5 Likes