Cannot exclude generated code
See original GitHub issueWe are using the jooq gradle plugin to generate some kotlin code (https://github.com/etiennestuder/gradle-jooq-plugin) Obviously I would like to exclude this code from ktlint. Code gets generated in <project>/build/generated-src It seems this is impossible. Here is the attempt I made:
ktlint {
version = libs.versions.ktlint.get()
debug = true
verbose = true
filter {
include { element ->
println(element.file.path)
println(!element.file.path.contains("generated-src"))
!element.file.path.contains("generated-src")
}
exclude { element ->
println(element.file.path)
println(element.file.path.contains("generated-src"))
element.file.path.contains("generated-src")
}
}
}
With the above kode ktlint still fails on the generated code.
Issue Analytics
- State:
- Created 2 years ago
- Reactions:2
- Comments:6 (1 by maintainers)
Top Results From Across the Web
To exclude the generated code from sonar analysis on Quality ...
I have been trying several option but in vain please help. <properties> <sonar.exclusions>**/generatedsources/fod1/fod2/**/*.java</sonar ...
Read more >ReSharper - Configure code inspection settings - JetBrains
Exclude specific files and folders from code inspection · Select ReSharper | Options from the main menu or press Alt+R O , then...
Read more >Configure code analysis rules - .NET - Microsoft Learn
Exclude generated code .NET code analyzer warnings aren't useful on generated code files, such as designer-generated files, which users can't ...
Read more >Exclusions from Jacoco Report - Baeldung
Generally, the candidates for exclusion can be configuration classes, POJOs, DTOs, as well as generated byte code.
Read more >Exclude java warnings in generated code - Genuitec
This code is generated in its own package, so I tried to exclude that from validation. The warnings don't go away. It seems...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Here is how I got it to work:
I have a similar setup with a
generated-src
directory and for the life of me I could not make the plugin exclude that directory.However, I found that if I:
rm -rf .gradle
and then./gradlew ktlintCheck
the exclusions worked just fine. This suggests to me that the plugin is simply re-runningktlint
on the same files it failed on previously without re-applying the exclude filter.Seems like a legit bug.