Code Monkey home page Code Monkey logo

Comments (3)

jacbop avatar jacbop commented on July 16, 2024

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.

TonioGela avatar TonioGela commented on July 16, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.