Skip to content

Commit 1ba96c3

Browse files
committed
support upcoming 3.3.4 for unused warnings
scala/scala3#17835 (comment)
1 parent f354dae commit 1ba96c3

File tree

4 files changed

+10
-9
lines changed

4 files changed

+10
-9
lines changed

docs/rules/OrganizeImports.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1277,7 +1277,7 @@ Remove unused imports.
12771277
12781278
> The `removeUnused` option is not supported for source files compiled with
12791279
> early versions of Scala 3 as these do not export SemanticDB diagnostics for
1280-
> unused imports. You must compile with Scala 3.4.0 or later to use it.
1280+
> unused imports. You must compile with Scala 3.3.4 or later to use it.
12811281
12821282
### Value type
12831283

docs/rules/RemoveUnused.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ example diff from running `sbt "scalafix RemoveUnused"`.
1515
To use this rule:
1616

1717
- Enable the Scala compiler option `-Ywarn-unused` (2.12), `-Wunused` (2.13),
18-
or `-Wunused:all` (3.4+).
18+
or `-Wunused:all` (3.3.4+).
1919
- Disable `-Xfatal-warnings` if you have it enabled. This is required so the
2020
compiler warnings do not fail the build before running Scalafix. If you are
2121
running 2.12.13+ or 2.13.2+, you may keep `-Xfatal-warnings` by modifying how

scalafix-rules/src/main/scala/scalafix/internal/rule/OrganizeImports.scala

+5-4
Original file line numberDiff line numberDiff line change
@@ -864,7 +864,7 @@ object OrganizeImports {
864864
scalaVersion: String
865865
): Configured[Rule] = {
866866
val hasCompilerSupport =
867-
Seq("3.0", "3.1", "3.2", "3.3")
867+
Seq("3.0", "3.1", "3.2", "3.3.0", "3.3.1", "3.3.2", "3.3.3")
868868
.forall(v => !scalaVersion.startsWith(v))
869869

870870
val hasWarnUnused = hasCompilerSupport && {
@@ -915,13 +915,14 @@ object OrganizeImports {
915915
else if (hasCompilerSupport)
916916
Configured.error(
917917
"A Scala compiler option is required to use OrganizeImports with"
918-
+ " \"OrganizeImports.removeUnused\" set to true. To fix this problem, update your"
919-
+ " build to add `-Ywarn-unused-import` (2.12) or `-Wunused:imports` (2.13 and 3.4+)."
918+
+ " \"OrganizeImports.removeUnused\" set to true. To fix this"
919+
+ " problem, update your build to add `-Ywarn-unused-import` (2.12)"
920+
+ " or `-Wunused:imports` (2.13 and 3.3.4+)."
920921
)
921922
else
922923
Configured.error(
923924
"\"OrganizeImports.removeUnused\"" + s"is not supported on $scalaVersion as the compiler is"
924-
+ " not providing enough information. Please upgrade the Scala compiler to 3.4.0 or greater."
925+
+ " not providing enough information. Please upgrade the Scala compiler to 3.3.4 or greater."
925926
+ " Otherwise, run the rule with \"OrganizeImports.removeUnused\" set to false"
926927
+ " to organize imports while keeping potentially unused imports."
927928
)

scalafix-rules/src/main/scala/scalafix/internal/rule/RemoveUnused.scala

+3-3
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class RemoveUnused(config: RemoveUnusedConfig)
3333
private def warnUnusedString = List("-Xlint", "-Xlint:unused")
3434
override def withConfiguration(config: Configuration): Configured[Rule] = {
3535
val diagnosticsAvailableInSemanticdb =
36-
Seq("3.0", "3.1", "3.2", "3.3")
36+
Seq("3.0", "3.1", "3.2", "3.3.0", "3.3.1", "3.3.2", "3.3.3")
3737
.forall(v => !config.scalaVersion.startsWith(v))
3838

3939
val hasWarnUnused = config.scalacOptions.exists(option =>
@@ -44,11 +44,11 @@ class RemoveUnused(config: RemoveUnusedConfig)
4444
Configured.error(
4545
"""|A Scala compiler option is required to use RemoveUnused. To fix this problem,
4646
|update your build to add -Ywarn-unused (with 2.12), -Wunused (with 2.13), or
47-
|-Wunused:all (with 3.4+)""".stripMargin
47+
|-Wunused:all (with 3.3.4+)""".stripMargin
4848
)
4949
} else if (!diagnosticsAvailableInSemanticdb) {
5050
Configured.error(
51-
"You must use a more recent version of the Scala 3 compiler (3.4+)"
51+
"You must use a more recent version of the Scala 3 compiler (3.3.4+)"
5252
)
5353
} else {
5454
config.conf

0 commit comments

Comments
 (0)