Skip to content

Commit

Permalink
support upcoming 3.3.4 for unused warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
bjaglin committed Jul 29, 2024
1 parent a34120c commit 7a9d9e4
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 9 deletions.
2 changes: 1 addition & 1 deletion docs/rules/OrganizeImports.md
Original file line number Diff line number Diff line change
Expand Up @@ -1277,7 +1277,7 @@ Remove unused imports.
> The `removeUnused` option is not supported for source files compiled with
> early versions of Scala 3 as these do not export SemanticDB diagnostics for
> unused imports. You must compile with Scala 3.4.0 or later to use it.
> unused imports. You must compile with Scala 3.3.4 or later to use it.
### Value type

Expand Down
2 changes: 1 addition & 1 deletion docs/rules/RemoveUnused.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ example diff from running `sbt "scalafix RemoveUnused"`.
To use this rule:

- Enable the Scala compiler option `-Ywarn-unused` (2.12), `-Wunused` (2.13),
or `-Wunused:all` (3.4+).
or `-Wunused:all` (3.3.4+).
- Disable `-Xfatal-warnings` if you have it enabled. This is required so the
compiler warnings do not fail the build before running Scalafix. If you are
running 2.12.13+ or 2.13.2+, you may keep `-Xfatal-warnings` by modifying how
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -864,7 +864,7 @@ object OrganizeImports {
scalaVersion: String
): Configured[Rule] = {
val hasCompilerSupport =
Seq("3.0", "3.1", "3.2", "3.3")
Seq("3.0", "3.1", "3.2", "3.3.0", "3.3.1", "3.3.2", "3.3.3")
.forall(v => !scalaVersion.startsWith(v))

val hasWarnUnused = hasCompilerSupport && {
Expand Down Expand Up @@ -915,13 +915,14 @@ object OrganizeImports {
else if (hasCompilerSupport)
Configured.error(
"A Scala compiler option is required to use OrganizeImports with"
+ " \"OrganizeImports.removeUnused\" set to true. To fix this problem, update your"
+ " build to add `-Ywarn-unused-import` (2.12) or `-Wunused:imports` (2.13 and 3.4+)."
+ " \"OrganizeImports.removeUnused\" set to true. To fix this"
+ " problem, update your build to add `-Ywarn-unused-import` (2.12)"
+ " or `-Wunused:imports` (2.13 and 3.3.4+)."
)
else
Configured.error(
"\"OrganizeImports.removeUnused\"" + s"is not supported on $scalaVersion as the compiler is"
+ " not providing enough information. Please upgrade the Scala compiler to 3.4.0 or greater."
+ " not providing enough information. Please upgrade the Scala compiler to 3.3.4 or greater."
+ " Otherwise, run the rule with \"OrganizeImports.removeUnused\" set to false"
+ " to organize imports while keeping potentially unused imports."
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class RemoveUnused(config: RemoveUnusedConfig)
private def warnUnusedString = List("-Xlint", "-Xlint:unused")
override def withConfiguration(config: Configuration): Configured[Rule] = {
val diagnosticsAvailableInSemanticdb =
Seq("3.0", "3.1", "3.2", "3.3")
Seq("3.0", "3.1", "3.2", "3.3.0", "3.3.1", "3.3.2", "3.3.3")
.forall(v => !config.scalaVersion.startsWith(v))

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

0 comments on commit 7a9d9e4

Please sign in to comment.