rb/summary/lines-of-user-code

This commit is contained in:
Alex Ford
2021-05-04 21:03:55 +01:00
parent f6c8b07f4f
commit 98a4f4c5b9
2 changed files with 20 additions and 0 deletions

View File

@@ -190,4 +190,7 @@ class File extends Container, @file {
/** Gets the number of lines of comments in this file. */
int getNumberOfLinesOfComments() { result = count(int line | this.line(line, true)) }
/** Holds if this file was extracted from ordinary source code. */
predicate fromSource() { files(this, _, _, _, 1) }
}

View File

@@ -0,0 +1,17 @@
/**
* @id rb/summary/lines-of-user-code
* @name Lines of authored Ruby code in the database
* @description The total number of lines of Ruby code across files, excluding library and generated code.
* @kind metric
* @tags summary
*/
import ruby
select sum(File f |
f.fromSource() and
exists(f.getRelativePath()) and
not f.getAbsolutePath().matches("%/vendor/%")
|
f.getNumberOfLinesOfCode()
)