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

ComplexInterface - should it also count private methods? #2446

Closed
Wrent opened this issue Mar 18, 2020 · 5 comments · Fixed by #2478
Closed

ComplexInterface - should it also count private methods? #2446

Wrent opened this issue Mar 18, 2020 · 5 comments · Fixed by #2478

Comments

@Wrent
Copy link

Wrent commented Mar 18, 2020

ComplexInterface is triggered even if the number of overrideable functions / properties is less than treshold, but there are private methods within the interface (used by default implementation of the functions), which trigger the rule.

Should it be the case? Instinctively, I would not think they would be counted, but maybe I am wrong..

@cortinico
Copy link
Member

Should it be the case? Instinctively, I would not think they would be counted, but maybe I am wrong..

I don't think so. Having too many private methods could be easily spotted by this other rule: https://arturbosch.github.io/detekt/complexity.html#toomanyfunctions

I like to think at ComplexInterface as a way to inspect the API surface of my interface so I would prefer having only public method considered during the inspection.

@Wrent
Copy link
Author

Wrent commented Mar 18, 2020

I like to think at ComplexInterface as a way to inspect the API surface of my interface so I would prefer having only public method considered during the inspection.

Exactly my thoughts, thanks for opinion.

@schalkms
Copy link
Member

Thanks for raising this interesting discussion thread.
I completely agree with the points made in @cortinico 's post. That's the reason why we have a separate rule for the mentioned case.

@BraisGabin
Copy link
Member

I think that there was a confusion here. If we all agree (I agree too) we should fix it. Becase, right now, ComplexInterface is counting the private functions.

@cortinico
Copy link
Member

cortinico commented Mar 21, 2020

Becase, right now, ComplexInterface is counting the private functions.

Agree, this should be fixed. Here a potential fix #2478

arturbosch pushed a commit that referenced this issue Mar 22, 2020
…ons (#2478)

* Extend ComplexInterface to support exclusion of private member/functions

Fixes #2446

* Include @schalkms suggestions

* Remove unnecessary parenthesis

* Add a validation exclusion for detekt-gradle-plugin

* Refactor calculateMembers
@arturbosch arturbosch added this to the 1.7.0 milestone Mar 22, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants