Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@cortinico
Copy link
Member

Following up discussion on #2446, currently ComplexInterface is considering also private members/functions. I'm adding a includePrivateDeclarations config field (default false) to make this behavior configurable.

Fixes #2446

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.

Thanks for this fix! Please take a look at the attached comments.

@cortinico
Copy link
Member Author

For some reason Travis hasn't run?
Moreover AppVeyor is failing on :detekt-gradle-plugin:detekt because of failed validation of config file.

This is what it looks like locally (./gradlew --project-dir detekt-gradle-plugin detekt):

> Task :detekt FAILED
Property 'complexity>ComplexInterface>includePrivateDeclarations' is misspelled or does not exist.

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':detekt'.
> Run failed with 1 invalid config property.

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) {
Copy link
Member

@arturbosch arturbosch Mar 21, 2020

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)
    }

@arturbosch arturbosch added this to the 1.7.0 milestone Mar 21, 2020
@arturbosch
Copy link
Member

Try adding a config>excludes entry for now: https://github.com/arturbosch/detekt/pull/2201/files
We should document this in our contribution guide :(.
Maybe even come up with an automatic way to generate them in our generator module to not confuse contributors ...

@codecov-io
Copy link

Codecov Report

Merging #2478 into master will increase coverage by 0.00%.
The diff coverage is 80.00%.

Impacted file tree graph

@@            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     
Impacted Files Coverage Δ Complexity Δ
...rbosch/detekt/rules/complexity/ComplexInterface.kt 93.10% <80.00%> (-6.90%) 14.00 <3.00> (-1.00)
.../rules/documentation/UndocumentedPublicProperty.kt 82.35% <0.00%> (-5.15%) 21.00% <0.00%> (+11.00%) ⬇️
...lab/arturbosch/detekt/formatting/FormattingRule.kt 93.33% <0.00%> (-2.97%) 13.00% <0.00%> (ø%)
...b/arturbosch/detekt/cli/baseline/BaselineFacade.kt 89.47% <0.00%> (-0.53%) 10.00% <0.00%> (ø%)
.../io/gitlab/arturbosch/detekt/cli/runners/Runner.kt 94.11% <0.00%> (+1.80%) 11.00% <0.00%> (-1.00%) ⬆️
...b/arturbosch/detekt/api/internal/DetektPomModel.kt 70.58% <0.00%> (+1.83%) 5.00% <0.00%> (ø%)
.../arturbosch/detekt/cli/baseline/BaselineHandler.kt 77.77% <0.00%> (+5.55%) 14.00% <0.00%> (+2.00%)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update a31e673...b6a1b2f. Read the comment docs.

@arturbosch arturbosch merged commit 2e40e53 into detekt:master Mar 22, 2020
@cortinico cortinico deleted the fix-2446-complex-interface-private branch June 13, 2020 20:40
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.

ComplexInterface - should it also count private methods?

4 participants