diff --git a/build.sbt b/build.sbt index 535b1c4..4322820 100644 --- a/build.sbt +++ b/build.sbt @@ -172,8 +172,7 @@ lazy val rules212 = rules .enablePlugins(ScalafixPlugin) .dependsOn(myRuleRule % ScalafixConfig) .settings( - // TODO re-enable if warning-diff-scalafix-plugin released - // Test / test := (Test / test).dependsOn(scripted.toTask("")).value, + Test / test := (Test / test).dependsOn(scripted.toTask("")).value, Compile / compile := (Compile / compile).dependsOn((Compile / scalafix).toTask(" MyScalafixRuleRule")).value, scriptedBufferLog := false, scriptedLaunchOpts += ("-Dscalafix-rules.version=" + version.value), diff --git a/rules/src/main/scala/fix/SeparateEachFileRewrite.scala b/rules/src/main/scala/fix/SeparateEachFileRewrite.scala index 46f59ef..eb0e972 100644 --- a/rules/src/main/scala/fix/SeparateEachFileRewrite.scala +++ b/rules/src/main/scala/fix/SeparateEachFileRewrite.scala @@ -86,5 +86,5 @@ class SeparateEachFileRewrite(config: SeparateEachFileConfig) extends SyntacticR Patch.empty } - private def isTopLevel(t: Tree): Boolean = t.parent.forall(_.is[Pkg]) + private def isTopLevel(t: Tree): Boolean = t.parent.forall(_.is[Pkg.Body]) } diff --git a/rules/src/main/scala/fix/UnmooredDocComment.scala b/rules/src/main/scala/fix/UnmooredDocComment.scala index 0f37e8f..677fa02 100644 --- a/rules/src/main/scala/fix/UnmooredDocComment.scala +++ b/rules/src/main/scala/fix/UnmooredDocComment.scala @@ -4,6 +4,7 @@ import scala.collection.compat._ import scala.meta.Decl import scala.meta.Defn import scala.meta.Mod +import scala.meta.Pkg import scala.meta.Stat import scala.meta.Tree import scala.meta.transversers._ @@ -17,7 +18,7 @@ import scalafix.v1.XtensionSeqPatch object UnmooredDocComment { private object Unmoored { def unapply(t: Tree): Boolean = t match { - case _: Stat.WithTemplate | _: Defn | _: Mod | _: Decl => + case _: Stat.WithTemplate | _: Defn | _: Mod | _: Decl | _: Pkg.Body => false case _ => true diff --git a/sbt-test/SyntacticOrganizeImports/test-1/project/plugins.sbt b/sbt-test/SyntacticOrganizeImports/test-1/project/plugins.sbt index 1de060c..5bae6e8 100644 --- a/sbt-test/SyntacticOrganizeImports/test-1/project/plugins.sbt +++ b/sbt-test/SyntacticOrganizeImports/test-1/project/plugins.sbt @@ -1,2 +1,2 @@ addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % sys.props("scalafix.version")) -addSbtPlugin("com.github.xuwei-k" % "warning-diff-scalafix-plugin" % "0.4.4") +addSbtPlugin("com.github.xuwei-k" % "warning-diff-scalafix-plugin" % "0.5.0") diff --git a/sbt-test/UnmooredDocComment/test-1/build.sbt b/sbt-test/UnmooredDocComment/test-1/build.sbt index 856724a..181bb56 100644 --- a/sbt-test/UnmooredDocComment/test-1/build.sbt +++ b/sbt-test/UnmooredDocComment/test-1/build.sbt @@ -1 +1,10 @@ ThisBuild / scalafixDependencies += "com.github.xuwei-k" %% "scalafix-rules" % sys.props("scalafix-rules.version") + +TaskKey[Unit]("check") := { + if(!scala.util.Properties.isWin) { + val actual = "target/warnings/warnings.json" + val expect = "expect.json" + sys.process.Process(Seq("diff", actual, expect)).! + assert(IO.read(file(actual)) == IO.read(file(expect))) + } +} diff --git a/sbt-test/UnmooredDocComment/test-1/expect.json b/sbt-test/UnmooredDocComment/test-1/expect.json index 323998f..b7b366f 100644 --- a/sbt-test/UnmooredDocComment/test-1/expect.json +++ b/sbt-test/UnmooredDocComment/test-1/expect.json @@ -53,4 +53,4 @@ "endLine": 24, "endColumn": 16 } -}] +}] \ No newline at end of file diff --git a/sbt-test/UnmooredDocComment/test-1/project/plugins.sbt b/sbt-test/UnmooredDocComment/test-1/project/plugins.sbt index 1de060c..5bae6e8 100644 --- a/sbt-test/UnmooredDocComment/test-1/project/plugins.sbt +++ b/sbt-test/UnmooredDocComment/test-1/project/plugins.sbt @@ -1,2 +1,2 @@ addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % sys.props("scalafix.version")) -addSbtPlugin("com.github.xuwei-k" % "warning-diff-scalafix-plugin" % "0.4.4") +addSbtPlugin("com.github.xuwei-k" % "warning-diff-scalafix-plugin" % "0.5.0") diff --git a/sbt-test/UnmooredDocComment/test-1/test b/sbt-test/UnmooredDocComment/test-1/test index c0de808..a52ba59 100644 --- a/sbt-test/UnmooredDocComment/test-1/test +++ b/sbt-test/UnmooredDocComment/test-1/test @@ -1,2 +1,2 @@ > warningsAll -$ must-mirror target/warnings/warnings.json expect.json +> check