Skip to content
This repository has been archived by the owner on Aug 12, 2020. It is now read-only.

Commit

Permalink
Fix Java Test Counting Bug - #45
Browse files Browse the repository at this point in the history
  • Loading branch information
jan-gerling committed Feb 18, 2020
1 parent 5a1b17b commit fcc6a4f
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -128,10 +128,8 @@ private void updateProcessMetrics(RevCommit commit, RevCommit commitParent) thro
}

// do not collect these numbers if not a java file (save some memory)
boolean isAJavaFile = fileName.toLowerCase().endsWith("java");
if (!isAJavaFile) {
if (!refactoringml.util.FileUtils.IsJavaFile(fileName))
continue;
}

// if the class was either removed or deleted, we remove it from our pmDatabase, as to not mess
// with the refactoring counter...
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,19 +27,21 @@ public static String[] getAllJavaFiles(String path) {
}

public static String[] getAllJavaFiles(String path, String regex) {

try {
return Files.walk(Paths.get(path))
.filter(Files::isRegularFile)
.filter(x -> !x.toAbsolutePath().toString().contains(".git"))
.filter(x -> x.toAbsolutePath().toString().toLowerCase().endsWith("java"))
.filter(x -> IsJavaFile(x.toAbsolutePath().toString()))
.filter(x -> (regex!=null?x.toAbsolutePath().toString().contains(regex):true))
.map(x -> x.toAbsolutePath().toString())
.toArray(String[]::new);
} catch(Exception e) {
throw new RuntimeException(e);
}

}

//Returns true if a file is a java file.
public static boolean IsJavaFile(String fileName){
return fileName.toLowerCase().endsWith("java");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
import java.util.List;
import java.util.Set;

import static refactoringml.util.FilePathUtils.enforceUnixPaths;

public class RefactoringUtils {

public static final int TYPE_CLASS_LEVEL = 1;
Expand Down Expand Up @@ -235,9 +237,11 @@ public static int refactoringTypeInNumber(Refactoring refactoring) {
}

public static boolean isTestFile(String fileName) {
String normalizedFileName = fileName.toLowerCase();
return normalizedFileName.contains("test.java") || normalizedFileName.contains("tests.java") ||
if(!FileUtils.IsJavaFile(fileName))
return false;

String normalizedFileName = enforceUnixPaths(fileName.toLowerCase());
return normalizedFileName.contains("test") ||
normalizedFileName.contains("/test/");
}

}
}

0 comments on commit fcc6a4f

Please sign in to comment.