Skip to content

Commit

Permalink
Various fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
mlachkar committed Oct 27, 2020
1 parent d1ed83f commit 9bb6f29
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 30 deletions.
2 changes: 1 addition & 1 deletion .scalafix.conf
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ ExplicitResultTypes {
OrganizeImports {
groupedImports = Explode
expandRelative = true
removeUnused = true
removeUnused = true # done already by RemoveUnused rule
groups = [
"re:javax?\\."
"scala."
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ package scalafix.internal.interfaces
import java.util.Optional

import scalafix.cli.ExitStatus
import scalafix.interfaces.EvaluationError
import scalafix.interfaces.ScalafixError
import scalafix.interfaces.ScalafixEvaluation
import scalafix.interfaces.ScalafixEvaluationError
import scalafix.interfaces.ScalafixFileEvaluation
import scalafix.internal.util.OptionOps._

Expand All @@ -15,13 +15,14 @@ final case class ScalafixEvaluationImpl(
fileEvaluations: Seq[ScalafixFileEvaluationImpl]
) extends ScalafixEvaluation {

override def getError: Optional[EvaluationError] =
override def getError: Optional[ScalafixEvaluationError] =
exitStatus match {
case ExitStatus.Ok => None.asJava
case ExitStatus.NoFilesError => Some(EvaluationError.NoFilesError).asJava
case ExitStatus.NoFilesError =>
Some(ScalafixEvaluationError.NoFilesError).asJava
case ExitStatus.CommandLineError =>
Some(EvaluationError.CommandLineError).asJava
case _ => Some(EvaluationError.UnexpectedError).asJava
Some(ScalafixEvaluationError.CommandLineError).asJava
case _ => Some(ScalafixEvaluationError.UnexpectedError).asJava
}

override def getErrors: Array[ScalafixError] =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ import java.util.Optional
import scala.meta.io.AbsolutePath

import scalafix.cli.ExitStatus
import scalafix.interfaces.FileEvaluationError
import scalafix.interfaces.ScalafixDiagnostic
import scalafix.interfaces.ScalafixError
import scalafix.interfaces.ScalafixFileEvaluation
import scalafix.interfaces.ScalafixFileEvaluationError
import scalafix.interfaces.ScalafixPatch
import scalafix.interfaces.ScalafixRule
import scalafix.internal.diff.DiffUtils
Expand Down Expand Up @@ -61,15 +61,16 @@ final case class ScalafixFileEvaluationImpl(
.asJava
}

override def getError(): Optional[FileEvaluationError] =
override def getError(): Optional[ScalafixFileEvaluationError] =
exitStatus match {
case ExitStatus.Ok => None.asJava
case ExitStatus.ParseError => Some(FileEvaluationError.ParseError).asJava
case ExitStatus.ParseError =>
Some(ScalafixFileEvaluationError.ParseError).asJava
case ExitStatus.MissingSemanticdbError =>
Some(FileEvaluationError.MissingSemanticdbError).asJava
Some(ScalafixFileEvaluationError.MissingSemanticdbError).asJava
case ExitStatus.StaleSemanticdbError =>
Some(FileEvaluationError.StaleSemanticdbError).asJava
case _ => Some(FileEvaluationError.UnexpectedError).asJava
Some(ScalafixFileEvaluationError.StaleSemanticdbError).asJava
case _ => Some(ScalafixFileEvaluationError.UnexpectedError).asJava
}

override def getErrors: Array[ScalafixError] =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@

public interface ScalafixEvaluation {
/**
* @return boolean true if scalafix has successfully been evaluated on all files configured with no error.
* @return boolean true if scalafix ran on at least one file; there might be errors in file evaluation though
*/
boolean isSuccessful();

Optional<EvaluationError> getError();
Optional<ScalafixEvaluationError> getError();

/**
* @deprecated replaced by {@link #getError()}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package scalafix.interfaces;

public enum EvaluationError {
public enum ScalafixEvaluationError {
/**
* Something unexpected happened.
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
package scalafix.interfaces;

import javax.swing.text.html.Option;
import java.nio.file.Path;
import java.util.Optional;

public interface ScalafixFileEvaluation {
/**
* @return boolean true if scalafix was successfully evaluated on the file
*/
boolean isSuccessful();

/**
* @return original path of the file scalafix has evaluated on
Expand All @@ -17,19 +20,9 @@ public interface ScalafixFileEvaluation {
*/
ScalafixRule[] getEvaluatedRules();

/**
*
* @return boolean true if there is no error except LintError when scalafix has been evaluated on the file
*/
boolean isSuccessful();

/**
*
* @return a more detailed error in case of scalafix.
*/
Optional<String> getErrorMessage();

Optional<FileEvaluationError> getError();
Optional<ScalafixFileEvaluationError> getError();

/**
* @deprecated replaced by {@link #getError()}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package scalafix.interfaces;

public enum FileEvaluationError {
public enum ScalafixFileEvaluationError {
/**
* Something unexpected happened.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,6 @@ class ScalafixArgumentsSuite extends AnyFunSuite with DiffAssertions {
)
.withClasspath((scalaLibrary.map(_.toNIO) :+ target).asJava)
.withScalacOptions(Collections.singletonList(removeUnused))
.withScalaVersion(scalaVersion)
.withPaths(Seq(main).asJava)
.withSourceroot(src)

Expand Down Expand Up @@ -311,7 +310,7 @@ class ScalafixArgumentsSuite extends AnyFunSuite with DiffAssertions {
assertNoDiff(obtained, content)
}

test(
test(
"Scalafix-evaluation-error-messages:Unknown rule error message",
SkipWindows
) {
Expand Down

0 comments on commit 9bb6f29

Please sign in to comment.