From 59d544e4b5e82211c268a90f57f32dc1e54ad46d Mon Sep 17 00:00:00 2001 From: Matt Dziuban Date: Thu, 16 May 2024 08:56:29 -0400 Subject: [PATCH 1/2] Upgrade deps. --- scalafix/project/build.properties | 2 +- scalafix/project/plugins.sbt | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/scalafix/project/build.properties b/scalafix/project/build.properties index 04267b1..081fdbb 100644 --- a/scalafix/project/build.properties +++ b/scalafix/project/build.properties @@ -1 +1 @@ -sbt.version=1.9.9 +sbt.version=1.10.0 diff --git a/scalafix/project/plugins.sbt b/scalafix/project/plugins.sbt index 2f54c3c..a043154 100644 --- a/scalafix/project/plugins.sbt +++ b/scalafix/project/plugins.sbt @@ -1,6 +1,6 @@ -addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % "0.12.0") +addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % "0.12.1") addSbtPlugin("com.eed3si9n" % "sbt-projectmatrix" % "0.10.0") -addSbtPlugin("org.typelevel" % "sbt-tpolecat" % "0.5.0") +addSbtPlugin("org.typelevel" % "sbt-tpolecat" % "0.5.1") resolvers += "bondlink-maven-repo" at "https://raw.githubusercontent.com/mblink/maven-repo/main" addSbtPlugin("bondlink" % "sbt-git-publish" % "0.0.5") From a3840d8cf76a79c382ee21e41f49586158ad6cbb Mon Sep 17 00:00:00 2001 From: Matt Dziuban Date: Thu, 16 May 2024 08:58:38 -0400 Subject: [PATCH 2/2] Remove `NoUnnecessaryCase` rule, it exists in https://github.com/xuwei-k/scalafix-rules --- .../main/scala/fix/NoUnnecessaryCase.scala | 25 ------------------- .../main/scala/fix/NoUnnecessaryCase.scala | 18 ------------- .../META-INF/services/scalafix.v1.Rule | 3 +-- .../main/scala/fix/NoUnnecessaryCase.scala | 16 ------------ 4 files changed, 1 insertion(+), 61 deletions(-) delete mode 100644 scalafix/input/src/main/scala/fix/NoUnnecessaryCase.scala delete mode 100644 scalafix/output/src/main/scala/fix/NoUnnecessaryCase.scala delete mode 100644 scalafix/rules/src/main/scala/fix/NoUnnecessaryCase.scala diff --git a/scalafix/input/src/main/scala/fix/NoUnnecessaryCase.scala b/scalafix/input/src/main/scala/fix/NoUnnecessaryCase.scala deleted file mode 100644 index c2161a5..0000000 --- a/scalafix/input/src/main/scala/fix/NoUnnecessaryCase.scala +++ /dev/null @@ -1,25 +0,0 @@ -/* -rule = NoUnnecessaryCase -*/ -package fix - -object NoUnnecessaryCase { - val a = Some(1).map { case i => i }/* assert: NoUnnecessaryCase - ^^^^^^^^^^^ - The `case` keyword is unnecessary here */ - val b = Some(1).map { i => i } - - val c: PartialFunction[Int, Int] = { case i => i }/* assert: NoUnnecessaryCase - ^^^^^^^^^^^ - The `case` keyword is unnecessary here */ - val d: PartialFunction[(Int, String), Int] = { case (i, _) => i } - - val e: PartialFunction[Int, Int] = { case i if i > 0 => i } - - val f = Some((1, "foo")).map { case (i, s) => (i + 1, s) } - - val g = Option(1) match { - case Some(i) => i - case None => 0 - } -} diff --git a/scalafix/output/src/main/scala/fix/NoUnnecessaryCase.scala b/scalafix/output/src/main/scala/fix/NoUnnecessaryCase.scala deleted file mode 100644 index 8f25ac2..0000000 --- a/scalafix/output/src/main/scala/fix/NoUnnecessaryCase.scala +++ /dev/null @@ -1,18 +0,0 @@ -package fix - -object NoUnnecessaryCase { - val a = Some(1).map { case i => i } - val b = Some(1).map { i => i } - - val c: PartialFunction[Int, Int] = { case i => i } - val d: PartialFunction[(Int, String), Int] = { case (i, _) => i } - - val e: PartialFunction[Int, Int] = { case i if i > 0 => i } - - val f = Some((1, "foo")).map { case (i, s) => (i + 1, s) } - - val g = Option(1) match { - case Some(i) => i - case None => 0 - } -} diff --git a/scalafix/rules/src/main/resources/META-INF/services/scalafix.v1.Rule b/scalafix/rules/src/main/resources/META-INF/services/scalafix.v1.Rule index 4c7a00f..fb0bad9 100644 --- a/scalafix/rules/src/main/resources/META-INF/services/scalafix.v1.Rule +++ b/scalafix/rules/src/main/resources/META-INF/services/scalafix.v1.Rule @@ -1,3 +1,2 @@ -fix.NoUnnecessaryCase fix.StrictSubclassAccess -fix.NoWithForExtends \ No newline at end of file +fix.NoWithForExtends diff --git a/scalafix/rules/src/main/scala/fix/NoUnnecessaryCase.scala b/scalafix/rules/src/main/scala/fix/NoUnnecessaryCase.scala deleted file mode 100644 index 0f05c7a..0000000 --- a/scalafix/rules/src/main/scala/fix/NoUnnecessaryCase.scala +++ /dev/null @@ -1,16 +0,0 @@ -package fix - -import scalafix.v1._ -import scala.meta._ - -case class UnnecessaryCase(position: Position) extends Diagnostic { - override def message = "The `case` keyword is unnecessary here" -} - -class NoUnnecessaryCase extends SyntacticRule("NoUnnecessaryCase") { - override def fix(implicit doc: SyntacticDocument): Patch = - doc.tree.collect { - case Term.PartialFunction(List(t @ Case(Pat.Var(Term.Name(_)), None, _))) => - Patch.lint(UnnecessaryCase(t.pos)) - }.asPatch -}