Skip to content

Commit

Permalink
Improve result log (#338)
Browse files Browse the repository at this point in the history
  • Loading branch information
carlosedp authored Apr 16, 2024
1 parent 9f83818 commit a9b155c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/main/java/org/antipathy/mvn_scalafmt/FormatMojo.java
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public void execute() throws MojoExecutionException {
project.getBasedir(),
useSpecifiedRepositories ? getRepositoriesUrls(mavenRepositories) : new ArrayList<String>()
).format(sources);
getLog().info(result.toString());
result.print(getLog());
if (validateOnly && result.unformattedFiles() != 0) {
throw new MojoExecutionException("Scalafmt: Unformatted files found");
}
Expand Down
14 changes: 9 additions & 5 deletions src/main/scala/org/antipathy/mvn_scalafmt/model/Summary.scala
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package org.antipathy.mvn_scalafmt.model

import org.apache.maven.plugin.logging.Log

// $COVERAGE-OFF$

/** Class representing the result of a run of the plugin
Expand All @@ -13,11 +15,13 @@ case class Summary(
fileDetails: Seq[FileSummary]
) {

override def toString: String =
s"""Scalafmt results: $unformattedFiles of $totalFiles were unformatted
|Details:
|${fileDetails.mkString(System.lineSeparator)}
""".stripMargin
def print(log: Log) = {
log.info(s"Scalafmt results: $unformattedFiles of $totalFiles were unformatted")
log.info("Details:")
fileDetails.foreach { fileSummary =>
log.info("- " + fileSummary.toString)
}
}
}

// $COVERAGE-ON$

0 comments on commit a9b155c

Please sign in to comment.