Scalafix is the refactoring and linting tool for Scala. Scalafix is a tool and a collection of rule that one can apply in its codebase to refactor some patterns or to get some linting errors.
Examples of rules are:
Remove unused: remove the unused import or unused variables
Explicit result type: add the return type of public members automatically
Disable syntax: disable some of the Scala syntax (throw, var...)
Scalafix is also a library that one can use to define its own rule.
Scala 3 new syntax
In Scala 3, we have a new control structure syntax and the new indentation syntax.
The goal of the project is to create Scalafix rules to refactor a codebase to the new control structure syntax and to the significant indentation syntax.
Those rules are already implemented in the Scala 3 compiler itself, however they are not very flexible:
we cannot have configuration on them
we can hardly configure which files to rewrite and which not to rewrite
With Scalafix we can have some configuration:
to keep or remove braces of the control structures
to activate or deactivate the fewer-braces rewrite
to add back-ticks around operator or keep braces
We can try to merge both rules in a single one.
We can integrate the rule in Metals to run the rule in a single file.
Expected outcome
We expect the student to implement the rewrite rules and to define some meaningful configuration on them.
An important requirement are the tests: each rule and configuration should be well-tested using the Scalafix test infrastructure.
Context
Scalafix
Scalafix is the refactoring and linting tool for Scala. Scalafix is a tool and a collection of rule that one can apply in its codebase to refactor some patterns or to get some linting errors. Examples of rules are:
throw
,var
...)Scalafix is also a library that one can use to define its own rule.
Scala 3 new syntax
In Scala 3, we have a new control structure syntax and the new indentation syntax.
Control structure syntax
https://docs.scala-lang.org/scala3/reference/other-new-features/control-syntax.html
Traditional Scala 2 syntax:
New Scala 3 syntax:
Indentation syntax
https://docs.scala-lang.org/scala3/reference/other-new-features/indentation.html#
Traditional curly-brace syntax:
New Scala 3 significant indentation syntax:
Description of the project
The goal of the project is to create Scalafix rules to refactor a codebase to the new control structure syntax and to the significant indentation syntax.
Those rules are already implemented in the Scala 3 compiler itself, however they are not very flexible:
With Scalafix we can have some configuration:
We can try to merge both rules in a single one.
We can integrate the rule in Metals to run the rule in a single file.
Expected outcome
We expect the student to implement the rewrite rules and to define some meaningful configuration on them.
An important requirement are the tests: each rule and configuration should be well-tested using the Scalafix test infrastructure.
Supervisor
Adrien Piquerez(adrien.piquerez@epfl.ch): Tooling Engineer at the Scala Center