-
-
Notifications
You must be signed in to change notification settings - Fork 794
UnusedPrivateMember doesn't report the correct warning count #1981
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
Comments
This rule only flags unused functions/members/parameters in classes/interfaces/objects. |
Ok, I edited the snippet using just methods inside classes and the error is there. Can we reopen this? |
Yep, the rule currently counts the references to each name in a hashmap. |
Do we want to handle function overloading as part of this rule ?
|
Good one! I'm going to create a test for this case too. |
I updated the one proposed by @sowmyav24 and added two more (the other one is the same but with two functions): class Test {
val value = unusedFunction()
private fun unusedFunction(): Int {
return 5
}
private fun unusedFunction(num: Int): Int {
return num
}
} If we have two functions that are called the same and one of them is used, the other one is not reported. I think that this case is a bit worse that the first that I reported. Here you are getting 0 findings. |
Thanks for formulating new test cases and for investigating this issue further. |
I think that to fix this issue we need type resolver. I tried to fix it but I found a wall. If I have this functions: private fun f(a: Int)
private fun f(a: String) I can't know if |
Yes! |
Expected Behavior
In that code I expect to have two warnings because there are two unused functions
Observed Behavior
Only one warning is raised. The reason is becase the functions are called the same.
Steps to Reproduce
You can check this comparison: master...BraisGabin:unused-private-function
Context
I found this issue fixing a similar issue with parameters that are called the same in different functions. That issue was easier to fix that this one.
Your Environment
The text was updated successfully, but these errors were encountered: