Skip to content

Commit

Permalink
fix(spoon): Fix filtering of non source path for spoon analyzer (#840)
Browse files Browse the repository at this point in the history
  • Loading branch information
MartinWitt committed Jul 15, 2023
1 parent b247909 commit 5a5600d
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package io.github.martinwitt.spoon_analyzer;

import java.io.File;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.List;
Expand Down Expand Up @@ -37,9 +38,18 @@ public static List<Path> removeRedundantPaths(List<Path> paths) {
* @return a new list of paths without resources or test files
*/
public static List<Path> filterResourcePaths(List<Path> paths) {
return paths.stream()
.filter(path -> path.toString().endsWith("src/main/java")
|| path.toString().endsWith("src/test/java"))
.collect(Collectors.toList());
return paths.stream().filter(path -> filterNonSourcePath(path)).collect(Collectors.toList());
}

private static boolean filterNonSourcePath(Path path) {
return isSourceDirectory(path) || isTestDirectory(path);
}

private static boolean isSourceDirectory(Path path) {
return path.endsWith("src" + File.separator + "main" + File.separator + "java");
}

private static boolean isTestDirectory(Path path) {
return path.endsWith("src" + File.separator + "test" + File.separator + "java");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -70,4 +70,12 @@ public List<BadSmell> analyze(String path) {
}
return badSmells;
}

public static void main(String[] args) {
var analyzer = new SpoonAnalyzer();
var badSmells = analyzer.analyze("./assertj-assertions-generator-maven-plugin");
for (BadSmell badSmell : badSmells) {
logger.atInfo().log(badSmell.toString());
}
}
}

0 comments on commit 5a5600d

Please sign in to comment.