Skip to content

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

Description

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.

Activity

  1. Goooler commented on Aug 23, 2023

    @Goooler
    Member

    It works, see Goooler/AndroidOAuth2WebView#36.

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

  2. daniel-lopes-optimizely commented on Aug 23, 2023

    @daniel-lopes-optimizely
    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.

  3. Goooler commented on Aug 23, 2023

    @Goooler
    Member

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

  4. daniel-lopes-optimizely commented on Aug 23, 2023

    @daniel-lopes-optimizely
    Author

    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?

  5. Goooler commented on Aug 23, 2023

    @Goooler
    Member

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

  6. daniel-lopes-optimizely commented on Aug 23, 2023

    @daniel-lopes-optimizely
    Author

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

  7. Goooler commented on Aug 23, 2023

    @Goooler
    Member

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

    I believe this is reasonable.

    @nedtwigg WDYT?

  8. daniel-lopes-optimizely commented on Aug 23, 2023

    @daniel-lopes-optimizely
    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.

  9. daniel-lopes-optimizely commented on Aug 23, 2023

    @daniel-lopes-optimizely
    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.

  10. added a commit that references this issue on Aug 24, 2023
    5976175
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions