@Test public void testCalculateStrCompNOC() throws IOException { assertEquals(3, sca.calculateNOC(TEST_CLASS, TYPE_STRCOMP)); }
public int calculateNOC(String filepath, String analyzerType) throws IOException { if(analyzerType.equals("regex")) { String sourceCode = fileReader.readFileIntoString(filepath); Pattern pattern = Pattern.compile(".*\\s*class\\s+.*"); Matcher classSignatures = pattern.matcher(sourceCode); int classCounter = 0; while (classSignatures.find()) { classCounter++; } return classCounter; } else if (analyzerType.equals("strcomp")) { List<String> sourceCodeList = fileReader.readFileIntoList(filepath); int classCounter = 0; for (String line : sourceCodeList) { line = line.trim(); if ((line.startsWith("class ") || line.contains(" class ")) && line.contains("{")) { classCounter++; } } return classCounter; } return -1; }
SourceCodeAnalyzer { public int calculateNOC(String filepath, String analyzerType) throws IOException { if(analyzerType.equals("regex")) { String sourceCode = fileReader.readFileIntoString(filepath); Pattern pattern = Pattern.compile(".*\\s*class\\s+.*"); Matcher classSignatures = pattern.matcher(sourceCode); int classCounter = 0; while (classSignatures.find()) { classCounter++; } return classCounter; } else if (analyzerType.equals("strcomp")) { List<String> sourceCodeList = fileReader.readFileIntoList(filepath); int classCounter = 0; for (String line : sourceCodeList) { line = line.trim(); if ((line.startsWith("class ") || line.contains(" class ")) && line.contains("{")) { classCounter++; } } return classCounter; } return -1; } }
SourceCodeAnalyzer { public int calculateNOC(String filepath, String analyzerType) throws IOException { if(analyzerType.equals("regex")) { String sourceCode = fileReader.readFileIntoString(filepath); Pattern pattern = Pattern.compile(".*\\s*class\\s+.*"); Matcher classSignatures = pattern.matcher(sourceCode); int classCounter = 0; while (classSignatures.find()) { classCounter++; } return classCounter; } else if (analyzerType.equals("strcomp")) { List<String> sourceCodeList = fileReader.readFileIntoList(filepath); int classCounter = 0; for (String line : sourceCodeList) { line = line.trim(); if ((line.startsWith("class ") || line.contains(" class ")) && line.contains("{")) { classCounter++; } } return classCounter; } return -1; } SourceCodeAnalyzer(String fileReaderType); }
SourceCodeAnalyzer { public int calculateNOC(String filepath, String analyzerType) throws IOException { if(analyzerType.equals("regex")) { String sourceCode = fileReader.readFileIntoString(filepath); Pattern pattern = Pattern.compile(".*\\s*class\\s+.*"); Matcher classSignatures = pattern.matcher(sourceCode); int classCounter = 0; while (classSignatures.find()) { classCounter++; } return classCounter; } else if (analyzerType.equals("strcomp")) { List<String> sourceCodeList = fileReader.readFileIntoList(filepath); int classCounter = 0; for (String line : sourceCodeList) { line = line.trim(); if ((line.startsWith("class ") || line.contains(" class ")) && line.contains("{")) { classCounter++; } } return classCounter; } return -1; } SourceCodeAnalyzer(String fileReaderType); int calculateLOC(String filepath, String analyzerType); int calculateNOM(String filepath, String analyzerType); int calculateNOC(String filepath, String analyzerType); }
SourceCodeAnalyzer { public int calculateNOC(String filepath, String analyzerType) throws IOException { if(analyzerType.equals("regex")) { String sourceCode = fileReader.readFileIntoString(filepath); Pattern pattern = Pattern.compile(".*\\s*class\\s+.*"); Matcher classSignatures = pattern.matcher(sourceCode); int classCounter = 0; while (classSignatures.find()) { classCounter++; } return classCounter; } else if (analyzerType.equals("strcomp")) { List<String> sourceCodeList = fileReader.readFileIntoList(filepath); int classCounter = 0; for (String line : sourceCodeList) { line = line.trim(); if ((line.startsWith("class ") || line.contains(" class ")) && line.contains("{")) { classCounter++; } } return classCounter; } return -1; } SourceCodeAnalyzer(String fileReaderType); int calculateLOC(String filepath, String analyzerType); int calculateNOM(String filepath, String analyzerType); int calculateNOC(String filepath, String analyzerType);  }