-
Notifications
You must be signed in to change notification settings - Fork 1
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
p2: Detekt configuration clean up #148
Merged
ab-gnm
merged 2 commits into
ab/add-binary-compatibility-plugin
from
ab/change-detekt-config
Dec 12, 2024
+95
−96
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,26 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<issues format="6" by="lint 8.7.2" type="baseline" client="gradle" dependencies="false" name="AGP (8.7.2)" variant="all" version="8.7.2"> | ||
<issues format="6" by="lint 8.7.3" type="baseline" client="gradle" dependencies="false" name="AGP (8.7.3)" variant="all" version="8.7.3"> | ||
|
||
<issue | ||
id="GradleProjectIsolation" | ||
message="Avoid using method getRootProject" | ||
errorLine1=" val rootProject = target.rootProject" | ||
errorLine2=" ~~~~~~~~~~~"> | ||
errorLine1=" rootProject.layout.buildDirectory.file("reports/detekt/merge.sarif")," | ||
errorLine2=" ~~~~~~~~~~~"> | ||
<location | ||
file="src/main/kotlin/com/theguardian/convention/DetektPlugin.kt" | ||
line="23" | ||
column="38"/> | ||
file="src/main/kotlin/com/theguardian/convention/shared/SetupDetekt.kt" | ||
line="20" | ||
column="17"/> | ||
</issue> | ||
|
||
<issue | ||
id="GradleProjectIsolation" | ||
message="Avoid using method getRootProject" | ||
errorLine1=" basePath = rootProject.projectDir.absolutePath" | ||
errorLine2=" ~~~~~~~~~~~"> | ||
<location | ||
file="src/main/kotlin/com/theguardian/convention/shared/SetupDetekt.kt" | ||
line="57" | ||
column="24"/> | ||
</issue> | ||
|
||
</issues> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
73 changes: 0 additions & 73 deletions
73
android/build-logic/convention/src/main/kotlin/com/theguardian/convention/DetektPlugin.kt
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
66 changes: 66 additions & 0 deletions
66
...d/build-logic/convention/src/main/kotlin/com/theguardian/convention/shared/SetupDetekt.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
package com.theguardian.convention.shared | ||
|
||
import io.gitlab.arturbosch.detekt.Detekt | ||
import io.gitlab.arturbosch.detekt.extensions.DetektExtension | ||
import io.gitlab.arturbosch.detekt.report.ReportMergeTask | ||
import org.gradle.api.JavaVersion | ||
import org.gradle.api.Project | ||
|
||
/** | ||
* The Detekt convention plugin applies detekt plugins, and sets up configuration based on settings. | ||
*/ | ||
fun Project.setupDetekt() { | ||
with(this) { | ||
with(pluginManager) { | ||
this.apply(libs.plugin("detekt").pluginId) | ||
} | ||
|
||
tasks.register("reportMerge", ReportMergeTask::class.java) { | ||
output.set( | ||
rootProject.layout.buildDirectory.file("reports/detekt/merge.sarif"), | ||
) | ||
} | ||
|
||
val reportMerge = tasks.named("reportMerge", ReportMergeTask::class.java) | ||
|
||
reportMerge.configure { | ||
input.from(tasks.withType(Detekt::class.java).map { it.sarifReportFile }) | ||
} | ||
|
||
// enable reports | ||
tasks.withType(Detekt::class.java).configureEach { | ||
jvmTarget = JavaVersion.VERSION_17.toString() | ||
reports { | ||
xml.required.set(false) | ||
html.required.set(true) | ||
txt.required.set(true) | ||
md.required.set(false) | ||
|
||
sarif.required.set(true) | ||
} | ||
|
||
exclude( | ||
"**/build/*", | ||
"**/generated/*", | ||
"**/build.gradle.kts", | ||
"**/settings.gradle.kts", | ||
) | ||
|
||
finalizedBy(reportMerge) | ||
} | ||
|
||
extensions.configure(DetektExtension::class.java) { | ||
toolVersion = libs.findVersion("detekt").get().requiredVersion | ||
config.setFrom(file("${rootDir}/config/detekt.yml")) | ||
parallel = true | ||
|
||
basePath = rootProject.projectDir.absolutePath | ||
ignoredBuildTypes = listOf("release") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is the additional change here - ignoring release builds. |
||
|
||
if (!isJvmModule()) { | ||
// By default only main and test sources are included. I've added androidTest too | ||
source.from("src/androidTest/java", "src/androidTest/kotlin") | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Moved to
SetupDetekt.kt
below.