From 4eedeb8c01eb478ef0015de0a46849d781766114 Mon Sep 17 00:00:00 2001 From: Evgeny Mandrikov Date: Thu, 9 Feb 2012 00:07:24 +0400 Subject: SONAR-3210 Compute new measure for Java files - LoC in file --- sonar-squid/src/main/java/org/sonar/squid/text/Source.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'sonar-squid') diff --git a/sonar-squid/src/main/java/org/sonar/squid/text/Source.java b/sonar-squid/src/main/java/org/sonar/squid/text/Source.java index 7b29770f87d..f7a7339e55f 100644 --- a/sonar-squid/src/main/java/org/sonar/squid/text/Source.java +++ b/sonar-squid/src/main/java/org/sonar/squid/text/Source.java @@ -19,6 +19,7 @@ */ package org.sonar.squid.text; +import com.google.common.annotations.Beta; import org.sonar.squid.measures.Metric; import org.sonar.squid.recognizer.CodeRecognizer; @@ -107,6 +108,9 @@ public class Source { return getMeasure(metric, 1, lines.size()); } + /** + * Numbering of lines starts from 1. + */ public int getMeasure(Metric metric, int fromLine, int toLine) { if (toLine > lines.size()) { throw new IllegalStateException("There are only " + lines.size() + " lines in the file and you're trying to reach line " + toLine); @@ -125,4 +129,13 @@ public class Source { public Set getNoSonarTagLines() { return noSonarTagLines; } + + /** + * @since 2.14 + */ + @Beta + public int getNumberOfLines() { + return lines.size(); + } + } -- cgit v1.2.3