-
-
Notifications
You must be signed in to change notification settings - Fork 757
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
Complexity rules: ComplexInterface + MethodOverloading #440
Conversation
@@ -168,9 +168,15 @@ complexity: | |||
LargeClass: | |||
active: true | |||
threshold: 150 | |||
LargeInterface: | |||
active: false | |||
threshold: 10 |
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.
I do not know if we should call it so. LargeClass
threshold measurement is sloc and for LargeInterface
it would be #members. ComplexInterface
? What if we rename the threshold property?
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.
Threshold is ok.
ComplexInterface is ok.
override fun visitClass(klass: KtClass) { | ||
if (klass.isInterface()) { | ||
val body = klass.getBody() ?: return | ||
val size = body.children.count { it is KtNamedFunction || it is KtProperty } |
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.
I suspect a local variable is also a KtProperty
. Can you add a test case for this please?
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.
I will.
override val issue = Issue("MethodOverloading", Severity.Maintainability, | ||
"Methods which are overloaded often might be harder to maintain. " + | ||
"Furthermore, these methods are tightly coupled. " + | ||
"Refactor these methods and try to use optional parameters.") |
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 might be argueable. Optional parameters tend to break the single responsibility principle (Uncle Bob).... Ah ok I was thinking of Java. I think Kotlin calls them default parameters ^^
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.
I'll rename it.
@arturbosch What do you think about that?
|
Thanks for the changes! |
I know. |
KK, than I merge this right now ^^ |
Should we also count static members to the
LargeInterface
rule?