dvreeze / tryscalafix   0.3.0

Apache License 2.0 GitHub

Using Scalafix to aid in understanding (large) Scala code bases

Scala versions: 2.13

Try-Scalafix

This project toys with the idea of using Scalafix for generating "overviews" of large code bases, to aid understanding of those code bases.

The project contains Scalafix semantic rules for this purpose, and therefore depends on Scalameta and SemanticDB.

Typically this project is used with specific ".scalafix.<rule>.<use-case>.conf" files, each one referring to only 1 rule.

In Scala Maven projects:

  • Run program EnhancePom to generate a "pom-semanticdb.xml" enhanced file copy of the POM file, containing Maven profile "semanticdb"
  • Generate ".semanticdb" files
  • Run the chosen rule

Compiling into ".semanticdb" files:

mvn clean compile -Psemanticdb -f pom-semanticdb.xml

Running the rule:

mvn scalafix:scalafix -Dscalafix.config=.scalafix.<XYZ>.conf -Psemanticdb -f pom-semanticdb.xml

If rule ShowTreeAndSymbols should run on one source file, and the chosen config file has this content:

rules = [
  TreeAndSymbolDisplayingRule
]

then we could do so (roughly) as follows:

mvn scalafix:scalafix -Dscalafix.config=.scalafix-TreeAndSymbolDisplayingRule.conf \
  -Dscalafix.command.line.args="--files=src/main/scala/com/test/MyClass.scala" \
  -Psemanticdb -f pom-semanticdb.xml