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

Gradle plugin: Set default path for "config" parameter #1801

Merged
merged 6 commits into from
Aug 4, 2019

Conversation

3flex
Copy link
Member

@3flex 3flex commented Aug 3, 2019

This PR:

  • Enhances CLI to allow creation of the default config file at a path of the user's choice on the CLI
  • Uses that feature in the Gradle plugin to generate the config file at rootDir/config/detekt/detekt.yml by default (to match conventions in other Gradle plugins)
  • Sets that path as the default config path if a file exists at that location
  • Moves some of detekt's config files to match the new convention

Closes #1262

@schalkms
Copy link
Member

schalkms commented Aug 3, 2019

LargeClass - 832/600 - [UnusedPrivateMemberSpec] at /home/travis/build/arturbosch/detekt/detekt-rules/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/UnusedPrivateMemberSpec.kt:12:1

That's interesting, since you didn't touch the UnusedPrivateMemberSpec class.
Something seems to be wrong here.

Copy link
Member

@schalkms schalkms left a comment

Choose a reason for hiding this comment

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

For me, this PR looks fine. Let's wait for Artur's opinion.

Copy link
Member

@arturbosch arturbosch left a comment

Choose a reason for hiding this comment

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

Looks good, I like the "only look at root/config/detekt" approach without trying to figure out sub projects config.

@arturbosch arturbosch added this to the 1.0.0 milestone Aug 3, 2019
InputArgument(source)
)

DetektInvoker.create(project).invokeCli(arguments.toList(), detektClasspath, name)
if (config.first().exists()) {
Copy link
Member

Choose a reason for hiding this comment

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

Can first() here crash when project.files(...) is empty or null?

Copy link
Member Author

Choose a reason for hiding this comment

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

Very literally yes, it would fail when project files is empty. But that won't happen as the value is set a couple lines earlier and doesn't rely on external input.

That said I'll make a new ConfigArgument that accepts a single file instead of a collection to clean it up.

Copy link
Member Author

Choose a reason for hiding this comment

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

It was a bit awkward to deal with a new ConfigArgument variant, so thought it's clearer to add error handling in the task itself.

To be clear this should never happen.

@arturbosch arturbosch merged commit acf2e3b into detekt:master Aug 4, 2019
@3flex 3flex deleted the 1262-fix branch August 4, 2019 22:57
smyachenkov pushed a commit to smyachenkov/detekt that referenced this pull request Dec 9, 2019
* Generate default config at user-specified path

* Set a default path for detekt's config file

* Write default config file to default config path

* Update config to use new config layout convention

* Update baseline file location

* Catch possible error if `config` collection is not expected size
smyachenkov pushed a commit to smyachenkov/detekt that referenced this pull request Dec 9, 2019
* Generate default config at user-specified path

* Set a default path for detekt's config file

* Write default config file to default config path

* Update config to use new config layout convention

* Update baseline file location

* Catch possible error if `config` collection is not expected size
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

Successfully merging this pull request may close these issues.

Default Gradle config path should be config/detekt/config.yml
3 participants