From 7bfc61789de78541999d5c8a57e33c5741d8203d Mon Sep 17 00:00:00 2001 From: Alex Ford Date: Mon, 19 Apr 2021 18:08:01 +0100 Subject: [PATCH] line count MetricFile predicates --- ql/src/codeql/files/FileSystem.qll | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/ql/src/codeql/files/FileSystem.qll b/ql/src/codeql/files/FileSystem.qll index 8223fd67ec7..91f52ca064c 100644 --- a/ql/src/codeql/files/FileSystem.qll +++ b/ql/src/codeql/files/FileSystem.qll @@ -165,4 +165,19 @@ class File extends Container, @file { /** Gets the URL of this file. */ override string getURL() { result = "file://" + this.getAbsolutePath() + ":0:0:0:0" } + + /** Gets the metric file. */ + MetricFile getMetrics() { result = this } } + +/** A wrapper providing metrics for a file */ +class MetricFile extends File { + /** Gets the number of lines in this file. */ + int getNumberOfLines() { numlines(this, result, _, _) } + + /** Gets the number of lines of code in this file. */ + int getNumberOfLinesOfCode() { numlines(this, _, result, _) } + + /** Gets the number of lines of comments in this file. */ + int getNumberOfLinesOfComments() { numlines(this, _, _, result) } +} \ No newline at end of file