mirror of
https://github.com/github/codeql.git
synced 2026-05-01 03:35:13 +02:00
JS: Add TypedExprs metric
This commit is contained in:
11
javascript/ql/src/meta/MetaMetrics.qll
Normal file
11
javascript/ql/src/meta/MetaMetrics.qll
Normal 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() = "" }
|
||||
@@ -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 {
|
||||
|
||||
19
javascript/ql/src/meta/types/TypedExprs.ql
Normal file
19
javascript/ql/src/meta/types/TypedExprs.ql
Normal 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()))
|
||||
Reference in New Issue
Block a user