Skip to content
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

Improve UnusedPrivateMember when it's related with parameters #1949

Merged
merged 1 commit into from
Oct 4, 2019

Conversation

BraisGabin
Copy link
Member

@BraisGabin BraisGabin commented Sep 25, 2019

If two parameters are called the same in two different functions and both are not used now we report them as two errors.

Copy link
Member

@schalkms schalkms left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Excuse me for reporting back after such a long timeframe.
I suppose that the problem here lies in the following referenced lines.
Note that I didn't debug the test code.
Only a single parameter named unusedParameter gets added to the Map.
Therefore, only 1 parameter gets reported.
I hope that this serves as a good starting point for you. If not, please don't hesitate to ask for help.

https://github.com/arturbosch/detekt/blob/387f95ea9db6b7473bb7478561041aba6ad92ad7/detekt-rules/src/main/kotlin/io/gitlab/arturbosch/detekt/rules/style/UnusedPrivateMember.kt#L138-L140

@BraisGabin BraisGabin changed the title Add a failing test for UnusedPrivateMember Improve UnusedPrivateMember when it's related with parameters Oct 3, 2019
@BraisGabin
Copy link
Member Author

Reading the code I found that the functions has the same problem but it's far more complicated to check. I'm going to create an issue to talk about that. So this PR is only to check the parameters.

Copy link
Member

@schalkms schalkms left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume that this is then ready to merge. Am I right?

Comment on lines 337 to 350
val code = """
class Test {
val value = usedMethod(1)
val value2 = usedMethod2(1)

private fun usedMethod(unusedParameter: Int): Int {
return 5
}

private fun usedMethod2(unusedParameter: Int) {
return 5
}
}
"""
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: 4 missing spaces (indentation)

@schalkms
Copy link
Member

schalkms commented Oct 4, 2019

Reading the code I found that the functions has the same problem but it's far more complicated to check.

Please elaborate on that in a separate issue, so that the community can also understand this problem.

If two parameters are called the same in different calls now it's
detected as two warnings.
@BraisGabin
Copy link
Member Author

Fixed. Yes, this is ready to merge and I'll write the issue.

@schalkms schalkms merged commit d2fca19 into detekt:master Oct 4, 2019
@arturbosch arturbosch added this to the 1.1.0 milestone Oct 4, 2019
smyachenkov pushed a commit to smyachenkov/detekt that referenced this pull request Dec 9, 2019
If two parameters are called the same in different calls now it's
detected as two warnings.
smyachenkov pushed a commit to smyachenkov/detekt that referenced this pull request Dec 9, 2019
If two parameters are called the same in different calls now it's
detected as two warnings.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants