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

Add detekt compiler plugin to main project #5492

Merged
merged 12 commits into from Dec 4, 2022

Conversation

3flex
Copy link
Member

@3flex 3flex commented Oct 31, 2022

This brings the detekt compiler plugin into the primary project. Aside from bringing the code over, this also makes changes to the Gradle plugin so that the standard plugin as well as the compiler plugin can be used in the same project. This wasn't previously possible due to the naming conflict on the detekt extension which was applied by both Gradle plugins.

I'd like to get this merged, then we can work on:

  • Confirming the versioning scheme for the compiler plugin which will be sensitive to the Kotlin version the target project is using. I propose just copying KSP's version scheme of $kotlinVersion-$pluginVersion e.g. 1.7.20-1.22.0-RC2
  • Docs
  • Pushing out at least one release (can then skip step 1 below)
  • Work on a fix for InvalidPackageDeclaration failures (means we can skip steps 3 & 4 below)

To test:

  1. Include these builds in the test project's settings.gradle(.kts) file:
includeBuild("../detekt/detekt-gradle-plugin")
includeBuild("../detekt")
  1. Apply the compiler plugin in a target project:
plugins {
    id("io.github.detekt.gradle.compiler-plugin")
}
  1. Add a detekt.yml config file and disable InvalidPackageDeclaration (see detekt-compiler-plugin/issues/15):
naming:
  InvalidPackageDeclaration:
    active: false
  1. Set buildUponDefaultConfig = true, e.g.:
detekt {
    buildUponDefaultConfig = true
}

The compiler plugin cannot be applied to the detekt project itself due to circular dependencies, which I couldn't work around, but hope to some time in future.

Closes #3520

@github-actions github-actions bot added build dependencies Pull requests that update a dependency file gradle labels Oct 31, 2022
Copy link

@github-advanced-security github-advanced-security bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

detekt found more than 10 potential problems in the proposed changes. Check the Files changed tab for more details.

@codecov
Copy link

codecov bot commented Oct 31, 2022

Codecov Report

Merging #5492 (f2690cf) into main (342c228) will increase coverage by 85.89%.
The diff coverage is n/a.

@@             Coverage Diff             @@
##             main    #5492       +/-   ##
===========================================
+ Coverage        0   85.89%   +85.89%     
- Complexity      0     3637     +3637     
===========================================
  Files           0      516      +516     
  Lines           0    12179    +12179     
  Branches        0     2171     +2171     
===========================================
+ Hits            0    10461    +10461     
- Misses          0      628      +628     
- Partials        0     1090     +1090     
Impacted Files Coverage Δ
.../arturbosch/detekt/rules/style/CanBeNonNullable.kt 73.20% <0.00%> (ø)
...ekt/rules/style/RedundantVisibilityModifierRule.kt 98.24% <0.00%> (ø)
...rturbosch/detekt/rules/style/OptionalWhenBraces.kt 94.11% <0.00%> (ø)
...b/arturbosch/detekt/rules/complexity/LargeClass.kt 94.87% <0.00%> (ø)
.../detekt/metrics/processors/KtFileCountProcessor.kt 100.00% <0.00%> (ø)
...t/rules/coroutines/SuspendFunWithFlowReturnType.kt 83.33% <0.00%> (ø)
...bosch/detekt/rules/naming/BooleanPropertyNaming.kt 94.28% <0.00%> (ø)
...detekt/metrics/processors/PackageCountProcessor.kt 100.00% <0.00%> (ø)
.../arturbosch/detekt/core/baseline/BaselineFacade.kt 86.66% <0.00%> (ø)
...ormatting/wrappers/FunctionTypeReferenceSpacing.kt 100.00% <0.00%> (ø)
... and 506 more

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

@schalkms
Copy link
Member

First of all, big shoutout to you @3flex! Great stuff 👍

I'd like to get this merged

I understand, that we are confident enough that the standard and compiler plugin can coexist for upcoming versions, without interfering each other. If so, I'm very pleased with merging this.

  • Confirming the versioning scheme for the compiler plugin which will be sensitive to the Kotlin version the target project is using. I propose just copying KSP's version scheme of $kotlinVersion-$pluginVersion e.g. 1.7.20-1.22.0-RC2

Agreed.

  • Docs

I think the focus should be on the restrictions for the compiler plugin. Maybe, the readme from the compiler plugin can be copied over to a separate detekt.dev webpage.

@3flex
Copy link
Member Author

3flex commented Dec 1, 2022

I propose to add docs in a separate PR. I'll open an issue for tracking once this is merged.

@chao2zhang chao2zhang merged commit 0abd43d into detekt:main Dec 4, 2022
@3flex 3flex deleted the compiler-plugin branch December 4, 2022 19:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
build dependencies Pull requests that update a dependency file gradle notable changes Marker for notable changes in the changelog
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add compiler plugin to main project
5 participants