Skip to content

Commit 35bdb41

Browse files
committed
JS: Add TypedExprs metric
1 parent 3913751 commit 35bdb41

File tree

3 files changed

+31
-6
lines changed

3 files changed

+31
-6
lines changed
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
/**
2+
* Helpers to generating meta metrics, that is, metrics about the CodeQL analysis and extractor.
3+
*/
4+
private import javascript
5+
6+
/**
7+
* Gets the root folder of the snapshot.
8+
*
9+
* This is selected as the location for project-wide metrics.
10+
*/
11+
Folder projectRoot() { result.getRelativePath() = "" }

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

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,7 @@ private import semmle.javascript.dependencies.FrameworkLibraries
1010
private import semmle.javascript.frameworks.Testing
1111
private import DataFlow
1212

13-
/**
14-
* Gets the root folder of the snapshot.
15-
*
16-
* This is selected as the location for project-wide metrics.
17-
*/
18-
Folder projectRoot() { result.getRelativePath() = "" }
13+
import meta.MetaMetrics
1914

2015
/** A file we ignore because it is a test file or compiled/generated/bundled code. */
2116
class IgnoredFile extends File {
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/**
2+
* @name Typed expressions
3+
* @description The number of expressions for which the TypeScript extractor could
4+
* extract a type other than 'any'.
5+
* @kind metric
6+
* @metricType project
7+
* @metricAggregate sum
8+
* @tags meta
9+
* @id js/meta/typed-expressions
10+
*/
11+
12+
import javascript
13+
import meta.MetaMetrics
14+
15+
predicate isProperType(Type t) {
16+
not t instanceof AnyType
17+
}
18+
19+
select projectRoot(), count(Expr e | isProperType(e.getType()))

0 commit comments

Comments
 (0)