From 013262287d96890edbb82879fec6b4884cb810d3 Mon Sep 17 00:00:00 2001 From: Johnnei Date: Mon, 26 Feb 2024 16:34:34 +0700 Subject: [PATCH] feat: Support Scala 2.13.13 and 2.12.19 --- .github/workflows/pr-checks.yml | 4 ++-- build.sbt | 4 ++-- project/plugins.sbt | 2 +- .../unneccesary/UnnecessaryConversion.scala | 4 ++-- .../scala/com/sksamuel/scapegoat/package.scala | 3 ++- .../UnnecessaryConversionTest.scala | 18 +++++++++--------- 6 files changed, 18 insertions(+), 17 deletions(-) diff --git a/.github/workflows/pr-checks.yml b/.github/workflows/pr-checks.yml index 3106d650..63d41a02 100644 --- a/.github/workflows/pr-checks.yml +++ b/.github/workflows/pr-checks.yml @@ -10,10 +10,10 @@ jobs: matrix: java: [8, 11] scala: - - 2.12.17 - 2.12.18 - - 2.13.11 + - 2.12.19 - 2.13.12 + - 2.13.13 steps: - uses: actions/checkout@v4 - uses: olafurpg/setup-scala@v14 diff --git a/build.sbt b/build.sbt index 8d4e8cd6..72296b4a 100644 --- a/build.sbt +++ b/build.sbt @@ -22,8 +22,8 @@ developers := List( ) ) -scalaVersion := "2.13.12" -crossScalaVersions := Seq("2.12.17", "2.12.18", "2.13.11", "2.13.12") +scalaVersion := "2.13.13" +crossScalaVersions := Seq("2.12.18", "2.12.19", "2.13.12", "2.13.13") autoScalaLibrary := false crossVersion := CrossVersion.full crossTarget := { diff --git a/project/plugins.sbt b/project/plugins.sbt index 89e94ad6..56633526 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -3,7 +3,7 @@ resolvers += Classpaths.sbtPluginReleases addSbtPlugin("com.github.sbt" % "sbt-ci-release" % "1.5.12") addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.14.10") addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.5.2") -addSbtPlugin("org.scoverage" % "sbt-scoverage" % "2.0.10") +addSbtPlugin("org.scoverage" % "sbt-scoverage" % "2.0.11") addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % "0.11.1") if (System.getProperty("add-scapegoat-plugin") == "true") diff --git a/src/main/scala/com/sksamuel/scapegoat/inspections/unneccesary/UnnecessaryConversion.scala b/src/main/scala/com/sksamuel/scapegoat/inspections/unneccesary/UnnecessaryConversion.scala index abd7bee5..d680a7fc 100644 --- a/src/main/scala/com/sksamuel/scapegoat/inspections/unneccesary/UnnecessaryConversion.scala +++ b/src/main/scala/com/sksamuel/scapegoat/inspections/unneccesary/UnnecessaryConversion.scala @@ -1,6 +1,6 @@ package com.sksamuel.scapegoat.inspections.unneccesary -import com.sksamuel.scapegoat.{isScala21312, Inspection, InspectionContext, Inspector, Levels} +import com.sksamuel.scapegoat.{isScala21312OrLater, Inspection, InspectionContext, Inspector, Levels} /** * @author @@ -15,7 +15,7 @@ class UnnecessaryConversion "Calling e.g. toString on a String or toList on a List is completely unnecessary and it's an equivalent to identity." ) { - override def isEnabled: Boolean = !isScala21312 + override def isEnabled: Boolean = !isScala21312OrLater def inspector(ctx: InspectionContext): Inspector = new Inspector(ctx) { override def postTyperTraverser: context.Traverser = new context.Traverser { diff --git a/src/main/scala/com/sksamuel/scapegoat/package.scala b/src/main/scala/com/sksamuel/scapegoat/package.scala index 19ac8849..ecf02ff6 100644 --- a/src/main/scala/com/sksamuel/scapegoat/package.scala +++ b/src/main/scala/com/sksamuel/scapegoat/package.scala @@ -5,5 +5,6 @@ package object scapegoat { private val shortScalaVersion = scalaVersion.split('.').dropRight(1).mkString(".") val isScala213: Boolean = shortScalaVersion == "2.13" - val isScala21312: Boolean = scalaVersion == "2.13.12" + val isScala21312OrLater: Boolean = scalaVersion == "2.13.12" || scalaVersion == "2.13.13" + } diff --git a/src/test/scala/com/sksamuel/scapegoat/inspections/unnecessary/UnnecessaryConversionTest.scala b/src/test/scala/com/sksamuel/scapegoat/inspections/unnecessary/UnnecessaryConversionTest.scala index c8180c13..37b9208c 100644 --- a/src/test/scala/com/sksamuel/scapegoat/inspections/unnecessary/UnnecessaryConversionTest.scala +++ b/src/test/scala/com/sksamuel/scapegoat/inspections/unnecessary/UnnecessaryConversionTest.scala @@ -1,7 +1,7 @@ package com.sksamuel.scapegoat.inspections.unnecessary import com.sksamuel.scapegoat.inspections.unneccesary.UnnecessaryConversion -import com.sksamuel.scapegoat.{isScala21312, Inspection, InspectionTest} +import com.sksamuel.scapegoat.{isScala21312OrLater, Inspection, InspectionTest} /** @author Stephen Samuel */ class UnnecessaryConversionTest extends InspectionTest { @@ -17,7 +17,7 @@ class UnnecessaryConversionTest extends InspectionTest { |}""".stripMargin compileCodeSnippet(code) - val expectedWarnings = if (isScala21312) 0 else 1 + val expectedWarnings = if (isScala21312OrLater) 0 else 1 compiler.scapegoat.feedback.warnings.size shouldBe expectedWarnings } @@ -28,7 +28,7 @@ class UnnecessaryConversionTest extends InspectionTest { |}""".stripMargin compileCodeSnippet(code) - val expectedWarnings = if (isScala21312) 0 else 1 + val expectedWarnings = if (isScala21312OrLater) 0 else 1 compiler.scapegoat.feedback.warnings.size shouldBe expectedWarnings } @@ -39,7 +39,7 @@ class UnnecessaryConversionTest extends InspectionTest { |}""".stripMargin compileCodeSnippet(code) - val expectedWarnings = if (isScala21312) 0 else 2 + val expectedWarnings = if (isScala21312OrLater) 0 else 2 compiler.scapegoat.feedback.warnings.size shouldBe expectedWarnings } @@ -50,7 +50,7 @@ class UnnecessaryConversionTest extends InspectionTest { |}""".stripMargin compileCodeSnippet(code) - val expectedWarnings = if (isScala21312) 0 else 1 + val expectedWarnings = if (isScala21312OrLater) 0 else 1 compiler.scapegoat.feedback.warnings.size shouldBe expectedWarnings } @@ -61,7 +61,7 @@ class UnnecessaryConversionTest extends InspectionTest { |}""".stripMargin compileCodeSnippet(code) - val expectedWarnings = if (isScala21312) 0 else 1 + val expectedWarnings = if (isScala21312OrLater) 0 else 1 compiler.scapegoat.feedback.warnings.size shouldBe expectedWarnings } @@ -72,7 +72,7 @@ class UnnecessaryConversionTest extends InspectionTest { |}""".stripMargin compileCodeSnippet(code) - val expectedWarnings = if (isScala21312) 0 else 1 + val expectedWarnings = if (isScala21312OrLater) 0 else 1 compiler.scapegoat.feedback.warnings.size shouldBe expectedWarnings } @@ -83,7 +83,7 @@ class UnnecessaryConversionTest extends InspectionTest { |}""".stripMargin compileCodeSnippet(code) - val expectedWarnings = if (isScala21312) 0 else 1 + val expectedWarnings = if (isScala21312OrLater) 0 else 1 compiler.scapegoat.feedback.warnings.size shouldBe expectedWarnings } @@ -94,7 +94,7 @@ class UnnecessaryConversionTest extends InspectionTest { |}""".stripMargin compileCodeSnippet(code) - val expectedWarnings = if (isScala21312) 0 else 1 + val expectedWarnings = if (isScala21312OrLater) 0 else 1 compiler.scapegoat.feedback.warnings.size shouldBe expectedWarnings } }