Allow plugins to contribute to the default configuration#4315
Conversation
74fc2b3 to
0d22c7c
Compare
0d22c7c to
1f0f20c
Compare
1f0f20c to
74737bd
Compare
Codecov Report
@@ Coverage Diff @@
## main #4315 +/- ##
============================================
- Coverage 84.35% 84.28% -0.08%
- Complexity 3277 3283 +6
============================================
Files 473 472 -1
Lines 10357 10450 +93
Branches 1827 1863 +36
============================================
+ Hits 8737 8808 +71
- Misses 668 671 +3
- Partials 952 971 +19
Continue to review full report at Codecov.
|
74737bd to
ea9eaad
Compare
|
It's difficult to unit test this >_< |
430327f to
627d2c1
Compare
| .use { it.copyTo(outputStream) } | ||
|
|
||
| ExtensionFacade(spec.extensionsSpec).pluginLoader | ||
| .getResourcesAsStream("config/config.yml") |
There was a problem hiding this comment.
Do you think this path config/config.yml should be configurable? If not, we probably need to add documentation in
There was a problem hiding this comment.
I don't think this could be configurable.
We need to document this. But should we document it right now? Or should we wait to release it first? And probably we can create a tool to generate this files from our annotations. The same that we have already for detekt but working for anyone.
There was a problem hiding this comment.
If not configurable, should this be exposed in detekt-api so that other plugin authors could refer to this constant. (the prefixing config/ does look a bit awkward)
627d2c1 to
2684a57
Compare
| public final fun load (Ljava/lang/ClassLoader;)Lio/github/detekt/tooling/api/DefaultConfigurationProvider; | ||
| public static synthetic fun load$default (Lio/github/detekt/tooling/api/DefaultConfigurationProvider$Companion;Ljava/lang/ClassLoader;ILjava/lang/Object;)Lio/github/detekt/tooling/api/DefaultConfigurationProvider; | ||
| public final fun load (Lio/github/detekt/tooling/api/spec/ProcessingSpec;Ljava/lang/ClassLoader;)Lio/github/detekt/tooling/api/DefaultConfigurationProvider; | ||
| public static synthetic fun load$default (Lio/github/detekt/tooling/api/DefaultConfigurationProvider$Companion;Lio/github/detekt/tooling/api/spec/ProcessingSpec;Ljava/lang/ClassLoader;ILjava/lang/Object;)Lio/github/detekt/tooling/api/DefaultConfigurationProvider; |
There was a problem hiding this comment.
I assume that no one is calling this function nor implementing its own DefaultConfigurationProvider. But this change breaks code and binary compatibility. And I don't know how to implement it without this change.
There was a problem hiding this comment.
I think this breaking change is okay if it's highlighted in the changelog.
2684a57 to
b2d6f10
Compare
|
That's great stuff! Can I ask you to update the PR name to something more meaningful as it will be harder to search & understand in the changelog |
You are completely right. |
| public final fun load (Ljava/lang/ClassLoader;)Lio/github/detekt/tooling/api/DefaultConfigurationProvider; | ||
| public static synthetic fun load$default (Lio/github/detekt/tooling/api/DefaultConfigurationProvider$Companion;Ljava/lang/ClassLoader;ILjava/lang/Object;)Lio/github/detekt/tooling/api/DefaultConfigurationProvider; | ||
| public final fun load (Lio/github/detekt/tooling/api/spec/ProcessingSpec;Ljava/lang/ClassLoader;)Lio/github/detekt/tooling/api/DefaultConfigurationProvider; | ||
| public static synthetic fun load$default (Lio/github/detekt/tooling/api/DefaultConfigurationProvider$Companion;Lio/github/detekt/tooling/api/spec/ProcessingSpec;Ljava/lang/ClassLoader;ILjava/lang/Object;)Lio/github/detekt/tooling/api/DefaultConfigurationProvider; |
There was a problem hiding this comment.
I think this breaking change is okay if it's highlighted in the changelog.
Co-authored-by: M Schalk <30376729+schalkms@users.noreply.github.com>
1518949 to
c6b0b1b
Compare
picklebento
left a comment
There was a problem hiding this comment.
Looks good to me overall. Thank you for building this feature!
Co-authored-by: Chao Zhang <zhangchao6865@gmail.com>
|
Great stuff! @BraisGabin can you add a paragraph in the |
|
@cortinico sorry but I don't know where do you want me to write it. |
I meant here: detekt/docs/pages/changelog 1.x.x.md Line 8 in 40efb62 #### UNRELEASED section and start populating the Changelog for 1.20.0).
|
|
Do we happen to have a page in the documentation about this feature? |
|
No, we don't have it. I'll try to write somthing about it. A tool to automate it would be nice too (#4457). |
We should allow that the detekt plugins could contribute with the configuration of it's rules (Slack comment and #3242. There are two places where we should allow this: when the core request the default configuration and when the user request to generare the configuration file.
With this PR if a plugin author adds a configuration file in their resources at the path
config/config.ymldetekt would concat it at the end of the configuration file.This PR doesn't give any support to generate nor keep in sync those configurations files but I think that it should be doable in the future.
Related #3242
Closes #1103