consider empty files (no ruby tokens) to have 0 lines

This commit is contained in:
Alex Ford
2021-04-21 11:29:55 +01:00
parent a8597025aa
commit 4e119cc085

View File

@@ -183,7 +183,11 @@ class File extends Container, @file {
}
/** Gets the number of lines in this file. */
int getNumberOfLines() { result = max(this.getAToken().getLocation().getEndLine()) }
int getNumberOfLines() {
if exists(this.getAToken())
then result = max(this.getAToken().getLocation().getEndLine())
else result = 0
}
/** Gets the number of lines of code in this file. */
int getNumberOfLinesOfCode() { result = count(int line | this.line(line, false)) }