Skip to content


Repository files navigation


Build Status

Join the chat at

ScalaClean is a full program static analysis tool. By looking at the entire program as a single entity we can do an in-depth analysis that is not available when working file by file as most current static analysis tools do.

Current Status

Runnable, but probably will do something bad ;). See the instructions below if you want to give it a try.


  • Scala 2.12.5
  • Scala 2.13.6 (See Scala 2_13 branch)


  • Dead code detection removal
  • adjust method/class/package visibility to minimum
  • find and remove unused parameters (e.g. overriding method but parameter is not used anywhere)
  • Many more


  • Run it on more things an fix the bugs

Running against an external project

We don't currently have a full sbt plugin or publish artifacts so you will need to do some of the legwork yourself.

1. Clone the repo

2. Build the compiler plugin

sbt analysisPlugin/assembly

This will create a jar for the compiler plugin.

You will need to find the full path for the file e.g.


3. Update your build to pull in semanticDB and the ScalaClean plugin.

Manually add the ScalaClean plugin to your project definition(s) - this will be automated later:

  scalacOptions ++= {
    val srcLocations = (sourceDirectories in Compile).value.mkString(

4. Now build your project

All being well you should now have a number of files in your META-INF directory:

E.g. for akka-actor in /akka-actor/target/classes/META-INF/ I have:


5. Build the ScalaClean main:

In ScalaClean sbt command/assembly

Creates: /workspace/ScalaClean/command/target/scala-2.12/command-assembly-0.1.0-SNAPSHOT.jar (your location may vary)

Now you can run ScalaClean using this jar. Point ScalaClean at your projects files e.g.:

java -cp $SCALACLEAN_JAR scalaclean.rules.deadcode.FullDeadCodeRemover --filesRoot ./akka-actor/target/classes/META-INF

By default it will print out the diff that it computes. To apply the changes directly add --replace to the command before the list of files. BEWARE - This is destructive - do not run it on code you care about that you do not already.

6. Report the bugs

Look at the output, determine if the output does not meet your expectations (one of the steps failed or the result is broken wrong) then drop us a bug report - we would love to hear about it. If you are feeling especially kind a bit of investigation and a sample project (see testProjects/deadCodeXXX for examples that we are using for testing. )

Useful links


Full program static analysis for Scala







No releases published