Skip to content

Commit

Permalink
Merge pull request #10705 from som-snytt/tweak/lint-all
Browse files Browse the repository at this point in the history
Lint all the things [ci: last-only]
  • Loading branch information
lrytz committed Mar 11, 2024
2 parents 4b124f2 + c0e5969 commit 1bdf362
Show file tree
Hide file tree
Showing 49 changed files with 72 additions and 135 deletions.
50 changes: 21 additions & 29 deletions build.sbt
Expand Up @@ -160,16 +160,16 @@ lazy val commonSettings = instanceSettings ++ clearSourceAndResourceDirectories
cleanFiles += (Compile / doc / target).value,
run / fork := true,
run / connectInput := true,
// uncomment for ease of development while breaking things
//Compile / scalacOptions ++= Seq("-Xmaxerrs", "5", "-Xmaxwarns", "5"),
// work around https://github.com/scala/bug/issues/11534
Compile / scalacOptions += "-Wconf:cat=unchecked&msg=The outer reference in this type test cannot be checked at run time.:s",
// we don't want optimizer warnings to interfere with `-Werror`. we have hundreds of such warnings
// when the optimizer is enabled (as it is in CI and release builds, though not in local development)
Compile / scalacOptions += "-Wconf:cat=optimizer:is",
// We use @nowarn for some methods that are deprecated in Java > 8
Compile / scalacOptions += "-Wconf:cat=unused-nowarn:s",
Compile / scalacOptions ++= Seq("-deprecation", "-feature"),
Compile / scalacOptions ++= Seq("-feature", "-Xlint",
//"-Xmaxerrs", "5", "-Xmaxwarns", "5", // uncomment for ease of development while breaking things
// work around https://github.com/scala/bug/issues/11534
"-Wconf:cat=unchecked&msg=The outer reference in this type test cannot be checked at run time.:s",
// optimizer warnings at INFO since `-Werror` may be turned on.
// optimizer runs in CI and release builds, though not in local development.
"-Wconf:cat=optimizer:is",
// we use @nowarn for methods that are deprecated in JDK > 8, but CI/release is under JDK 8
"-Wconf:cat=unused-nowarn:s",
),
Compile / doc / scalacOptions ++= Seq(
"-doc-footer", "epfl",
"-diagrams",
Expand Down Expand Up @@ -412,7 +412,6 @@ lazy val library = configureAsSubproject(project)
name := "scala-library",
description := "Scala Standard Library",
Compile / scalacOptions ++= Seq("-sourcepath", (Compile / scalaSource).value.toString),
Compile / scalacOptions ++= Seq("-Xlint", "-feature"),
Compile / doc / scalacOptions ++= {
val libraryAuxDir = (ThisBuild / baseDirectory).value / "src/library-aux"
Seq(
Expand Down Expand Up @@ -460,7 +459,6 @@ lazy val reflect = configureAsSubproject(project)
name := "scala-reflect",
description := "Scala Reflection Library",
Osgi.bundleName := "Scala Reflect",
Compile / scalacOptions ++= Seq("-Xlint", "-feature"),
Compile / doc / scalacOptions ++= Seq(
"-skip-packages", "scala.reflect.macros.internal:scala.reflect.internal:scala.reflect.io"
),
Expand Down Expand Up @@ -532,8 +530,6 @@ lazy val compiler = configureAsSubproject(project)
).get
},
Compile / scalacOptions ++= Seq(
"-Xlint",
"-feature",
"-Wconf:cat=deprecation&msg=early initializers:s", // compiler heavily relies upon early initializers
),
Compile / doc / scalacOptions ++= Seq(
Expand Down Expand Up @@ -574,15 +570,15 @@ lazy val interactive = configureAsSubproject(project)
.settings(
name := "scala-compiler-interactive",
description := "Scala Interactive Compiler",
Compile / scalacOptions ++= Seq("-Xlint", "-Wconf:cat=deprecation&msg=early initializers:s"),
Compile / scalacOptions ++= Seq("-Wconf:cat=deprecation&msg=early initializers:s"),
)
.dependsOn(compiler)

lazy val repl = configureAsSubproject(project)
.settings(disableDocs)
.settings(fatalWarningsSettings)
.settings(publish / skip := true)
.settings(Compile / scalacOptions ++= Seq("-Xlint", "-Wconf:cat=deprecation&msg=early initializers:s"))
.settings(Compile / scalacOptions ++= Seq("-Wconf:cat=deprecation&msg=early initializers:s"))
.dependsOn(compiler, interactive)

lazy val replFrontend = configureAsSubproject(project, srcdir = Some("repl-frontend"))
Expand All @@ -592,7 +588,6 @@ lazy val replFrontend = configureAsSubproject(project, srcdir = Some("repl-front
.settings(
libraryDependencies ++= jlineDeps,
name := "scala-repl-frontend",
Compile / scalacOptions ++= Seq("-Xlint"),
)
.settings(
run := (Compile / run).partialInput(" -usejavacp").evaluated, // so `replFrontend/run` works
Expand All @@ -612,8 +607,6 @@ lazy val scaladoc = configureAsSubproject(project)
libraryDependencies ++= ScaladocSettings.webjarResources,
Compile / resourceGenerators += ScaladocSettings.extractResourcesFromWebjar,
Compile / scalacOptions ++= Seq(
"-Xlint",
"-feature",
"-Wconf:cat=deprecation&msg=early initializers:s",
),
)
Expand All @@ -629,8 +622,6 @@ lazy val sbtBridge = configureAsSubproject(project, srcdir = Some("sbt-bridge"))
description := "sbt compiler bridge for Scala 2",
libraryDependencies += compilerInterfaceDep % Provided,
Compile / scalacOptions ++= Seq(
"-Xlint",
"-feature",
"-Wconf:cat=deprecation&msg=early initializers:s", // compiler heavily relies upon early initializers
),
generateServiceProviderResources("xsbti.compile.CompilerInterface2" -> "scala.tools.xsbt.CompilerBridge"),
Expand Down Expand Up @@ -687,7 +678,6 @@ lazy val scalap = configureAsSubproject(project)
xs filter { x => !excluded(x.getName) }
},
Compile / headerResources := Nil,
Compile / scalacOptions ++= Seq("-Xlint", "-feature"),
)
.dependsOn(compiler)

Expand All @@ -702,7 +692,6 @@ lazy val partest = configureAsSubproject(project)
libraryDependencies ++= List(testInterfaceDep, diffUtilsDep, junitDep),
Compile / javacOptions ++= Seq("-XDenableSunApiLintControl", "-Xlint") ++
(if (fatalWarnings.value) Seq("-Werror") else Seq()),
Compile / scalacOptions ++= Seq("-feature", "-Xlint"),
pomDependencyExclusions ++= List((organization.value, "scala-repl-frontend"), (organization.value, "scala-compiler-doc")),
fixPom(
"/project/name" -> <name>Scala Partest</name>,
Expand All @@ -720,7 +709,6 @@ lazy val tastytest = configureAsSubproject(project)
name := "scala-tastytest",
description := "Scala TASTy Integration Testing Tool",
libraryDependencies += diffUtilsDep,
Compile / scalacOptions ++= Seq("-feature", "-Xlint"),
)

// An instrumented version of BoxesRunTime and ScalaRunTime for partest's "specialized" test category
Expand Down Expand Up @@ -752,7 +740,6 @@ lazy val specLib = project.in(file("test") / "instrumented")
patch("ScalaRunTime.scala", "srt.patch")
)
}.taskValue,
Compile / scalacOptions ++= Seq("-feature", "-Xlint"),
)

