Skip to content

Commit 63d48bf

Browse files
committed
JS: Move IgnoredFile to MetaMetrics
1 parent 35bdb41 commit 63d48bf

File tree

2 files changed

+20
-17
lines changed

2 files changed

+20
-17
lines changed

javascript/ql/src/meta/MetaMetrics.qll

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,30 @@
22
* Helpers to generating meta metrics, that is, metrics about the CodeQL analysis and extractor.
33
*/
44
private import javascript
5+
private import semmle.javascript.dependencies.Dependencies
6+
private import semmle.javascript.dependencies.FrameworkLibraries
7+
private import semmle.javascript.frameworks.Testing
58

69
/**
710
* Gets the root folder of the snapshot.
811
*
912
* This is selected as the location for project-wide metrics.
1013
*/
1114
Folder projectRoot() { result.getRelativePath() = "" }
15+
16+
/** A file we ignore because it is a test file or compiled/generated/bundled code. */
17+
class IgnoredFile extends File {
18+
IgnoredFile() {
19+
any(Test t).getFile() = this
20+
or
21+
getRelativePath().regexpMatch("(?i).*/test(case)?s?/.*")
22+
or
23+
getBaseName().regexpMatch("(?i)(.*[._\\-]|^)(min|bundle|concat|spec|tests?)\\.[a-zA-Z]+")
24+
or
25+
exists(TopLevel tl | tl.getFile() = this |
26+
tl.isExterns()
27+
or
28+
tl instanceof FrameworkLibraryInstance
29+
)
30+
}
31+
}

javascript/ql/src/meta/analysis-quality/CallGraphQuality.qll

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -12,23 +12,6 @@ private import DataFlow
1212

1313
import meta.MetaMetrics
1414

15-
/** A file we ignore because it is a test file or compiled/generated/bundled code. */
16-
class IgnoredFile extends File {
17-
IgnoredFile() {
18-
any(Test t).getFile() = this
19-
or
20-
getRelativePath().regexpMatch("(?i).*/test(case)?s?/.*")
21-
or
22-
getBaseName().regexpMatch("(?i)(.*[._\\-]|^)(min|bundle|concat|spec|tests?)\\.[a-zA-Z]+")
23-
or
24-
exists(TopLevel tl | tl.getFile() = this |
25-
tl.isExterns()
26-
or
27-
tl instanceof FrameworkLibraryInstance
28-
)
29-
}
30-
}
31-
3215
/** An call site that is relevant for analysis quality. */
3316
class RelevantInvoke extends InvokeNode {
3417
RelevantInvoke() { not getFile() instanceof IgnoredFile }

0 commit comments

Comments
 (0)