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 regression generating configuration #4646

Merged
merged 5 commits into from Mar 29, 2022
Merged

Fix regression generating configuration #4646

merged 5 commits into from Mar 29, 2022

Conversation

BraisGabin
Copy link
Member

@BraisGabin BraisGabin commented Mar 20, 2022

This is not my nicest job for sure. But now it works and we have a test to ensure that it doesn't break again.

To fix this properly we need to do a huge refactor on the core.

fix #4601

@BraisGabin BraisGabin added this to the 1.20.0 milestone Mar 20, 2022
@codecov
Copy link

codecov bot commented Mar 20, 2022

Codecov Report

Merging #4646 (ddd6ade) into main (481b3b2) will increase coverage by 84.53%.
The diff coverage is 71.42%.

@@             Coverage Diff             @@
##             main    #4646       +/-   ##
===========================================
+ Coverage        0   84.53%   +84.53%     
- Complexity      0     3364     +3364     
===========================================
  Files           0      482      +482     
  Lines           0    11211    +11211     
  Branches        0     2044     +2044     
===========================================
+ Hits            0     9477     +9477     
- Misses          0      698      +698     
- Partials        0     1036     +1036     
Impacted Files Coverage Δ
...otlin/io/gitlab/arturbosch/detekt/cli/CliRunner.kt 7.14% <0.00%> (ø)
...bosch/detekt/core/tooling/DefaultConfigProvider.kt 80.95% <50.00%> (ø)
...rturbosch/detekt/core/settings/ClassloaderAware.kt 63.63% <66.66%> (ø)
...ab/arturbosch/detekt/cli/runners/ConfigExporter.kt 84.61% <85.71%> (ø)
...itlab/arturbosch/detekt/core/ProcessingSettings.kt 100.00% <100.00%> (ø)
...detekt/tooling/api/DefaultConfigurationProvider.kt 100.00% <100.00%> (ø)
...kt/core/config/DefaultPropertiesConfigValidator.kt 100.00% <0.00%> (ø)
...bosch/detekt/rules/style/UnnecessaryInheritance.kt 92.85% <0.00%> (ø)
...ekt/generator/collection/DocumentationCollector.kt 86.36% <0.00%> (ø)
...rturbosch/detekt/rules/bugs/UnusedUnaryOperator.kt 70.83% <0.00%> (ø)
... and 478 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 481b3b2...ddd6ade. Read the comment docs.

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;
public final fun load (Lio/github/detekt/tooling/api/spec/ExtensionsSpec;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/ExtensionsSpec;Ljava/lang/ClassLoader;ILjava/lang/Object;)Lio/github/detekt/tooling/api/DefaultConfigurationProvider;
Copy link
Member Author

Choose a reason for hiding this comment

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

This functions were introduced in 1.20 so it's safe to change them.

@cortinico
Copy link
Member

Could you provide some tests + more context on what this change is doing (it's not immediate from reading the code).

@BraisGabin
Copy link
Member Author

ddd6ade#diff-ea3a27e29a40bcb62f6014e51bfdf793236b1ed156b98170570086a1cff78415 this is the unit test that I added to reproduce the issue. The test wasn't testing the real state. The real state is that the file doesn't exist and that all works. That case was failing before and know it works.

All the fix is in this commit: ddd6ade the other commits are just refactors to make this change easier. I don't know how to add more tests because the tests are already there.


About context. The issue was this line of code that I added in #4315:

val spec = arguments.createSpec(outputPrinter, errorPrinter)

The problem is that arguments.createSpec validates that the configuration is ready to execute detekt. One of those checks is: If there is a configuration file path it should exist. But when you are generating the configuration the file doesn't need to exist. For that reason I can't use arguments.createSpec. That's the reason I'm using the Spec DSL directly. (Yeap, we have a DSL for that, Artur did so many things :P)

@cortinico
Copy link
Member

Thanks for the explanation. IMHO this can be merged 👍

@cortinico cortinico merged commit dd00f22 into main Mar 29, 2022
@cortinico cortinico deleted the fix-4601 branch March 29, 2022 10:37
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.

detektGenerateConfig doesn't work
2 participants