File tree Expand file tree Collapse file tree 3 files changed +16
-10
lines changed
scalafix-cli/src/main/scala/scalafix/internal/interfaces
scalafix-tests/unit/src/test/scala/scalafix/tests/interfaces Expand file tree Collapse file tree 3 files changed +16
-10
lines changed Original file line number Diff line number Diff line change @@ -251,6 +251,10 @@ final case class ScalafixArgumentsImpl(args: Args = Args.default)
251251 copy(args = args.copy(scalacOptions = options.asScala.toList))
252252
253253 override def withScalaVersion (version : String ): ScalafixArguments = {
254+ if (version.startsWith(" 2.11" ))
255+ throw new ScalafixMainArgsException (
256+ " Scala 2.11 is no longer supported; the final version supporting it is Scalafix 0.10.4"
257+ )
254258 ScalaVersion
255259 .from(version) match {
256260 case Success (value) => copy(args = args.copy(scalaVersion = value))
Original file line number Diff line number Diff line change @@ -24,7 +24,9 @@ final class ScalafixImpl extends Scalafix {
2424 override def supportedScalaVersions (): Array [String ] =
2525 Versions .supportedScalaVersions.toArray
2626 override def scala211 (): String =
27- throw new java.lang.UnsupportedOperationException ()
27+ throw new java.lang.UnsupportedOperationException (
28+ " Scala 2.11 is no longer supported; the final version supporting it is Scalafix 0.10.4"
29+ )
2830 override def scala212 (): String =
2931 Versions .scala212
3032 override def scala213 (): String =
Original file line number Diff line number Diff line change @@ -7,7 +7,6 @@ import java.nio.file.Paths
77import java .util .Collections
88
99import scala .collection .JavaConverters ._
10- import scala .util .Failure
1110import scala .util .Try
1211
1312import scala .meta .internal .io .FileIO
@@ -507,14 +506,15 @@ class ScalafixArgumentsSuite extends AnyFunSuite with DiffAssertions {
507506
508507 test(" withScalaVersion: non-parsable scala version" ) {
509508 val run = Try (api.withScalaVersion(" 213" ))
510- assert(run.isFailure)
511- run match {
512- case Failure (exception) =>
513- assert(
514- exception.getMessage == " Failed to parse the Scala version"
515- )
516- case _ => ()
517- }
509+ val expectedErrorMessage = " Failed to parse the Scala version"
510+ assert(run.failed.toOption.map(_.getMessage) == Some (expectedErrorMessage))
511+ }
512+
513+ test(" Scala 2.11 is no longer supported" ) {
514+ val run = Try (api.withScalaVersion(" 2.11.12" ))
515+ val expectedErrorMessage =
516+ " Scala 2.11 is no longer supported; the final version supporting it is Scalafix 0.10.4"
517+ assert(run.failed.toOption.map(_.getMessage) == Some (expectedErrorMessage))
518518 }
519519
520520 def removeUnsuedRule (): SemanticRule = {
You can’t perform that action at this time.
0 commit comments