Skip to content

Use getter when determining whether custom config path is set in DetektGenerateConfigTask - #5157

Merged
cortinico merged 1 commit into
detekt:mainfrom
3flex:5097-fix
Jul 31, 2022
Merged

cortinico merged 1 commit into
detekt:mainfrom
3flex:5097-fix

Conversation

@3flex

@3flex 3flex commented Jul 31, 2022

Copy link
Copy Markdown
Member

Fixes #5097

Before this change, this task:

tasks.register("customDetektConfig", io.gitlab.arturbosch.detekt.DetektGenerateConfigTask::class) {
    config.setFrom("custom/location.yml")
    doLast {
        logger.warn("Configured path: ${config.asPath}")
    }
}

Would produce this output:

> Task :detekt-api:customDetektConfig
Skipping config file generation; file already exists at C:\<projectPath>\config\detekt\detekt.yml
Configured path: C:\<projectPath>\detekt-api\custom\location.yml

You can see the task was setting the config path and despite what was configured in the build file, the config wasn't being calculated correctly by the task.

With this PR, it will successfully generate the file:

> Task :detekt-api:customDetektConfig
Successfully copied default config to C:\<projectPath>\detekt-api\custom\location.yml
Configured path: C:\<projectPath>\detekt-api\custom\location.yml

And subsequent invocations will product the expected output:

> Task :detekt-api:customDetektConfig
Skipping config file generation; file already exists at C:\<projectPath>\detekt-api\custom\location.yml
Configured path: C:\<projectPath>\detekt-api\custom\location.yml

@cortinico cortinico added this to the 1.22.0 milestone Jul 31, 2022
@cortinico
cortinico merged commit 9b5e12a into detekt:main Jul 31, 2022
@3flex
3flex deleted the 5097-fix branch July 31, 2022 11:28

This branch was successfully deployed

1 active deployment
Preview — fbc9fc0e Deployed Jul 31, 2022 by vercel[bot]
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.

DetektGenerateConfigTask does not respect custom config locations in 1.21.0

4 participants