-
-
Notifications
You must be signed in to change notification settings - Fork 821
Extend ComplexInterface to support exclusion of private member/functions #2478
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
Extend ComplexInterface to support exclusion of private member/functions #2478
Conversation
schalkms
left a comment
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.
Thanks for this fix! Please take a look at the attached comments.
...t-rules/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/complexity/ComplexInterfaceSpec.kt
Outdated
Show resolved
Hide resolved
...t-rules/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/complexity/ComplexInterfaceSpec.kt
Show resolved
Hide resolved
|
For some reason Travis hasn't run? This is what it looks like locally ( Any hints? Seems related to #2217 ? |
| private fun calculateMembers(body: KtClassBody) = body.children.count { it is KtNamedFunction || it is KtProperty } | ||
| private fun calculateMembers(body: KtClassBody) = body.children | ||
| .filter { | ||
| if (includePrivateDeclarations) { |
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.
Consider includeXXX || elseExpr.
Or maybe
private fun calculateMembers(body: KtClassBody): Int {
fun PsiElement.considerPrivate(): Boolean = includeStaticDeclarations ||
this is KtTypeParameterListOwner && !this.isPrivate()
fun PsiElement.isMember(): Boolean = this is KtNamedFunction || this is KtProperty
return body.children
.filter(PsiElement::considerPrivate)
.count(PsiElement::isMember)
}|
Try adding a |
Codecov Report
@@ Coverage Diff @@
## master #2478 +/- ##
=========================================
Coverage 83.29% 83.29%
- Complexity 2185 2196 +11
=========================================
Files 360 360
Lines 6207 6225 +18
Branches 1139 1144 +5
=========================================
+ Hits 5170 5185 +15
Misses 463 463
- Partials 574 577 +3
Continue to review full report at Codecov.
|
Following up discussion on #2446, currently
ComplexInterfaceis considering alsoprivatemembers/functions. I'm adding aincludePrivateDeclarationsconfig field (default false) to make this behavior configurable.Fixes #2446