Skip to content

Commit 0c724a8

Browse files
authored
Merge pull request github#5304 from asgerf/js/non-alert-data
JS: Implement new metric queries for line counting
2 parents 073a43c + 405c1f3 commit 0c724a8

File tree

8 files changed

+43
-0
lines changed

8 files changed

+43
-0
lines changed
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
/**
2+
* @id js/summary/lines-of-code
3+
* @name Total lines of JavaScript and TypeScript code in the database
4+
* @description The total number of lines of JavaScript or TypeScript code across all files checked into the repository, except in `node_modules`. This is a useful metric of the size of a database. For all files that were seen during extraction, this query counts the lines of code, excluding whitespace or comments.
5+
* @kind metric
6+
* @tags summary
7+
*/
8+
9+
import javascript
10+
11+
select sum(File f | not f.getATopLevel().isExterns() | f.getNumberOfLinesOfCode())
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
| 12 |
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Summary/LinesOfCode.ql
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
rules:
2+
semi: error
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
/**
2+
* @externs
3+
*/
4+
5+
// Should not be counted
6+
7+
function Object() {}
8+
function String() {}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
function foo(x) {
2+
return x;
3+
}
4+
5+
function bar(y) {
6+
return y;
7+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"private": true,
3+
"devDependencies": {
4+
"typescript": "*"
5+
}
6+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
export interface Foo {
2+
x: number;
3+
}
4+
5+
export function getX(f: Foo) {
6+
return f.x;
7+
}

0 commit comments

Comments
 (0)