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

Kotlinter 3.12.0 complains about disabled_rules and lints stuff in generated-sources #288

Closed
henrik242 opened this issue Oct 13, 2022 · 9 comments

Comments

@henrik242
Copy link

henrik242 commented Oct 13, 2022

Tried updating to 3.12.0, but I'm not able to get rid of these:

Property 'disabled_rules' is deprecated: Rename property 'disabled_rules' to 'ktlint_disabled_rules' in all '.editorconfig' files.
[repeated maaany times]
Property 'disabled_rules' is deprecated: Rename property 'disabled_rules' to 'ktlint_disabled_rules' in all '.editorconfig' files.
/Users/foo/src/bar-app/buildSrc/build/generated-sources/kotlin-dsl-accessors/kotlin/gradle/kotlin/dsl/accessors/_33a194716742ed17c4f8baa5f74fe207/TestRuntimeOnlyDependenciesMetadataConfigurationAccessors.kt:27:18: Lint error > [trailing-comma-on-call-site] Missing trailing comma before ")"
Property 'disabled_rules' is deprecated: Rename property 'disabled_rules' to 'ktlint_disabled_rules' in all '.editorconfig' files.
[repeated maaany times]
Property 'disabled_rules' is deprecated: Rename property 'disabled_rules' to 'ktlint_disabled_rules' in all '.editorconfig' files.
/Users/foo/src/bar-app/buildSrc/build/generated-sources/kotlin-dsl-accessors/kotlin/gradle/kotlin/dsl/accessors/_33a194716742ed17c4f8baa5f74fe207/Accessorsbjzfxoa3vns0zfsjg3ibeiv28.kt:27:18: Lint error > [trailing-comma-on-call-site] Missing trailing comma before ")"
Property 'disabled_rules' is deprecated: Rename property 'disabled_rules' to 'ktlint_disabled_rules' in all '.editorconfig' files.
[many more repeats and many more classes in generated-sources follows]

I have renamed disabled_rules to ktlint_disabled_rules.

@mateuszkwiecinski
Copy link
Contributor

Just to confirm: you're running the ./gradlew lintKotlin task, right?
Can you try with ./gradlew --stop before running ./gradlew lintKotlin, to confirm nothing got cached? (I want to make sure I didn't miss any scenario in #265)

@henrik242
Copy link
Author

Just to confirm: you're running the ./gradlew lintKotlin task, right?

Yup!

Can you try with ./gradlew --stop before running ./gradlew lintKotlin, to confirm nothing got cached?

Thanks, that fixed the Property 'disabled_rules' is deprecated messages. It's still trying to lint stuff in generated-sources though.

@mateuszkwiecinski
Copy link
Contributor

It's still trying to lint stuff in generated-sources though.

Can you share which plugin generates files under generated-sources? And which task tries to run them over generated files.

btw. you can manually configure Kotlinter to exclude generated files (in a slightly confusing way 😬) - I can link a similar issue which lists couple of examples how to exclude generated files: #256

@henrik242
Copy link
Author

Can you share which plugin generates files under generated-sources?

It seems like the kotlin-dsl itself. Not 100% sure though.

btw. you can manually configure Kotlinter to exclude generated files

Could do that, but weird that this isn't a problem in 3.10.x

@mateuszkwiecinski
Copy link
Contributor

mateuszkwiecinski commented Oct 13, 2022

It seems like the kotlin-dsl itself.

I'm fairly sure kotlin-dsl doesn't generate any sources 👀

Could do that, but weird that this isn't a problem in 3.10.x

Huh, I don't recall any changes around recognizing sourcesets 🤔 I'd rather guess ktlint was invoked against generated sources, but it simply didn't find any issues. Could that be the case?
I'd love to see a sample project that reproduces the scenario you describe 👀

@mateuszkwiecinski
Copy link
Contributor

I'm going to close the issue for now, I hope nobody will mind that - There is nothing we can change on the plugin side as for this moment, I shared the workaround that skips linting generated source (#256), and we'll need a repro project before we can investigate the issue any further 👀

@mateuszkwiecinski mateuszkwiecinski closed this as not planned Won't fix, can't repro, duplicate, stale Oct 21, 2022
@henrik242
Copy link
Author

henrik242 commented Jan 2, 2023

Hi, sorry for the late reply. Somehow I'm still having problems with the generated sources, even with the exclude from #265

$ ./gradlew --stop
Stopping Daemon(s)
1 Daemon stopped
Finished at man  2 jan 2023 14:00:31 CET

$ ./gradlew lintKotlin --no-configuration-cache --rerun-tasks
Starting a Gradle Daemon, 6 stopped Daemons could not be reused, use --status for details
Type-safe project accessors is an incubating feature.

> Configure project :buildSrc
WARNING: Unsupported Kotlin plugin version.
The `embedded-kotlin` and `kotlin-dsl` plugins rely on features of Kotlin `1.7.10` that might work differently than in the requested version `1.8.0`.

> Task :buildSrc:lintKotlinMain
/Users/foo/src/finn/foo-app2/buildSrc/build/generated-sources/kotlin-dsl-external-plugin-spec-builders/kotlin/gradle/kotlin/dsl/plugins/_50c5e4b1076861bcabac21b03c0c99c5/PluginSpecBuilders.kt:26:18: Lint error > [trailing-comma-on-call-site] Missing trailing comma before ")"
/Users/foo/src/finn/foo-app2/buildSrc/build/generated-sources/kotlin-dsl-accessors/kotlin/gradle/kotlin/dsl/accessors/_fd918eead956bdac562d69dc00a276db/Accessors9osmdt78klrrxidc9srcw3tsq.kt:27:18: Lint error > [trailing-comma-on-call-site] Missing trailing comma before ")"
...

I'm on kotlin 1.8 and kotlinter 3.13.0. (The results are the same on kotlin 1.7.x)

@mateuszkwiecinski
Copy link
Contributor

@henrik242 Can you share how did you apply kotlinter to your buildSrc project? And post the config that suppose to exclude generated files? Ideally, a standalone repro project, would help a lot 👀

@henrik242
Copy link
Author

henrik242 commented Feb 13, 2023

Regarding the generated-sources problem. Adding this helped:

tasks.withType<org.jmailen.gradle.kotlinter.tasks.ConfigurableKtLintTask>().configureEach {
        exclude { it.file.path.contains("build") }
    }

(idea from JLLeitschuh/ktlint-gradle#266 (comment))

I first tried exclude("**/build/**"), but that didn't work.

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

No branches or pull requests

2 participants