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

Fix KotlinProjectExtension.targets import on Kotlin 1.7.20 #5381

Merged
merged 1 commit into from Oct 6, 2022

Conversation

Goooler
Copy link
Contributor

@Goooler Goooler commented Oct 6, 2022

@Goooler Goooler changed the title Obtain KotlinJvmProjectExtension's target on Kotlin 1.7.20 Fix KotlinProjectExtension.targets import on Kotlin 1.7.20 Oct 6, 2022
@codecov
Copy link

codecov bot commented Oct 6, 2022

Codecov Report

Merging #5381 (faf099e) into main (7eab480) will increase coverage by 0.27%.
The diff coverage is 81.25%.

❗ Current head faf099e differs from pull request most recent head d99c88d. Consider uploading reports for the commit d99c88d to get more accurate results

@@             Coverage Diff              @@
##               main    #5381      +/-   ##
============================================
+ Coverage     85.84%   86.11%   +0.27%     
+ Complexity     3722     3643      -79     
============================================
  Files           513      515       +2     
  Lines         12023    12085      +62     
  Branches       2227     2161      -66     
============================================
+ Hits          10321    10407      +86     
+ Misses          611      609       -2     
+ Partials       1091     1069      -22     
Impacted Files Coverage Δ
...in/io/gitlab/arturbosch/detekt/api/SplitPattern.kt 100.00% <ø> (+7.40%) ⬆️
...gitlab/arturbosch/detekt/core/config/BaseConfig.kt 90.32% <0.00%> (-6.35%) ⬇️
...t/generator/collection/RuleSetProviderCollector.kt 78.31% <0.00%> (-0.96%) ⬇️
...detekt/rules/bugs/DuplicateCaseInWhenExpression.kt 100.00% <ø> (ø)
...ab/arturbosch/detekt/rules/bugs/MissingWhenCase.kt 92.85% <ø> (ø)
...rturbosch/detekt/rules/bugs/RedundantElseInWhen.kt 100.00% <ø> (+7.69%) ⬆️
.../arturbosch/detekt/rules/style/CanBeNonNullable.kt 73.20% <ø> (ø)
...tlab/arturbosch/detekt/rules/style/UseDataClass.kt 79.72% <0.00%> (-1.36%) ⬇️
...bosch/detekt/rules/complexity/LabeledExpression.kt 86.20% <50.00%> (ø)
.../arturbosch/detekt/rules/style/AlsoCouldBeApply.kt 56.25% <56.25%> (ø)
... and 53 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@cortinico cortinico enabled auto-merge (squash) October 6, 2022 12:21
@cortinico cortinico merged commit 075db1f into detekt:main Oct 6, 2022
@Goooler Goooler deleted the fix_errors_from_5163 branch October 6, 2022 12:24
@Goooler
Copy link
Contributor Author

Goooler commented Oct 6, 2022

@cortinico What will be the min Kotlin version requirement of Detekt 1.22, if it running under Kotlin 1.7.20, this PR would be a broken change?

@cortinico
Copy link
Member

@cortinico What will be the min Kotlin version requirement of Detekt 1.22, if it running under Kotlin 1.7.20, this PR would be a broken change?

That's a non trivial question as it depends on the Kotlin version used by Gradle (as this is part of the Gradle plugin). I don't recall what's the status in the ecosystem, but we can't enforce 1.7.20 on all of our users. @3flex do you recall if this is safe to land or do we need to revert it?

@Goooler
Copy link
Contributor Author

Goooler commented Oct 6, 2022

If not, I'll address a compatible commit with Goooler#3.

@Goooler
Copy link
Contributor Author

Goooler commented Oct 6, 2022

I just see the declaration of KotlinProjectExtension.targets has changed from

// 1.7.10
val KotlinProjectExtension.targets: Iterable<KotlinTarget>
    get() = when (this) {
        is KotlinSingleTargetExtension -> listOf(this.target)
        is KotlinMultiplatformExtension -> targets
        else -> error("Unexpected 'kotlin' extension $this")
    }

to

// 1.7.20
val KotlinProjectExtension.targets: Iterable<KotlinTarget>
    get() = when (this) {
        is KotlinSingleTargetExtension<*> -> listOf(this.target)
        is KotlinMultiplatformExtension -> targets
        else -> error("Unexpected 'kotlin' extension $this")
    }

there is an type argument added on KotlinSingleTargetExtension:

abstract class KotlinSingleTargetExtension<TARGET : KotlinTarget>(project: Project) : KotlinProjectExtension(project) {
    abstract val target: TARGET

    fun target(body: Action<TARGET>) = body.execute(target)
}

@Goooler
Copy link
Contributor Author

Goooler commented Oct 6, 2022

We can fix this broken change like Goooler@bb81a27?

@Goooler
Copy link
Contributor Author

Goooler commented Oct 6, 2022

And the other solution is using KotlinJvmProjectExtension's target directly like Goooler@c6b9550, but I'd prefer to merge DetektJvm into DetektMultiplatform to unify task configurations.

@3flex
Copy link
Member

3flex commented Oct 6, 2022

I had a look at this and there's no need to use that function there. So I've opened #5383 to remove it which should avoid any compatibility issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants