@Test public void testCalculateRegexNOM() throws IOException { assertEquals(3, sca.calculateNOM(TEST_CLASS, TYPE_REGEX)); }
public int calculateNOM(String filepath, String analyzerType) throws IOException { if(analyzerType.equals("regex")) { String sourceCode = fileReader.readFileIntoString(filepath); Pattern pattern = Pattern.compile(".*(public |protected |private |static )?[\\w\\<\\>\\[\\]]+\\s+(\\w+) *\\([^\\)]*\\) *(\\{?|[^;]).*"); Matcher methodSignatures = pattern.matcher(sourceCode); int methodCounter = 0; while (methodSignatures.find()) { methodCounter++; } return methodCounter; } else if (analyzerType.equals("strcomp")) { List<String> sourceCodeList = fileReader.readFileIntoList(filepath); int methodCounter = 0; for (String line : sourceCodeList) { line = line.trim(); if ( ((line.contains("public") || line.contains("private") || line.contains("protected")) || line.contains("void") || line.contains("int") || line.contains("String")) && line.contains("(") && line.contains(")") && line.contains("{") ) methodCounter++; } return methodCounter; } return -1; }
SourceCodeAnalyzer { public int calculateNOM(String filepath, String analyzerType) throws IOException { if(analyzerType.equals("regex")) { String sourceCode = fileReader.readFileIntoString(filepath); Pattern pattern = Pattern.compile(".*(public |protected |private |static )?[\\w\\<\\>\\[\\]]+\\s+(\\w+) *\\([^\\)]*\\) *(\\{?|[^;]).*"); Matcher methodSignatures = pattern.matcher(sourceCode); int methodCounter = 0; while (methodSignatures.find()) { methodCounter++; } return methodCounter; } else if (analyzerType.equals("strcomp")) { List<String> sourceCodeList = fileReader.readFileIntoList(filepath); int methodCounter = 0; for (String line : sourceCodeList) { line = line.trim(); if ( ((line.contains("public") || line.contains("private") || line.contains("protected")) || line.contains("void") || line.contains("int") || line.contains("String")) && line.contains("(") && line.contains(")") && line.contains("{") ) methodCounter++; } return methodCounter; } return -1; } }
SourceCodeAnalyzer { public int calculateNOM(String filepath, String analyzerType) throws IOException { if(analyzerType.equals("regex")) { String sourceCode = fileReader.readFileIntoString(filepath); Pattern pattern = Pattern.compile(".*(public |protected |private |static )?[\\w\\<\\>\\[\\]]+\\s+(\\w+) *\\([^\\)]*\\) *(\\{?|[^;]).*"); Matcher methodSignatures = pattern.matcher(sourceCode); int methodCounter = 0; while (methodSignatures.find()) { methodCounter++; } return methodCounter; } else if (analyzerType.equals("strcomp")) { List<String> sourceCodeList = fileReader.readFileIntoList(filepath); int methodCounter = 0; for (String line : sourceCodeList) { line = line.trim(); if ( ((line.contains("public") || line.contains("private") || line.contains("protected")) || line.contains("void") || line.contains("int") || line.contains("String")) && line.contains("(") && line.contains(")") && line.contains("{") ) methodCounter++; } return methodCounter; } return -1; } SourceCodeAnalyzer(String fileReaderType); }
SourceCodeAnalyzer { public int calculateNOM(String filepath, String analyzerType) throws IOException { if(analyzerType.equals("regex")) { String sourceCode = fileReader.readFileIntoString(filepath); Pattern pattern = Pattern.compile(".*(public |protected |private |static )?[\\w\\<\\>\\[\\]]+\\s+(\\w+) *\\([^\\)]*\\) *(\\{?|[^;]).*"); Matcher methodSignatures = pattern.matcher(sourceCode); int methodCounter = 0; while (methodSignatures.find()) { methodCounter++; } return methodCounter; } else if (analyzerType.equals("strcomp")) { List<String> sourceCodeList = fileReader.readFileIntoList(filepath); int methodCounter = 0; for (String line : sourceCodeList) { line = line.trim(); if ( ((line.contains("public") || line.contains("private") || line.contains("protected")) || line.contains("void") || line.contains("int") || line.contains("String")) && line.contains("(") && line.contains(")") && line.contains("{") ) methodCounter++; } return methodCounter; } 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 calculateNOM(String filepath, String analyzerType) throws IOException { if(analyzerType.equals("regex")) { String sourceCode = fileReader.readFileIntoString(filepath); Pattern pattern = Pattern.compile(".*(public |protected |private |static )?[\\w\\<\\>\\[\\]]+\\s+(\\w+) *\\([^\\)]*\\) *(\\{?|[^;]).*"); Matcher methodSignatures = pattern.matcher(sourceCode); int methodCounter = 0; while (methodSignatures.find()) { methodCounter++; } return methodCounter; } else if (analyzerType.equals("strcomp")) { List<String> sourceCodeList = fileReader.readFileIntoList(filepath); int methodCounter = 0; for (String line : sourceCodeList) { line = line.trim(); if ( ((line.contains("public") || line.contains("private") || line.contains("protected")) || line.contains("void") || line.contains("int") || line.contains("String")) && line.contains("(") && line.contains(")") && line.contains("{") ) methodCounter++; } return methodCounter; } return -1; } SourceCodeAnalyzer(String fileReaderType); int calculateLOC(String filepath, String analyzerType); int calculateNOM(String filepath, String analyzerType); int calculateNOC(String filepath, String analyzerType);  }