scalafix icon indicating copy to clipboard operation
scalafix copied to clipboard

RemoveUnused: Expression parentheses not properly handled after removing unused variable

Open nox213 opened this issue 1 year ago • 1 comments
trafficstars

Removing an unused variable with Scalafix’s RemoveUnused rule leaves unbalanced parentheses in expressions, resulting in invalid syntax.

scala version: 2.13.13 sbt version: 1.10.1 scalafix version: 0.12.1

build.sbt

ThisBuild / scalaVersion := "2.13.13"
ThisBuild / semanticdbEnabled := true
ThisBuild / semanticdbVersion := scalafixSemanticdb.revision

lazy val root = (project in file("."))
  .settings(
    name := "Test",
    scalacOptions += {
      "-Wunused:locals"
    }
  )

Before

object Main {
  def main(args: Array[String]): Unit = {
    val a: Int =
      (3
        + 4)
  }
}

After

object Main {
  def main(args: Array[String]): Unit = {
    3
        + 4)
  }
}

nox213 avatar Aug 30 '24 06:08 nox213

Thanks for the great bug report! I'll try to look at it in the coming days.

bjaglin avatar Aug 31 '24 17:08 bjaglin