Skip to content

Commit

Permalink
Merge pull request #27 from poslegm/warnings-list
Browse files Browse the repository at this point in the history
Warnings for all unformatted files
  • Loading branch information
tanishiking committed Mar 14, 2019
2 parents bffd41b + 83e142f commit 4e8e2ea
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions plugin/src/main/scala/org/scalafmt/sbt/ScalafmtPlugin.scala
Expand Up @@ -154,7 +154,7 @@ object ScalafmtPlugin extends AutoPlugin {
cached[Boolean](cacheDirectory, FilesInfo.lastModified) { modified =>
val changed = modified.filter(_.exists)
if (changed.size > 0) {
log.info(s"Formatting ${changed.size} Scala sources...")
log.info(s"Checking ${changed.size} Scala sources...")
checkSources(changed.toSeq, config, log, writer)
} else {
true
Expand All @@ -168,22 +168,25 @@ object ScalafmtPlugin extends AutoPlugin {
log: Logger,
writer: PrintWriter
): Boolean = {
val res = withFormattedSources(sources, config, log, writer)(
val unformattedCount = withFormattedSources(sources, config, log, writer)(
(file, e) => {
log.err(e.toString)
false
},
(file, input, output) => {
val diff = input != output
if (diff) {
throw new MessageOnlyException(
s"${file.toString} isn't formatted properly!"
)
log.warn(s"${file.toString} isn't formatted properly!")
}
!diff
}
).flatten.forall(x => x)
res
).flatten.count(x => !x)
if (unformattedCount > 0) {
throw new MessageOnlyException(
s"${unformattedCount} files must be formatted"
)
}
unformattedCount == 0
}

private def cached[T](cacheBaseDirectory: File, inStyle: FileInfo.Style)(
Expand Down

0 comments on commit 4e8e2ea

Please sign in to comment.