in src/main/java/com/spotify/fmt/Formatter.java [76:104]
public void formatSourceFilesInDirectory(
File directory, com.google.googlejavaformat.java.Formatter formatter, Style style)
throws FormatterException {
if (!directory.isDirectory()) {
log.info("Directory '" + directory + "' is not a directory. Skipping.");
return;
}
try (Stream<Path> paths = Files.walk(Paths.get(directory.getPath()))) {
FileFilter fileNameFilter = getFileNameFilter();
FileFilter pathFilter = getPathFilter();
long failures =
paths.collect(Collectors.toList()).parallelStream()
.filter(p -> p.toFile().exists())
.map(Path::toFile)
.filter(fileNameFilter::accept)
.filter(pathFilter::accept)
.map(file -> formatSourceFile(file, formatter, style))
.filter(r -> !r)
.count();
if (failures > 0) {
throw new FormatterException(
"There were errors when formatting files. Error count: " + failures);
}
} catch (IOException exception) {
throw new FormatterException(exception.getMessage());
}
}