diff --git a/modules/cli/src/main/scala/scala/cli/commands/scalafix/Scalafix.scala b/modules/cli/src/main/scala/scala/cli/commands/scalafix/Scalafix.scala index 077a3515c7..226eda5a25 100644 --- a/modules/cli/src/main/scala/scala/cli/commands/scalafix/Scalafix.scala +++ b/modules/cli/src/main/scala/scala/cli/commands/scalafix/Scalafix.scala @@ -121,6 +121,7 @@ object Scalafix extends ScalaCommand[ScalafixOptions] { options.scalafixConf.toList.flatMap(scalafixConf => List("--config", scalafixConf)) ++ Seq("--sourceroot", workspace.toString) ++ Seq("--classpath", classPaths.mkString(java.io.File.pathSeparator)) ++ + Seq("--scala-version", scalaVersion) ++ (if (options.check) Seq("--test") else Nil) ++ (if (scalacOptions.nonEmpty) scalacOptions.flatMap(Seq("--scalac-options", _)) else Nil) ++ @@ -130,6 +131,8 @@ object Scalafix extends ScalaCommand[ScalafixOptions] { options.rules.flatMap(Seq("-r", _)) ++ options.scalafixArg + println(s"AAAAAAAAAAAA: ${artifacts.scalafixJars}") + val proc = Runner.runJvm( buildOptions.javaHome().value.javaCommand, buildOptions.javaOptions.javaOpts.toSeq.map(_.value.value), diff --git a/modules/integration/src/test/scala/scala/cli/integration/ScalafixTestDefinitions.scala b/modules/integration/src/test/scala/scala/cli/integration/ScalafixTestDefinitions.scala index 6da38775d6..7d326b0bc4 100644 --- a/modules/integration/src/test/scala/scala/cli/integration/ScalafixTestDefinitions.scala +++ b/modules/integration/src/test/scala/scala/cli/integration/ScalafixTestDefinitions.scala @@ -233,29 +233,25 @@ abstract class ScalafixTestDefinitions extends ScalaCliSuite with TestScalaVersi test("external rule") { val original: String = - """|//> using scalafix.dep "io.github.ghostbuster91.scalafix-unified::unified:0.0.8" + """|//> using scalafix.dep "com.github.xuwei-k::scalafix-rules:0.5.1" | - |package foo - | - |object Hello { - | val a = List[Int]() + |object CollectHeadOptionTest { + | def x1: Option[String] = List(1, 2, 3).collect { case n if n % 2 == 0 => n.toString }.headOption |} |""".stripMargin val inputs: TestInputs = TestInputs( os.rel / confFileName -> s"""|rules = [ - | EmptyCollectionsUnified + | CollectHeadOption |] |""".stripMargin, os.rel / "Hello.scala" -> original ) val expectedContent: String = noCrLf { - """|//> using scalafix.dep "io.github.ghostbuster91.scalafix-unified::unified:0.0.8" + """|//> using scalafix.dep "com.github.xuwei-k::scalafix-rules:0.5.1" | - |package foo - | - |object Hello { - | val a = List.empty[Int] + |object CollectHeadOptionTest { + | def x1: Option[String] = List(1, 2, 3).collectFirst{ case n if n % 2 == 0 => n.toString } |} |""".stripMargin } @@ -267,10 +263,7 @@ abstract class ScalafixTestDefinitions extends ScalaCliSuite with TestScalaVersi } } - test { - val name = "explicit-result-types" - if (actualScalaVersion.startsWith("3")) name.ignore else munit.TestOptions(name) - } { + test("explicit-result-types") { val original: String = """|package foo | diff --git a/website/docs/commands/scalafix.md b/website/docs/commands/scalafix.md index 42d3a2f0f8..dfa1dbe1ea 100644 --- a/website/docs/commands/scalafix.md +++ b/website/docs/commands/scalafix.md @@ -39,7 +39,7 @@ Read more about Scalafix: ### Using external rules -Adding an [external scalafix rule]() to scala-cli might be done by declaring [`scalafix.dep`](./compile.md#compile-only-dependencies): +Adding an [external scalafix rule](https://scalacenter.github.io/scalafix/docs/rules/external-rules.html) to scala-cli might be done by declaring [`scalafix.dep`](./compile.md#compile-only-dependencies): ```scala title=externalRule.scala -//> using scalafix.dep "com.github.jatcwang::scalafix-named-params:0.2.5" +//> using scalafix.dep "com.github.xuwei-k::scalafix-rules:0.5.1" ```