@Test public void testCalculateLOC() throws IOException { int expectedLoc = 21; int actualLoc = analyzer.calculateLOC(TEST_FILEPATH); assertEquals(expectedLoc, actualLoc); }
@Override public int calculateLOC(String filepath) throws IOException { String sourceCode = contentReader.readFileForRegex(filepath); Pattern pattern = Pattern.compile("(( Matcher nonCodeLinesMatcher = pattern.matcher(sourceCode); int nonCodeLinesCounter = 0; while (nonCodeLinesMatcher.find()) { nonCodeLinesCounter++; } int sourceFileLength = sourceCode.split("\n").length; int loc = sourceFileLength - nonCodeLinesCounter; return loc; }
RegexAnalyzer extends SourceCodeAnalyzer { @Override public int calculateLOC(String filepath) throws IOException { String sourceCode = contentReader.readFileForRegex(filepath); Pattern pattern = Pattern.compile("(( Matcher nonCodeLinesMatcher = pattern.matcher(sourceCode); int nonCodeLinesCounter = 0; while (nonCodeLinesMatcher.find()) { nonCodeLinesCounter++; } int sourceFileLength = sourceCode.split("\n").length; int loc = sourceFileLength - nonCodeLinesCounter; return loc; } }
RegexAnalyzer extends SourceCodeAnalyzer { @Override public int calculateLOC(String filepath) throws IOException { String sourceCode = contentReader.readFileForRegex(filepath); Pattern pattern = Pattern.compile("(( Matcher nonCodeLinesMatcher = pattern.matcher(sourceCode); int nonCodeLinesCounter = 0; while (nonCodeLinesMatcher.find()) { nonCodeLinesCounter++; } int sourceFileLength = sourceCode.split("\n").length; int loc = sourceFileLength - nonCodeLinesCounter; return loc; }  }
RegexAnalyzer extends SourceCodeAnalyzer { @Override public int calculateLOC(String filepath) throws IOException { String sourceCode = contentReader.readFileForRegex(filepath); Pattern pattern = Pattern.compile("(( Matcher nonCodeLinesMatcher = pattern.matcher(sourceCode); int nonCodeLinesCounter = 0; while (nonCodeLinesMatcher.find()) { nonCodeLinesCounter++; } int sourceFileLength = sourceCode.split("\n").length; int loc = sourceFileLength - nonCodeLinesCounter; return loc; }  @Override int calculateLOC(String filepath); @Override int calculateNOM(String filepath); @Override int calculateNOC(String filepath); }
RegexAnalyzer extends SourceCodeAnalyzer { @Override public int calculateLOC(String filepath) throws IOException { String sourceCode = contentReader.readFileForRegex(filepath); Pattern pattern = Pattern.compile("(( Matcher nonCodeLinesMatcher = pattern.matcher(sourceCode); int nonCodeLinesCounter = 0; while (nonCodeLinesMatcher.find()) { nonCodeLinesCounter++; } int sourceFileLength = sourceCode.split("\n").length; int loc = sourceFileLength - nonCodeLinesCounter; return loc; }  @Override int calculateLOC(String filepath); @Override int calculateNOM(String filepath); @Override int calculateNOC(String filepath);  }