Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Many Of The Warnings #928

Merged
merged 3 commits into from
Nov 30, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion bench/src/main/scala/org/scalacheck/bench/GenBench.scala
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ class GenBench {
// this guarantees a deterministic set of seeds for any given
// seedCount, which helps ensure we're making fair comparisons
// when we benchmark several different branches.
val start = 993423
val start: Long = 993423L
val preseeds = start until (start + seedCount)
seeds = preseeds.map(n => Seed(n)).toList

Expand Down
8 changes: 6 additions & 2 deletions core/js/src/main/scala/org/scalacheck/Platform.scala
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,14 @@

package org.scalacheck

import scala.scalajs.reflect.Reflect

import Test._

import scala.annotation.nowarn
import scala.scalajs.reflect.Reflect

private[scalacheck] object Platform {

@nowarn("msg=is never used")
def runWorkers(
params: Parameters,
workerFun: Int => Result,
Expand All @@ -23,6 +25,7 @@ private[scalacheck] object Platform {
workerFun(0)
}

@nowarn("msg=is never used")
def loadModule(name: String, loader: ClassLoader): AnyRef = {
Reflect
.lookupLoadableModuleClass(name + "$")
Expand All @@ -31,6 +34,7 @@ private[scalacheck] object Platform {
.asInstanceOf[AnyRef]
}

@nowarn("msg=is never used")
def newInstance(name: String, loader: ClassLoader, paramTypes: Seq[Class[_]])(args: Seq[AnyRef]): AnyRef = {
Reflect
.lookupInstantiatableClass(name)
Expand Down
3 changes: 3 additions & 0 deletions core/jvm/src/main/scala/org/scalacheck/Platform.scala
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@

package org.scalacheck

import scala.annotation.nowarn

import Test._

private[scalacheck] object Platform {
Expand Down Expand Up @@ -61,6 +63,7 @@ private[scalacheck] object Platform {
}
}

@nowarn("msg=is never used")
def newInstance(name: String, loader: ClassLoader, paramTypes: Seq[Class[_]])(args: Seq[AnyRef]): AnyRef =
if(!args.isEmpty) ???
else Class.forName(name, true, loader).getDeclaredConstructor().newInstance().asInstanceOf[AnyRef]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import Gen._

import java.time._
import java.time.temporal.ChronoUnit
import java.time.temporal.TemporalUnit
import java.util.Date
import scala.util.{Try, Success, Failure}

Expand All @@ -28,7 +27,7 @@ object ChooseSpecification extends Properties("Choose") with time.OrderingVersio
import O.mkOrderingOps
Try(choose(l, h)) match {
case Success(g) => Prop.forAll(g) { x => l <= x && x <= h }
case Failure(e: Choose.IllegalBoundsError[_]) => l > h
case Failure(_: Choose.IllegalBoundsError[_]) => l > h
case Failure(e) => throw e
}
}
Expand Down
14 changes: 7 additions & 7 deletions core/jvm/src/test/scala/org/scalacheck/GenSpecification.scala
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,12 @@ object GenSpecification extends Properties("Gen") with GenSpecificationVersionSp

property("frequency 1") = {
val g = frequency((10, const(0)), (5, const(1)))
forAll(g) { n => true }
forAll(g) { _ => true }
}

property("frequency 2") = {
val g = frequency((10, 0), (5, 1))
forAll(g) { n => true }
forAll(g) { _ => true }
}

property("frequency 3") = forAll(choose(1,100000)) { n =>
Expand Down Expand Up @@ -84,9 +84,9 @@ object GenSpecification extends Properties("Gen") with GenSpecificationVersionSp
fail(prms, seed) == None
}

property("parameterized") = forAll((g: Gen[Int]) => parameterized(p=>g) == g)
property("parameterized") = forAll((g: Gen[Int]) => parameterized(_=>g) == g)

property("sized") = forAll((g: Gen[Int]) => sized(i => g) == g)
property("sized") = forAll((g: Gen[Int]) => sized(_ => g) == g)

property("resize(sz, posNum)") = forAll { (sz: Int) =>
val g = Gen.resize(sz, Gen.posNum[Int])
Expand Down Expand Up @@ -386,17 +386,17 @@ object GenSpecification extends Properties("Gen") with GenSpecificationVersionSp
// its constructor valid values.
property("BigDecimal") = forAll { (_: BigDecimal) => true }

property("resultOf1") = forAll(resultOf((m: Int) => 0))(_ == 0)
property("resultOf1") = forAll(resultOf((_: Int) => 0))(_ == 0)

property("resultOf2") = {
case class A(m: Int, s: String)
forAll(resultOf(A.apply _)) { (a:A) => true }
forAll(resultOf(A.apply _)) { _ => true }
}

property("resultOf3") = {
case class B(n: Int, s: String, b: Boolean)
implicit val arbB: Arbitrary[B] = Arbitrary(resultOf(B.apply _))
forAll { (b:B) => true }
forAll { (_: B) => true }
}

property("option") = forAll { (n: Int) =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ object LazyPropertiesSpecification extends Properties("Properties.lazy registrat

property("properties registered lazily") = {
var evaluated = false
val p = new Properties("P") {
val _ = new Properties("P") {
property("p") = {
evaluated = true
Prop.proved
Expand All @@ -23,4 +23,3 @@ object LazyPropertiesSpecification extends Properties("Properties.lazy registrat
}

}

Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ package org.scalacheck
import org.apache.commons.lang3.SerializationUtils
import java.io.Serializable

import Prop.proved

import util.SerializableCanBuildFroms._

object SerializabilitySpecification extends Properties("Serializability") {
Expand Down
18 changes: 9 additions & 9 deletions core/jvm/src/test/scala/org/scalacheck/TestSpecification.scala
Original file line number Diff line number Diff line change
Expand Up @@ -20,21 +20,21 @@ object TestSpecification extends Properties("Test") {

val passing = forAll( (n: Int) => n == n )

val failing = forAll( (n: Int) => false )
val failing = forAll( (_: Int) => false )

val exhausted = forAll( (n: Int) =>
(n > 0 && n < 0) ==> (n == n)
)

val shrunk = forAll( (t: (Int,Int,Int)) => false )
val shrunk = forAll( (_: (Int,Int,Int)) => false )

val propException = forAll { (n:Int) => throw new java.lang.Exception }
val propException = forAll { (_:Int) => throw new java.lang.Exception }

val undefinedInt = for{
n <- arbitrary[Int]
} yield n/0

val genException = forAll(undefinedInt)((n: Int) => true)
val genException = forAll(undefinedInt)((_: Int) => true)

property("workers") = forAll { (prms: Test.Parameters) =>
var res = true
Expand Down Expand Up @@ -120,7 +120,7 @@ object TestSpecification extends Properties("Test") {
Test.check(prms, shrunk).status match {
case Failed(Arg(_,(x:Int,y:Int,z:Int),_,_,_,_)::Nil,_) =>
x == 0 && y == 0 && z == 0
case x => false
case _ => false
}
}

Expand All @@ -133,13 +133,13 @@ object TestSpecification extends Properties("Test") {
var shrunk: Boolean = false

implicit def shrinkBogus: Shrink[Bogus] = {
Shrink { (b: Bogus) => shrunk = true; Stream.empty }
Shrink { (_: Bogus) => shrunk = true; Stream.empty }
}
}

case class Bogus(x: Int)

val prop = Prop.forAll[Bogus, Prop](Bogus.gen) { b => Prop(false) }
val prop = Prop.forAll[Bogus, Prop](Bogus.gen) { _ => Prop(false) }
val prms = Test.Parameters.default.disableLegacyShrinking
val res = Test.check(prms, prop)
Prop(!res.passed && !Bogus.shrunk)
Expand Down Expand Up @@ -195,7 +195,7 @@ object TestSpecification extends Properties("Test") {
val seed = rng.Seed.fromBase64("aaaaa_mr05Z_DCbd2PyUolC0h93iH1MQwIdnH2UuI4L=").get
val gen = Gen.choose(Int.MinValue, Int.MaxValue)
val expected = gen(Gen.Parameters.default, seed).get

val prms = Test.Parameters.default
.withInitialSeed(Some(seed))
.withMinSuccessfulTests(10)
Expand All @@ -207,7 +207,7 @@ object TestSpecification extends Properties("Test") {
true
}

val res = Test.check(prms, prop)
Test.check_(prms, prop)
val n = xs.size
val unique = xs.toSet
val p0 = Prop(unique(expected)) :| s"did not see $expected in $unique"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ object CommandsShrinkSpecification extends Properties("Commands Shrinking") {
// command sequence contains the Dequeue command, we will invoke
// Nil.tail which will raise UnsupportedOperationException.
result.status match {
case Prop.Exception(e: UnsupportedOperationException) => false
case Prop.Exception(_: UnsupportedOperationException) => false
case _ => true
}
}
Expand Down
4 changes: 4 additions & 0 deletions core/native/src/main/scala/org/scalacheck/Platform.scala
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,12 @@ package org.scalacheck

import Test._

import scala.annotation.nowarn
import scala.scalanative.reflect.Reflect

private[scalacheck] object Platform {

@nowarn("msg=is never used")
def runWorkers(
params: Parameters,
workerFun: Int => Result,
Expand All @@ -23,6 +25,7 @@ private[scalacheck] object Platform {
workerFun(0)
}

@nowarn("msg=is never used")
def loadModule(name: String, loader: ClassLoader): AnyRef = {
Reflect
.lookupLoadableModuleClass(name + "$")
Expand All @@ -31,6 +34,7 @@ private[scalacheck] object Platform {
.asInstanceOf[AnyRef]
}

@nowarn("msg=is never used")
def newInstance(name: String, loader: ClassLoader, paramTypes: Seq[Class[_]])(args: Seq[AnyRef]): AnyRef = {
Reflect
.lookupInstantiatableClass(name)
Expand Down
5 changes: 2 additions & 3 deletions core/shared/src/main/scala/org/scalacheck/Arbitrary.scala
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

package org.scalacheck

import language.higherKinds
import concurrent.Future
import scala.util.{Failure, Success, Try}
import scala.concurrent.duration.{Duration, FiniteDuration}
Expand All @@ -22,7 +21,7 @@ import util.SerializableCanBuildFroms._
*
* The [[Arbitrary]] module defines implicit generator instances for
* common types.
*
*
* The implicit definitions of [[Arbitrary]] provide type-directed
* [[Gen]]s so they are available for properties, generators, or other
* definitions of [[Arbitrary]].
Expand Down Expand Up @@ -261,7 +260,7 @@ private[scalacheck] sealed trait ArbitraryLowPriority {
} yield {
try {
BigDecimal(n, scale, mc)
} catch { case ae: ArithmeticException =>
} catch { case _: ArithmeticException =>
// Handle the case where scale/precision conflict
BigDecimal(n, scale, UNLIMITED)
}
Expand Down
1 change: 0 additions & 1 deletion core/shared/src/main/scala/org/scalacheck/Cogen.scala
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

package org.scalacheck

import language.higherKinds
import scala.annotation.tailrec
import scala.collection.immutable.BitSet
import scala.util.{Failure, Success, Try}
Expand Down
Loading