Skip to content

Commit

Permalink
Fix failing tests and compilation errors.
Browse files Browse the repository at this point in the history
  • Loading branch information
olafurpg committed Aug 16, 2017
1 parent 8810e25 commit c3605c3
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 7 deletions.
2 changes: 1 addition & 1 deletion readme/Configuration.scalatex
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
If a rewrites is on the classpath, you can classload it with the
@code{scala:} protocol.
@config
rewrite = "scala:scalafix.rewrite.ProcedureSyntax"
rewrite = "scala:scalafix.internal.rewrite.ProcedureSyntax"

@sect{github:}
If a rewrite is written in a single file and you want a short syntax,
Expand Down
1 change: 1 addition & 0 deletions readme/Rewrites.scalatex
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
@import Main._
@import scalafix.Readme._
@import scalafix.rewrite._
@import scalafix.internal.rewrite._

@sect{Rewrites}
@p
Expand Down
3 changes: 2 additions & 1 deletion scalafix-cli/src/main/scala/scalafix/cli/CliRunner.scala
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,8 @@ sealed abstract case class CliRunner(
}
display.stop()
val exit = exitCode.get()
if (!config.reporter.hasErrors) ExitStatus.merge(ExitStatus.LinterError, exit)
if (!config.reporter.hasErrors)
ExitStatus.merge(ExitStatus.LinterError, exit)
else exit
}

Expand Down
1 change: 0 additions & 1 deletion scalafix-cli/src/test/scala/scalafix/cli/CliTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import scalafix.internal.cli.ScalafixOptions
import scalafix.internal.rewrite.ExplicitReturnTypes
import scalafix.internal.rewrite.ProcedureSyntax
import scalafix.internal.util.FileOps
import scalafix.rewrite.ProcedureSyntax
import scalafix.testkit.DiffAssertions
import org.scalatest.FunSuite

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package scalafix.internal.config
import scala.meta.Position
import scala.meta.internal.inputs.XtensionPositionFormatMessage
import java.io.PrintStream
import java.util.concurrent.atomic.AtomicInteger
import java.util.concurrent.atomic.AtomicReference
import scalafix.internal.util.Severity
import metaconfig._
Expand All @@ -29,17 +30,19 @@ case class PrintStreamReporter(
)
}
}
private val _hasError = new AtomicReference(false)
private val _errorCount = new AtomicInteger()

override def report(message: String, position: Position, severity: Severity)(
implicit ctx: LogContext): Unit = {
_hasError.compareAndSet(false, severity == Severity.Error)
if (severity == Severity.Error) {
_errorCount.incrementAndGet()
}
val enclosing =
if (includeLoggerName) s"(${ctx.enclosing.value}) " else ""
outStream.println(
position.formatMessage(enclosing + severity.toString, message))
}

/** Returns true if this reporter has seen an error */
override def hasErrors: Boolean = _hasError.get()
override def errorCount: Int = _errorCount.get()
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@ import metaconfig.ConfDecoder
trait ScalafixReporter {

/** Returns true if this reporter has seen an error */
def hasErrors: Boolean
def hasErrors: Boolean = errorCount > 0

/** Returns the number of reported errors */
def errorCount: Int

/** Messages with severity < minSeverity are skipped. */
def minSeverity: Severity
Expand Down

0 comments on commit c3605c3

Please sign in to comment.