Reputation: 2661
I am using 'scalafmt' command to ensure that I've no formatting errors in my Scala code. It keeps failing with this error message:
Looking for unformatted files... (98.35 %, 238 / 242)
error: --test failed
Those are the last two lines. There's no other error message in the log. Is there a configuration I can use that will give me more information about this failure?
Upvotes: 1
Views: 1440
Reputation: 2080
If you run scalafmt --test
from the command line it will give you a diff between what you have and what it thinks you should have. Unfortunately it only shows you the difference, and not which rule indicated the change.
Upvotes: 0
Reputation: 568
By default, Scalafmt errors are reported to System.err. Extend org.scalafmt.interfaces.ScalafmtReporter to customize error reporting to handle parse and config errors.
class ScalafmtErrReport(out: PrintStream) extends ScalafmtReporter {
override def error(file: Path, e: Throwable): Unit = {
out.print(s"error: $file: ")
trimStacktrace(e)
e.printStackTrace(out)
}
override def error(path: Path, message: String): Unit = {
out.println(s"error: $path: $message")
}
override def error(file: Path, message: String, e: Throwable): Unit = {
error(file, ScalafmtException(message, e))
}
}
check: https://scalameta.org/scalafmt/docs/installation.html
Upvotes: 1