Skip to content

Fix errors with detektGenerateConfig - #5199

Merged
schalkms merged 3 commits into
mainfrom
fix-4843
Aug 8, 2022
Merged

Fix errors with detektGenerateConfig#5199
schalkms merged 3 commits into
mainfrom
fix-4843

Conversation

@BraisGabin

@BraisGabin BraisGabin commented Aug 7, 2022

Copy link
Copy Markdown
Member

I recomment to read #4843 to understand all the context for this solution.

TL;DR detektGenerateConfig runs in a race condition and tries to create the same file multiple times and crashes. With this solution we ansure that this task is always run in serial to avoid it.

This PR also have 2 commits with little refactors over DetektGenerateConfigTask. I didn't want to fall into the rabbit hole so I didn't refactor anymore. But if someone wants: It seems that we are doing more work than needed here. The providers and properties are executed multiple times without, I think, a good reason.

Fixes #4843

Comment on lines +47 to 53
private val configurationToUse: File
get() = if (config.isEmpty) {
objects.fileCollection().from(defaultConfigPath)
defaultConfigPath.toFile()
} else {
config
config.last()
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Just to confirm that these changes are mainly for refactoring.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Yes

@schalkms schalkms added this to the 1.22.0 milestone Aug 8, 2022
@schalkms
schalkms merged commit 5f3ad3e into main Aug 8, 2022
@schalkms
schalkms deleted the fix-4843 branch August 8, 2022 08:24
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 fails

4 participants