mirror of
https://github.com/github/codeql.git
synced 2026-04-30 11:15:13 +02:00
JS: Move IgnoredFile to MetaMetrics
This commit is contained in:
@@ -2,6 +2,9 @@
|
||||
* Helpers to generating meta metrics, that is, metrics about the CodeQL analysis and extractor.
|
||||
*/
|
||||
private import javascript
|
||||
private import semmle.javascript.dependencies.Dependencies
|
||||
private import semmle.javascript.dependencies.FrameworkLibraries
|
||||
private import semmle.javascript.frameworks.Testing
|
||||
|
||||
/**
|
||||
* Gets the root folder of the snapshot.
|
||||
@@ -9,3 +12,20 @@ private import javascript
|
||||
* This is selected as the location for project-wide metrics.
|
||||
*/
|
||||
Folder projectRoot() { result.getRelativePath() = "" }
|
||||
|
||||
/** A file we ignore because it is a test file or compiled/generated/bundled code. */
|
||||
class IgnoredFile extends File {
|
||||
IgnoredFile() {
|
||||
any(Test t).getFile() = this
|
||||
or
|
||||
getRelativePath().regexpMatch("(?i).*/test(case)?s?/.*")
|
||||
or
|
||||
getBaseName().regexpMatch("(?i)(.*[._\\-]|^)(min|bundle|concat|spec|tests?)\\.[a-zA-Z]+")
|
||||
or
|
||||
exists(TopLevel tl | tl.getFile() = this |
|
||||
tl.isExterns()
|
||||
or
|
||||
tl instanceof FrameworkLibraryInstance
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,23 +12,6 @@ private import DataFlow
|
||||
|
||||
import meta.MetaMetrics
|
||||
|
||||
/** A file we ignore because it is a test file or compiled/generated/bundled code. */
|
||||
class IgnoredFile extends File {
|
||||
IgnoredFile() {
|
||||
any(Test t).getFile() = this
|
||||
or
|
||||
getRelativePath().regexpMatch("(?i).*/test(case)?s?/.*")
|
||||
or
|
||||
getBaseName().regexpMatch("(?i)(.*[._\\-]|^)(min|bundle|concat|spec|tests?)\\.[a-zA-Z]+")
|
||||
or
|
||||
exists(TopLevel tl | tl.getFile() = this |
|
||||
tl.isExterns()
|
||||
or
|
||||
tl instanceof FrameworkLibraryInstance
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
/** An call site that is relevant for analysis quality. */
|
||||
class RelevantInvoke extends InvokeNode {
|
||||
RelevantInvoke() { not getFile() instanceof IgnoredFile }
|
||||
|
||||
Reference in New Issue
Block a user