Skip to content

xplosunn/ForceOverrides

Repository files navigation

ForceOverrides

Scalafix rule to force explicit overriding.

Given the following example:

trait Printer {
  def print(s: String): Unit
}

object StdOut extends Printer {
  def print(sx: String): Unit = System.out.print(sx)
}

This rule re-writes the code to:

trait Printer {
  def print(s: String): Unit
}

object StdOut extends Printer {
  override def print(sx: String): Unit = System.out.print(sx)
}

Usage

Add to build.sbt:

ThisBuild / scalafixDependencies += "com.github.xplosunn" %% "ForceOverrides" % "0.0.3"

Add to .scalafix.conf:

fix.ForceOverrides