-
-
Notifications
You must be signed in to change notification settings - Fork 770
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
Ignore actual members in UnusedPrivateMember #3669
Ignore actual members in UnusedPrivateMember #3669
Conversation
Codecov Report
@@ Coverage Diff @@
## main #3669 +/- ##
=========================================
Coverage 77.95% 77.96%
Complexity 2870 2870
=========================================
Files 470 470
Lines 9245 9248 +3
Branches 1761 1763 +2
=========================================
+ Hits 7207 7210 +3
Misses 1077 1077
Partials 961 961
Continue to review full report at Codecov.
|
@@ -204,7 +205,7 @@ private class UnusedParameterVisitor(allowedNames: Regex) : UnusedMemberVisitor( | |||
} | |||
|
|||
override fun visitClassOrObject(klassOrObject: KtClassOrObject) { | |||
if (klassOrObject.isExpect()) return | |||
if (klassOrObject.isExpect() || klassOrObject.isActual()) return |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How is this related to the rule of thumb if a rule is ignored for overridden members, it should be ignored for actual members.
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This line is actually my mistake (I went with isExpect()
one step too far). Actual classes or objects should be visited. Just their actual members should be ignored.
I'll update the PR.
...t-rules-style/src/main/kotlin/io/gitlab/arturbosch/detekt/rules/style/UnusedPrivateMember.kt
Outdated
Show resolved
Hide resolved
a654113
to
cce1aea
Compare
@chao2zhang, Sorry for the mistake. I've fixed the PR, rebased and squashed for better readability. Also an example of an actual constructor, that should be ignored: expect class Foo(bar: Bar) {
expect fun doSomething()
} jvmMain: actual class Foo actual constructor(private val bar: Bar) {
actual fun doSomething() {
bar.doSomething()
}
} jsMain: actual class Foo actual constructor(bar: Bar) {
actual fun doSomething() {
// Do something with JS that doesn't require bar
}
} |
cce1aea
to
a6f6157
Compare
The general rule of thumb should be:
abstract
members, it should be ignored forexpect
members,actual
members.See also:
Related to #3415