// The scala version used by the benchmark suites, leave undefined to use the ambient version.")
Expand Down Expand Up @@ -790,7 +777,6 @@ lazy val testkit = configureAsSubproject(project)
.settings(
name := "scala-testkit",
description := "Scala Compiler Testkit",
Compile / scalacOptions ++= Seq("-feature", "-Xlint"),
libraryDependencies ++= Seq(junitDep, asmDep),
Compile / unmanagedSourceDirectories := List(baseDirectory.value),
fixPom(
Expand Down Expand Up @@ -819,8 +805,7 @@ lazy val junit = project.in(file("test") / "junit")
(Test / forkOptions) := (Test / forkOptions).value.withWorkingDirectory((ThisBuild / baseDirectory).value),
(Test / testOnly / forkOptions) := (Test / testOnly / forkOptions).value.withWorkingDirectory((ThisBuild / baseDirectory).value),
Compile / scalacOptions ++= Seq(
"-feature",
"-Xlint:-valpattern,_",
"-Xlint:-valpattern",
"-Wconf:msg=match may not be exhaustive:s", // if we missed a case, all that happens is the test fails
"-Wconf:cat=lint-nullary-unit&site=.*Test:s", // normal unit test style
"-Ypatmat-exhaust-depth", "40", // despite not caring about patmat exhaustiveness, we still get warnings for this
Expand Down Expand Up @@ -869,6 +854,9 @@ lazy val tasty = project.in(file("test") / "tasty")
s"-Dtastytest.classpaths.scalaReflect=$scalaReflect",
)
},
Compile / scalacOptions ++= Seq(
"-Wconf:cat=lint-nullary-unit&site=.*Test:s", // normal unit test style
),
)

