xuwei-k / unused-code   0.4.1

MIT License GitHub

find and remove unused scala code

Scala versions: 2.13 2.12
sbt plugins: 1.x

Unused Code

maven scaladoc

find and warn, remove unused public classes, methods by scalafix SyntacticRule.

setup

project/plugins.sbt

addSbtPlugin("com.github.xuwei-k" % "unused-code-plugin" % "version")

sbt shell

> unusedCode
> scalafix WarnUnusedCode
> scalafix RemoveUnusedCode

config example

build.sbt

import scala.concurrent.duration.*

ThisBuild / unusedCodeConfig ~= { c =>
  c.copy(
    excludeNameRegex = Set(
      ".*Server"
    ),
    excludePath = c.excludePath ++ Set(
      "glob:some-project/**"
    ),
    excludeGitLastCommit = Some(
      365.days
    ),
    excludeMainMethod = false,
    dialect = unused_code.Dialect.Scala3,
  )
}