Fine-granular warnings silencing


#1

At the moment we don’t have a way to, for example, completely disable one kind of warnings, turn another into error and leave the rest untouched.

We have https://github.com/ghik/silencer but it is intrusive and inconvenient to use.

I would propose to implement fine-granular warning settings.

So, for each kind of a warning we should be able choose one of 3 possible alert levels, {IGNORE | WARN | FAIL}.

The only problem is how to identify warnings - there is no identifier parameter available in compiler logging method (c.warning(...), etc).

Actually we may implement two solutions (both of them may co-exist):

  1. Add a “identifier” parameter into compiler to all the compiler logging methods. So we may provide identifiers like c.warning(123456, "message"), c.error(4567, "message")
  2. Add missing parameters with a macro as a hash(file:line:character).

At the end we would be able to do smth like scalac -Y:warning:SC-XXXX:ignore -Y:warning:SC-XXXX:fail

This should be relatively easy to implement and it should significantly improve our experience.

Related post: https://github.com/scala/bug/issues/7934#issuecomment-427583273


Towards better error messages in Scalac
#2

See also https://scala-lang.org/blog/2016/10/14/dotty-errors.html and Towards better error messages in Scalac


#3

Besides customizing each warning type, we also need to be able to make those customizations within a particular scope. If it’s for an entire compiler invocation it could be a scalac flag but if it’s for a specific region of code there needs to be a way of specifying it in the code. The only thing I know of that has such a duality is language imports. I guess this would be another.

I’m not sure what c.error(...) is – is that code in the scalac codebase?

Anyway, my understanding is that everyone wants such an ability, but besides for the bikeshedding that may need to be done, the main thing holding this up is that so far no one has stepped forward with an implementation. I’m sure a PR would be welcome…


#4

I keep wanting to work on this, but so far all I have to show is a Friday afternoon’s worth of tinkering with a command-line option to configure deprecation warnings: https://github.com/scala/scala/compare/2.13.x...adriaanm:deprconf :slight_smile:

happy to mentor anyone who’d like to pick this up