lazy val scalacheck = project.in(file("test") / "scalacheck")
Expand All @@ -889,7 +877,11 @@ lazy val scalacheck = project.in(file("test") / "scalacheck")
),
libraryDependencies ++= Seq(scalacheckDep, junitDep),
Compile / unmanagedSourceDirectories := Nil,
Test / unmanagedSourceDirectories := List(baseDirectory.value)
Test / unmanagedSourceDirectories := List(baseDirectory.value),
Compile / scalacOptions ++= Seq(
"-Wconf:msg=match may not be exhaustive:s", // if we missed a case, all that happens is the test fails
"-Wconf:msg=Classes which cannot access Tree:s", // extension is irrelevant to tests
),
)

lazy val osgiTestFelix = osgiTestProject(
Expand Down
2 changes: 1 addition & 1 deletion src/manual/scala/tools/docutil/ManMaker.scala
Expand Up @@ -57,7 +57,7 @@ class ManMaker {

/** Command line runner for ManMaker which is called from the sbt build. */
object ManMaker extends App {
val Array(commands, htmlout, manout) = args
val Array(commands, htmlout, manout) = args: @unchecked
val mm = new ManMaker
mm.setCommand(commands)
mm.setHtmlout(new File(htmlout))
Expand Down
6 changes: 3 additions & 3 deletions src/partest/scala/tools/partest/nest/FromString.scala
Expand Up @@ -13,8 +13,6 @@
package scala.tools.partest.nest

import scala.reflect.OptManifest
import scala.sys.process.Parser.tokenize
import scala.tools.nsc.io.Directory

/** A general mechanism for defining how a command line argument
* (always a String) is transformed into an arbitrary type. A few
Expand All @@ -30,6 +28,8 @@ abstract class FromString[+T](implicit m: OptManifest[T]) extends PartialFunctio
}

object FromString {
import scala.sys.process.Parser.tokenize
import scala.tools.nsc.io.Directory
// We need this because we clash with the String => Path implicits.
private def toDir(s: String) = new Directory(new java.io.File(s))

Expand Down Expand Up @@ -66,6 +66,6 @@ object FromString {
*/
implicit val IntFromString: FromString[Int] = new FromString[Int] {
override def isDefinedAt(s: String) = s.toIntOption.isDefined
def apply(s: String) = s.toInt
def apply(s: String) = s.toIntOption.getOrElse(0)
}
}
5 changes: 0 additions & 5 deletions test/osgi/src/BasicLibrary.scala
Expand Up @@ -2,18 +2,13 @@ package tools.test.osgi
package libonly

import org.junit.Assert._
import org.ops4j.pax.exam.CoreOptions._

import org.junit.Test
import org.junit.runner.RunWith
import org.ops4j.pax.exam
import org.ops4j.pax.exam.Configuration
import org.ops4j.pax.exam.junit.PaxExam
import org.ops4j.pax.exam.spi.reactors.{ ExamReactorStrategy, PerMethod }
import org.ops4j.pax.swissbox.tracker.ServiceLookup
import org.osgi.framework.BundleContext



@RunWith(classOf[PaxExam])
@ExamReactorStrategy(Array(classOf[PerMethod]))
Expand Down
6 changes: 0 additions & 6 deletions test/osgi/src/BasicReflection.scala
Expand Up @@ -2,20 +2,14 @@ package tools.test.osgi
package reflection
package basic

import scala.language.higherKinds

import org.junit.Assert._
import org.ops4j.pax.exam.CoreOptions._

import org.junit.Test
import org.junit.runner.RunWith
import org.ops4j.pax.exam
import org.ops4j.pax.exam.Configuration
import org.ops4j.pax.exam.junit.PaxExam
import org.ops4j.pax.exam.spi.reactors.{ ExamReactorStrategy, PerMethod }
import org.ops4j.pax.swissbox.tracker.ServiceLookup
import org.osgi.framework.BundleContext


class C {
val f1 = 2
Expand Down
9 changes: 0 additions & 9 deletions test/osgi/src/BasicTest.scala
@@ -1,20 +1,11 @@
package tools.test.osgi

import org.junit.Assert._
import org.ops4j.pax.exam.CoreOptions._

import org.junit.Test
import org.junit.runner.RunWith
import org.ops4j.pax.exam
import org.ops4j.pax.exam.Configuration
import org.ops4j.pax.exam.junit.PaxExam
import org.ops4j.pax.exam.spi.reactors.{ ExamReactorStrategy, PerMethod }
import org.ops4j.pax.swissbox.tracker.ServiceLookup
import org.osgi.framework.BundleContext





@RunWith(classOf[PaxExam])
@ExamReactorStrategy(Array(classOf[PerMethod]))
Expand Down
5 changes: 1 addition & 4 deletions test/osgi/src/ReflectionToolboxTest.scala
Expand Up @@ -3,17 +3,13 @@ package reflection
package toolbox

import org.junit.Assert._
import org.ops4j.pax.exam.CoreOptions._

import org.junit.Test
import org.junit.runner.RunWith
import org.ops4j.pax.exam
import org.ops4j.pax.exam.Configuration
import org.ops4j.pax.exam.junit.PaxExam
import org.ops4j.pax.exam.spi.reactors.{ ExamReactorStrategy, PerMethod }
import org.ops4j.pax.swissbox.tracker.ServiceLookup
import org.osgi.framework.BundleContext


class C {
val f1 = 2
Expand All @@ -35,6 +31,7 @@ class ReflectionToolBoxTest extends ScalaOsgiHelper {
import scala.tools.reflect.ToolBox
val cm = runtimeMirror(classOf[C].getClassLoader)
val tb = cm.mkToolBox()
@annotation.unused
val im = cm.reflect(new C)
val tree = tb.parse("1 to 3 map (_+1)")
val eval = tb.eval(tree)
Expand Down
4 changes: 1 addition & 3 deletions test/scalacheck/CheckEither.scala
@@ -1,9 +1,7 @@
import org.scalacheck.{ Arbitrary, Prop, Properties }
import org.scalacheck.{Arbitrary, Properties}
import org.scalacheck.Arbitrary.{arbitrary, arbThrowable}
import org.scalacheck.Gen.oneOf
import org.scalacheck.Prop._
import org.scalacheck.Test.check
import Function.tupled
import scala.util.Either.LeftProjection

@annotation.nowarn("cat=deprecation")
Expand Down
6 changes: 4 additions & 2 deletions test/scalacheck/Ctrie.scala
Expand Up @@ -5,6 +5,8 @@ import collection._
import collection.concurrent.TrieMap
import scala.language.reflectiveCalls

import annotation.unused

case class Wrap(i: Int) {
override def hashCode = i // * 0x9e3775cd
}
Expand Down Expand Up @@ -101,7 +103,7 @@ object CtrieTest extends Properties("concurrent.TrieMap") {
val ct = new TrieMap[Wrap, Int]

// checker
val checker = spawn {
@unused val checker = spawn {
def check(last: Map[Wrap, Int], iterationsLeft: Int): Boolean = {
val current = ct.readOnlySnapshot()
if (!hasGrown(last, current)) false
Expand Down Expand Up @@ -187,7 +189,7 @@ object CtrieTest extends Properties("concurrent.TrieMap") {
val totalInserts = new java.util.concurrent.atomic.AtomicInteger
val ct = new TrieMap[Wrap, String]

val results = inParallel(p) {
@unused val results = inParallel(p) {
idx =>
(0 until sz) foreach {
i =>
Expand Down
2 changes: 0 additions & 2 deletions test/scalacheck/SeqMap.scala
Expand Up @@ -5,8 +5,6 @@ import Arbitrary.arbitrary
import Prop._
import Gen._

import scala.collection.mutable.ListBuffer

object SeqMapTest extends Properties("SeqMap") {

property("overrides stringPrefix") = {
Expand Down
1 change: 0 additions & 1 deletion test/scalacheck/array-new.scala
Expand Up @@ -5,7 +5,6 @@ import Gen._
import Arbitrary._
import util._
import Buildable._
import scala.collection.mutable.ArraySeq

object ArrayNewTest extends Properties("Array") {
/** At this moment the authentic scalacheck Array Builder/Arb bits are commented out.
Expand Down
1 change: 0 additions & 1 deletion test/scalacheck/array-old.scala
Expand Up @@ -4,7 +4,6 @@ import Gen._
import Arbitrary._
import util._
import Buildable._
import scala.collection.mutable.ArraySeq

object ArrayOldTest extends Properties("Array") {
/** At this moment the authentic scalacheck Array Builder/Arb bits are commented out.
Expand Down
2 changes: 1 addition & 1 deletion test/scalacheck/primitive-eqeq.scala
Expand Up @@ -15,7 +15,7 @@ object PrimitiveEqEqTest extends Properties("==") {
property("transitivity") = forAll { (x: AnyVal, y: AnyVal, z: AnyVal) => x != y || y != z || x == z }

property("##") = forAll { x: Short =>
val anyvals = List(x.toByte, x.toChar, x, x.toInt, x.toLong, x.toFloat, x.toDouble, BigInt(x), BigDecimal(x))
val anyvals = List[Any](x.toByte, x.toChar, x, x.toInt, x.toLong, x.toFloat, x.toDouble, BigInt(x), BigDecimal(x))
val shortAndLarger = anyvals drop 2

(anyvals.lazyZip(anyvals) forall equalObjectsEqualHashcodes) &&
Expand Down
1 change: 0 additions & 1 deletion test/scalacheck/range.scala
Expand Up @@ -104,7 +104,6 @@ abstract class RangeTest(kind: String) extends Properties("Range "+kind) {
property("foreach.inside.range") = forAll(myGen) { r =>
// println("foreach.inside.range "+str(r))
var allValid = true
var last: Option[Int] = None
val cnt = new Counter(r)
r foreach { x => cnt(x)
allValid &&= within(r, x)
Expand Down

0 comments on commit 1bdf362

Please sign in to comment.