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

1.13.0 changes to detektGenerateConfig #3065

Closed
Tolriq opened this issue Sep 11, 2020 · 5 comments
Closed

1.13.0 changes to detektGenerateConfig #3065

Tolriq opened this issue Sep 11, 2020 · 5 comments
Assignees
Milestone

Comments

@Tolriq
Copy link

Tolriq commented Sep 11, 2020

Expected Behavior

Now detektGenerateConfig tries to create the configuration on the configured path.
This change is strange because:

  • If the file exist the task refuse to create / update the file as already present
  • If the file does not exist the task does not run either as the file is missing

detektGenerateConfig ignores detekt.config paramenter - #2565

The task should not take in account this parameter and eventually there should be a new parameter that allows to define default configuration location.

Currently we can no more generate default configuration and see what new options have been added / changed.

@arturbosch arturbosch self-assigned this Sep 25, 2020
@arturbosch
Copy link
Member

I couldn't reproduce this.
The file gets generated for me.
A problem exist with multi project gradle builds where only the first subproject generates the file but all sub projects reference it.

@Tolriq
Copy link
Author

Tolriq commented Sep 26, 2020

Yes the second issue was due to 1.13 publishing problem.

The problem of using the configured production path and not a default configuration path is that once you are in production you can't generate a new config to see what have changed between releases to update the production configuration.

Having a different file allows to keep both in git, see the diff apply what we want to production file. Now since the production file exist you can't generate a new file. If we delete the production file we can generate the new default but you can't diff since the diff is irrelevant to detekt version update but takes in account previous production file.

There should be 2 different files for default and production configuration using the same config value for both brings a lot of issues without really solving anything.

@arturbosch
Copy link
Member

arturbosch commented Sep 27, 2020

You can create a new task based on our task for a diff config:

import io.gitlab.arturbosch.detekt.DetektGenerateConfigTask

val createDetektConfigForDiff by tasks.registering(DetektGenerateConfigTask::class) {
    description = ""
    config.setFrom(buildDir.resolve("detekt-diff.yaml"))

    doFirst {
      // optionally delete the old config diff file first 
    }
}

Does this work for your use case?

@Tolriq
Copy link
Author

Tolriq commented Sep 27, 2020

Yes works perfectly, did not thought it would be so easy 👍 Thanks.

Maybe worth some kind of recipes for others as this sounds like a normal need to know what changes between version and easily update config;

@Tolriq Tolriq closed this as completed Sep 27, 2020
@arturbosch
Copy link
Member

Yes works perfectly, did not thought it would be so easy Thanks.

Maybe worth some kind of recipes for others as this sounds like a normal need to know what changes between version and easily update config;

Thanks for the suggestion!
Will post it under https://detekt.github.io/detekt/news.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants