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 errors with detektGenerateConfig #5199

Merged
merged 3 commits into from Aug 8, 2022
Merged

Fix errors with detektGenerateConfig #5199

merged 3 commits into from Aug 8, 2022

Conversation

BraisGabin
Copy link
Member

@BraisGabin BraisGabin commented Aug 7, 2022

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
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
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
3 participants