-
-
Notifications
You must be signed in to change notification settings - Fork 773
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
Deprecate configuration of reports in detekt Gradle extension #3687
Conversation
Codecov Report
@@ Coverage Diff @@
## main #3687 +/- ##
============================================
- Coverage 83.58% 83.58% -0.01%
+ Complexity 3187 3186 -1
============================================
Files 459 459
Lines 9101 9099 -2
Branches 1772 1772
============================================
- Hits 7607 7605 -2
Misses 561 561
Partials 933 933
Continue to review full report at Codecov.
|
docs/pages/gettingstarted/gradle.md
Outdated
reportId = "CustomJsonReport" | ||
destination = file("build/reports/detekt.json") | ||
} | ||
} |
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.
How do I enable/disable some reports now? And should we talk about reportsDir
here? Or is it a default in gradle so we don't need to?
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.
All report config is done on the task, so you would enable/disable reports either on the individual task level or using withType
. That's the doc section I need to write.
reportsDir
is used in Gradle for other code quality plugins so we'd now follow that convention. I can mention that in the doc and remove references to the deprecated option (I didn't search to see if there are any yet)
File(extension.reportsDir, compilation.name + ".sarif").absolutePath | ||
} | ||
) | ||
) |
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.
would it be possible to extract this to a function/extension function so we should need to pass the name and it will configure all the reports? We have a lot of duplicated code between Multiplatform, JVM and Android (not only this)
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.
And, should we change Plain too?
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.
Plain is OK because it defers to the default report path set in the task if the report destination (or now, the outputLocation) is not set (it's an odd exception because the task isn't setup the same way as the others but at least it works):
detekt/detekt-gradle-plugin/src/main/kotlin/io/gitlab/arturbosch/detekt/Detekt.kt
Lines 270 to 273 in da8676d
if (isEnabled) { | |
val destination = report.destination ?: reportsDir.getOrElse(defaultReportsDir.asFile) | |
.resolve("${DetektReport.DEFAULT_FILENAME}.${report.type.extension}") | |
provider.set(destination) |
There's a fair bit of refactoring that can be done in the plugin, lots of which is easier once we're on Gradle 6.1. I'd prefer to wait until then before fixing up the repetition.
@Suppress("DeprecatedCallableAddReplaceWith", "DEPRECATION") | ||
@Deprecated("Customise the reports on the Detekt task(s) instead.", level = DeprecationLevel.WARNING) | ||
fun reports(configure: Action<DetektReports>) = configure.execute(reports) |
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.
In the DetektExtension, will it make sense to keep the enabling flags for each report type? My assumptions are:
- Fewer users are configuring the report output location
- More users are configuring whether to keep txt/xml/html/sarif.
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.
I understand your point, but in Gradle reports are configured on tasks, not on the extension. That's what's done for CodeNarc, Checkstyle and PMD extensions, and that intention is made explicit in the docs:
Things that produce reports (typically tasks) expose a report container that contains Report objects for each possible report that they can produce.
We can't implement ReportContainer directly but in keeping with that convention (and slightly simplifying the plugin) I still think it should be removed.
Any other concerns on this before merging? I'd only suggest waiting until after 1.17 release now some RCs have been published. |
Agree, we should wait until 1.17.0 is released. |
LGTM? |
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.
Can we please extend a bit on the documentation for this PR?
Specifically we're deprecating a property that is suggested to use in our README and in the homepage of the website: https://detekt.github.io/detekt/ Therefore we should provide clear alternatives to our users.
Potentially also a migration page should be added as well.
Should we push this to |
Yeah sorry I haven't had time to dedicate to this recently. Happy to push it back. I'll need to rebase and still write some docs. |
7d7d7fe
to
99fa293
Compare
Rebased & docs updated. I believe I've updated all sections where the deprecated configuration was used, except the old "News" posts. Migration instructions were added to the changelog. |
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.
I'd vote to split this PR in two. One with code and chancellor and the other with the doc. Otherwise the users will see a "too updated" documentation untilnwe release 1.19
Time for versioned docs? :) I've split them up - doc updates in #4064. I've left the changelog & migration update in this PR because the changelog is versioned so it's clear that it's related to unreleased changes. |
detekt-gradle-plugin/src/main/kotlin/io/gitlab/arturbosch/detekt/extensions/DetektExtension.kt
Show resolved
Hide resolved
This is unnecessary as it just returns the value of reportsDir
This matches the property names & types used in Gradle's code quality plugins.
Is there something missing here? Can we merge this? This is a big change fot 1.19.0 so I think that as soon as we merge it as better. Someone using the SNAPSHOT can find some issue or we can find some issue while developing the tool itself. |
☝️ Agree. I believe we're good to go for merging this |
Doc update for detekt#3687 # Conflicts: # docs/pages/gettingstarted/gradle.md
Doc update for #3687 # Conflicts: # docs/pages/gettingstarted/gradle.md
Reports need to be configured on tasks directly, not by using the detekt extension.
This is to avoid setting the same destination path for multiple detekt reports. An example of this can be seen in the detektTest task of this build scan where the html report is written to the same path as the report generated by the detektMain task because both tasks get the destination path from the extension.
I will add a new section to the Gradle config doc and link to it from the deprecation message on the extension once the PR has been reviewed.
Fixes: #3926
Fixes: #4035
Fixes: #4044
Edit by @cortinico - Added fix issue reference