Example project used for the Functional World presentation on high-quality Scala code.
This is a sbt multi-module project with the following modules:
api
- Contains only interfaces and specifications about the expected behavior of any implementation of the game.squared
- An implementation for the classic Minesweeper in a squared board.cli
- Command line interface for any implementation of the API.cli-squared
- Combination of CLI with the squared implementation.
This project is built using sbt for Scala on the JVM. Both sbt and the JDK are needed in order to be able to build and run the code. The file .tool-versions contains the exact versions used during the development of this project.
It is recommended to use asdf such that just doing asdf install
will
install and provide the correct tools versions.
You can expect all the usual sbt commands to work, for example compile
, test
, or api/compile
.
There are some sbt command alias provided as well:
checkFormat
- Check all Scala files to verify their formatting.lint
- Compile with strict flags enabled plus wartremover checks.testCoverage
- Enable coverage, run test, generate a report, and verify that minimum code coverage is reached.mutationTest
- Introduce changes to the code, run tests, and verify that some test fails.verify
- Run all the above sequentially.
Here's a list of the tools used in the project. Some of them are sbt plugins that add their own commands. See the corresponding documentation to find more about how they work:
- Scalafmt - Code formatter
- sbt-tpolecat - Strict scalac options
- WartRemover - Static linter
- MUnit - Test execution framework
- ScalaCheck - Property-based testing library
- sbt-scoverage - Code coverage
- Stryker - Mutation testing