New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Compiler should warn about unused private methods #440
Comments
Imported From: https://issues.scala-lang.org/browse/SI-440?orig=1 |
@odersky said: |
@adriaanm said: |
@blair said: |
@adriaanm said: |
@blair said: One of the reasons people like using Clang instead of gcc/g++ to compile their code is because it gives more and better warnings and errors. I would think one would want the same from scalac. Am I missing something? |
Christopher Sahnwaldt (jcsahnwaldt) said: |
@retronym said: But in the meantime, here an experimental implementation: paulp/scala@386464fe. Not really suitable for an end-user at it is based on the generated bytecode, so the warnings might refer to mangled names, etc. BTW, IntelliJ highlights unused privates. |
@adriaanm said: I'd rather invest in a rich compiler "platform" that can be used by tools such as the ones Jason mentions than implement this ad-hoc analysis (no matter how useful). This kind of analysis seems like something you would run once in a while, maybe on an integration server, or after a refactoring. |
@blair said: The issue I had with closing the ticket was the "Out of Scope" resolution, which doesn't seem accurate, as a compiler is one place to check for programming errors. What about adding another "Will not implement" and provide the limited resources as a reason in the comment? I wouldn't have been so adamant about this issue then :) |
@paulp said: |
I recently did some refactoring on my Scala code and later realized that
I had a private method that was no longer used.
It would be great if the Scala compiler could warn about these to indicate
programming errors.
For example, this should generate a warning since do_nothing is not
used.
Currently, we can use findbugs to find these, but having the compiler
do them would be much nicer.
The text was updated successfully, but these errors were encountered: