Skip to content

Commit 98a4f4c

Browse files
committed
rb/summary/lines-of-user-code
1 parent f6c8b07 commit 98a4f4c

2 files changed

Lines changed: 20 additions & 0 deletions

File tree

ql/src/codeql/files/FileSystem.qll

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,4 +190,7 @@ class File extends Container, @file {
190190

191191
/** Gets the number of lines of comments in this file. */
192192
int getNumberOfLinesOfComments() { result = count(int line | this.line(line, true)) }
193+
194+
/** Holds if this file was extracted from ordinary source code. */
195+
predicate fromSource() { files(this, _, _, _, 1) }
193196
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/**
2+
* @id rb/summary/lines-of-user-code
3+
* @name Lines of authored Ruby code in the database
4+
* @description The total number of lines of Ruby code across files, excluding library and generated code.
5+
* @kind metric
6+
* @tags summary
7+
*/
8+
9+
import ruby
10+
11+
select sum(File f |
12+
f.fromSource() and
13+
exists(f.getRelativePath()) and
14+
not f.getAbsolutePath().matches("%/vendor/%")
15+
|
16+
f.getNumberOfLinesOfCode()
17+
)

0 commit comments

Comments
 (0)