How to exclude generated sources from Inspection?
已回答
We are using a code generator to create REST controllers from openapi yaml files.
Generated code is in build/generated-sources
and added to the gradle build like this:
def generatedSrcDir = layout.buildDirectory.dir("generated-sources").get().asFile
def openApiGeneratedSrcDir = "$generatedSrcDir/openapi"
sourceSets {
main {
java {
srcDir openApiGeneratedSrcDir
}
}
}
When I use “Inspect Code” to run inspections, I get a lot of errors in generated code.
I tried to create a custom Scope, but failed so far:
Started with pattern src:*..*
which results in “Scope contains 164 of total 51,535 files”.
Now, how do I extend this pattern to exclude everything under build/generated-sources
?
In the scope editor window (Settings → Appearance & Behavior → Scopes") I don't even see any build
directory.
Also, no variation of this pattern works: src:*..*&&!file:generated-sources//*
(still finds all 164 source files).
请先登录再写评论。
Please vote on this known issue:
https://youtrack.jetbrains.com/issue/KTIJ-501/Inspect-code-false-positive-inspection-error-is-reported-in-excluded-auto-generated-extensions-for-Gradle-API