From 56b6fb0bac70f607f36974e17ed2ae9c99adc7f2 Mon Sep 17 00:00:00 2001 From: David Gregory <2992938+DavidGregory084@users.noreply.github.com> Date: Thu, 6 Jul 2023 17:36:40 +0100 Subject: [PATCH] Update the README to warn about ScalaTest / -Wnonunit-statement --- README.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/README.md b/README.md index 0d14aec..3a5753e 100644 --- a/README.md +++ b/README.md @@ -22,6 +22,20 @@ Once you are using this plugin we recommend that you don't manipulate the `scala Instead you should modify the `tpolecatScalacOptions` key or the options key for the relevant mode, for example `tpolecatDevModeOptions` for the development mode. +### ScalaTest warnings + +One of the options configured by **sbt-tpolecat** (`-Wnonunit-statement`) is designed to warn users about discarded values in their code. + +However, Scalatest assertions return a value of type `Assertion` by design, in order to support async testing. + +Unfortunately, this means that in synchronous test suites, every assertion discards this `Assertion` value, triggering the `-Wnonunit-statement` compiler warning. + +If you find yourself in this situation, you can disable the `-Wnonunit-discard` option in your test suite like so: + +```scala +Test / tpolecatExcludeOptions += ScalacOptions.warnNonUnitStatement +``` + ### Configuring the REPL To filter out scala compiler options that don't work well in the REPL, use the `tpolecatExcludeOptions`.