Skip to content

Commit

Permalink
Add a filename filter to I18nSpec to skip garbage files
Browse files Browse the repository at this point in the history
I'm looking at you, .DS_Store
  • Loading branch information
Chris Birchall committed Sep 26, 2014
1 parent bbfdda6 commit 78e0c58
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions test/views/I18nSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,16 @@ class I18nSpec extends FlatSpec with Matchers {
class MultibyteCharDetector extends SimpleFileVisitor[Path] {
val violations = ArrayBuffer.empty[Violation]

val pathMatcher = FileSystems.getDefault.getPathMatcher("glob:**/*.scala*") // Scala files and .scala.html templates

override def visitFile(file: Path, attrs: BasicFileAttributes) = {
Source.fromFile(file.toFile).getLines().zipWithIndex.foreach {
case (line, lineNum) =>
if (line.getBytes(StandardCharsets.UTF_8).length != line.size) {
violations += Violation(file, lineNum, line)
}
if (pathMatcher.matches(file)) {
Source.fromFile(file.toFile).getLines().zipWithIndex.foreach {
case (line, lineNum) =>
if (line.getBytes(StandardCharsets.UTF_8).length != line.size) {
violations += Violation(file, lineNum, line)
}
}
}
FileVisitResult.CONTINUE
}
Expand Down

0 comments on commit 78e0c58

Please sign in to comment.