Comments (3)
Here is my build.sbt
import Dependencies.*
import org.typelevel.scalacoptions.ScalacOptions
import sbt.Keys.libraryDependencies
val scalaV = "3.3.3"
val commonSettings = Seq(
scalaVersion := scalaV,
organization := "com.test",
scalacOptions ++= Seq("-no-indent"),
tpolecatScalacOptions += ScalacOptions.sourceFuture,
libraryDependencies ++= coreLibraries,
libraryDependencies ++= testLibraries
)
lazy val root: Project = (project in file("."))
.settings(
name := "test-app",
Compile / mainClass := Some("com.test.Main"),
commonSettings,
run / fork := true
)
.enablePlugins(JavaAppPackaging)
my plugins.sbt config
addSbtPlugin("org.typelevel" % "sbt-tpolecat" % "0.5.1") //Adds useful compiler warnings
addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.5.2") //Formats code
addSbtPlugin("com.github.sbt" % "sbt-native-packager" % "1.9.16") //Allows distributing your app
and my dependencies
import sbt._
object Dependencies {
// Core deps
val catsEffectV = "3.5.4"
val catsV = "2.10.0"
// Test deps
val scalaCheckV = "1.17.0"
val scalaTestScalacheckV = "3.2.18.0"
val scalaTestV = "3.2.18"
lazy val coreLibraries = Seq(
"org.typelevel" %% "cats-core" % catsV,
"org.typelevel" %% "cats-effect" % catsEffectV // Concurrency and Pure FP
)
lazy val testLibraries = Seq(
"org.scalacheck" %% "scalacheck" % scalaCheckV % Test,
"org.scalatest" %% "scalatest" % scalaTestV % Test,
"org.scalatestplus" %% "scalacheck-1-17" % scalaTestScalacheckV % Test
)
}
from sbt-tpolecat.
Is this a regression issue or a desired functionality change between 0.5.0 and 0.5.1?
This flag got in by default when updating typelevel/scalac-options
and I'm prone to say that is a desired functionality, as in general, it warns you when you forget unused stuff, i.e.
//> using scala 3.4.1
//> using toolkit typelevel::latest
//> using option -Wnonunit-statement
import cats.effect.*
object Main extends IOApp.Simple:
def run: IO[Unit] =
IO.pure("discarded") // <-- you'll get a warn here
IO.println("foo") *> IO.println("bar")
As per your case, I'll try to reproduce it with sbt, as with scala-cli it doesn't appear to be faulty:
//> using scala 3.3.3
//> using dep org.scalatest::scalatest::3.2.18
//> using option -Wnonunit-statement, -Wunused:nowarn
import org.scalatest.freespec.AnyFreeSpec
import org.scalatest.matchers.should.Matchers
import scala.annotation.nowarn
@nowarn("msg=unused value of type org\\.scalatest\\.Assertion")
class MainSpec extends AnyFreeSpec with Matchers:
"unused value warnings" in {
"3".toInt shouldBe 3
"4".toInt shouldBe 4
}
A thing to bear in mind is that the syntax for nowarn is @nowarn("msg=<regex>")
so theoretically you might want to escape the dots if you're planning to match against the exact string (i.e. @nowarn("msg=unused value of type org\\.scalatest\\.Assertion")
)
Also, I suggest you using -Wunused:nowarn
for debug, so that you might get a warn even when a nowarn gets unused (maybe because the regex isn't matching).
from sbt-tpolecat.
Related Issues (20)
- Scala.js options overwritten on Scala 3 HOT 8
- Extract settings DSL into a library HOT 1
- Error when enabling scalafix in multi project build on versions > 0.3.1 HOT 4
- Is it possible to disable the unused warnings for generated src code in `target/src_manged`? HOT 7
- warnUnused is reporting on Assertions HOT 17
- Warn unused is reporting on XML literals HOT 3
- Set every tpolecatOptionsMode with tpolecatDevMode
- `-source` choices passed to scalac 3.* via space instead of colon and gets ignored. HOT 1
- New linting options for 3.3.0 HOT 1
- Change modes in intellij HOT 2
- Support `safe-init` in Scala 3
- warnNonUnitStatement has no effect in Scala 3.3.x HOT 1
- Scala 3's -Yexplicit-nulls HOT 5
- Consider verbose warnings
- `-Wnonunit-statement` seems not to work for scala-3 (3.3.3) HOT 3
- `tpolecatOptionsMode` is ignored in test scope HOT 5
- `-Xcheckinit` should not be enabled by default HOT 5
- Write a Scalafix migration to migrate usages of the old package name
- Add this project to Typelevel Steward's repo list
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sbt-tpolecat.