-
Notifications
You must be signed in to change notification settings - Fork 62
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
Add exclusion filter for directories #1828
base: main
Are you sure you want to change the base?
Conversation
...nguage-python/src/test/kotlin/de/fraunhofer/aisec/cpg/frontends/python/PythonFrontendTest.kt
Outdated
Show resolved
Hide resolved
@@ -146,6 +146,13 @@ private constructor( | |||
|
|||
var sourceLocations: List<File> = ctx.config.softwareComponents[sc] ?: listOf() | |||
|
|||
sourceLocations = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is not enough, I think you need to move the exclusion handling down to the file walk (or after the walk), because at this point here the locations are not "expanded". For example, if I set the source location "mypackage", which has a "tests" folder in it. In this case the exclusion filter filters based on mypackage, but not on mypackage/tests which is only expanded about 10 lines down.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
cpg-core/src/main/kotlin/de/fraunhofer/aisec/cpg/TranslationConfiguration.kt
Show resolved
Hide resolved
* exclusionPatterns(listOf(Regex(".*test(s)?"))) | ||
* ``` | ||
*/ | ||
fun exclusionPatternsByRegex(patterns: List<Regex>): Builder { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure if we should use two overloaded functions, e.g. “exclusionPatterns” or separate as here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can overload them.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done. As far as I unterstand, the JvmName
annotation is required because the two functions only differ by a generic parameter and the JVM erases that parameter during compilation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we have varargs instead of a list? Then they should be different and varargs might be nice to work with
This PR adds the possibility to exclude folders or files from the analysis. Specifically, it should be possible to filter either by
strings
or byregex
.