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

ktlint_standard_enum-entry-name-case = disabled does not work on .editorconfig #1785

Closed
daniel-lopes-optimizely opened this issue Aug 21, 2023 · 9 comments · Fixed by #1788
Closed

Comments

@daniel-lopes-optimizely
Copy link

daniel-lopes-optimizely commented Aug 21, 2023

The .editorconfig file

[*.{kt,kts}]
indent_style = space
indent_size = 4
ktlint_standard_no-wildcard-imports = disabled # works
ktlint_standard_filename = disabled # works
ktlint_standard_enum-entry-name-case = disabled # doesnt work

The error:

Error on line: 209, column: 4
rule: standard:enum-entry-name-case
Enum entry name should be uppercase underscore-separated names like "ENUM_ENTRY" or upper camel-case like "EnumEntry"

The gradle.kts

plugins {
        id("com.diffplug.spotless") version "6.20.0"
    }
...
spotless {
    kotlin {
        ktlint("0.50.0").setEditorConfigPath("$projectDir/../.editorconfig")
    }
}

Is this something you can help me figure out? I'm using the latest spotless gradle plugin, but I think this is related to ktlint. Let me know if I have to take this to the ktlint devs instead.

@Goooler
Copy link
Contributor

Goooler commented Aug 23, 2023

It works, see Goooler/AndroidOAuth2WebView#36.

I guess the issue is what you are using "$projectDir/../.editorconfig" to override file path.

@daniel-lopes-optimizely
Copy link
Author

The file path needs to be overridden because the project is a submodule of a bigger project.
The plugin fails if it can't find the file in the config path:

Could not determine the dependencies of task ':spotlessApply'.
> Could not create task ':spotlessKotlinApply'.
   > Could not create task ':spotlessKotlin'.
      > File signature can only be created for existing regular files, given: .../looker-sdk-codegen/.blablah

Plus, the other settings I have in the .editorconfig file seem to work fine.

@Goooler
Copy link
Contributor

Goooler commented Aug 23, 2023

You can use "$projectDir.parent/.editorconfig" here.

@daniel-lopes-optimizely
Copy link
Author

daniel-lopes-optimizely commented Aug 23, 2023

I'm getting odd behavior, and I'm not sure what happened but none of the settings work now.

I tried the path that you provided and tried the old one. There's no errors about the file not being found, but it does not seem to matter and it fails the validation.

What worked though was copying the .editconfig to the project directory and removing the setEditorConfigPath.
But I can't do that, not without telling the project maintainers that I now have to have two distinct .editorconfig files and that editor config path setting should work, right?

@Goooler
Copy link
Contributor

Goooler commented Aug 23, 2023

Overriing .editorconfig works, I just tried with a simular case in Goooler/AndroidOAuth2WebView#36, I guess you are still setting a wrong path.

@daniel-lopes-optimizely
Copy link
Author

Shouldn't the plugin fail if the file isn't found?

@Goooler
Copy link
Contributor

Goooler commented Aug 23, 2023

Shouldn't the plugin fail if the file isn't found?

I believe this is reasonable.

@nedtwigg WDYT?

@daniel-lopes-optimizely
Copy link
Author

If I change the file name or path I get an error.
The current behaviour ignores the file content if it's not in the root directory.

@daniel-lopes-optimizely
Copy link
Author

I fixed this by deleting the .gradle and build directories. Not sure why I had to do this, but spotlessApply is working fine after that.

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 a pull request may close this issue.

2 participants