JS: Count lines of code correctly

This commit is contained in:
Asger Feldthaus
2020-06-29 09:27:38 +01:00
parent 9c65318f99
commit e46a9dac65
3 changed files with 11 additions and 4 deletions

View File

@@ -511,7 +511,7 @@ public class FileExtractor {
new TextualExtractor(
trapwriter, locationManager, source, config.getExtractLines(), metrics, extractedFile);
LoCInfo loc = extractor.extract(textualExtractor);
int numLines = textualExtractor.getNumLines();
int numLines = textualExtractor.isSnippet() ? 0 : textualExtractor.getNumLines();
int linesOfCode = loc.getLinesOfCode(), linesOfComments = loc.getLinesOfComments();
trapwriter.addTuple("numlines", fileLabel, numLines, linesOfCode, linesOfComments);
trapwriter.addTuple("filetype", fileLabel, fileType.toString());

View File

@@ -52,6 +52,13 @@ public class TextualExtractor {
return extractedFile;
}
/**
* Returns true if the extracted file and the source location files are different.
*/
public boolean isSnippet() {
return !extractedFile.equals(locationManager.getSourceFile());
}
public TrapWriter getTrapwriter() {
return trapwriter;
}