JS: Add TypedExprs metric

This commit is contained in:
Asger Feldthaus
2020-06-01 11:38:39 +01:00
parent 39137510ba
commit 35bdb4127e
3 changed files with 31 additions and 6 deletions

View File

@@ -0,0 +1,11 @@
/**
* Helpers to generating meta metrics, that is, metrics about the CodeQL analysis and extractor.
*/
private import javascript
/**
* Gets the root folder of the snapshot.
*
* This is selected as the location for project-wide metrics.
*/
Folder projectRoot() { result.getRelativePath() = "" }

View File

@@ -10,12 +10,7 @@ private import semmle.javascript.dependencies.FrameworkLibraries
private import semmle.javascript.frameworks.Testing
private import DataFlow
/**
* Gets the root folder of the snapshot.
*
* This is selected as the location for project-wide metrics.
*/
Folder projectRoot() { result.getRelativePath() = "" }
import meta.MetaMetrics
/** A file we ignore because it is a test file or compiled/generated/bundled code. */
class IgnoredFile extends File {

View File

@@ -0,0 +1,19 @@
/**
* @name Typed expressions
* @description The number of expressions for which the TypeScript extractor could
* extract a type other than 'any'.
* @kind metric
* @metricType project
* @metricAggregate sum
* @tags meta
* @id js/meta/typed-expressions
*/
import javascript
import meta.MetaMetrics
predicate isProperType(Type t) {
not t instanceof AnyType
}
select projectRoot(), count(Expr e | isProperType(e.getType()))