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
[Feature Request] Produce a warning for unused methods #243
Comments
This can be applied only to unused private methods. This is a part of the roadmap |
I think traversing the shard/app's specs may still be useful for producing a warning if a public method that is exported by the project isn't used (can't be guaranteed that it compiles) |
What if the shard is some kind of api and public method is designed to be used in a separate dependent shard? |
In that case, wouldn't you expect that method to have been spec'd? Would it make sense for it to be optional for unused public methods, with private unused method warnings enabled by default? |
Ok, i see the point now, thanks. Keep in mind, Ameba makes static analysis only and knows nothing about types, so it is quite hard to do this properly. For example: class MyClass
def select
# ...
end
end
# somewhere in spec...
obj.select { ... } # is this a custom method or the built-in one `Array#select` ? While detecting unused private methods could be a bit easier, since you can use them only in class, finding unused public methods could be challenging and in my understanding doesn't worth it if we disable that by default. |
Crystal's behaviour of not type-checking unused code paths can lead to some annoying situations.
A lint that checks that every method is called will help reduce dead and broken code in a codebase.
The text was updated successfully, but these errors were encountered: