reduce compiler warnings

This commit is contained in:
Eugene Yokota 2020-01-08 09:41:29 -05:00
parent b37bad6644
commit 36a16673c0
12 changed files with 34 additions and 19 deletions

View File

@ -686,9 +686,11 @@ lazy val commandProj = (project in file("main-command"))
testedBaseSettings,
name := "Command",
libraryDependencies ++= Seq(launcherInterface, sjsonNewScalaJson.value, templateResolverApi),
libraryDependencies ++= (scalaVersion.value match {
case v if v.startsWith("2.12.") => List(compilerPlugin(silencerPlugin))
case _ => List()
}),
Compile / scalacOptions += "-Ywarn-unused:-locals,-explicits,-privates",
// Removing -Xfatal-warnings is necessary because BasicKeys contains a Key for a deprecated class.
Compile / scalacOptions -= "-Xfatal-warnings",
managedSourceDirectories in Compile +=
baseDirectory.value / "src" / "main" / "contraband-scala",
sourceManaged in (Compile, generateContrabands) := baseDirectory.value / "src" / "main" / "contraband-scala",
@ -863,7 +865,10 @@ lazy val mainProj = (project in file("main"))
log4jDependencies ++
Seq(scalaCacheCaffeine, lmCoursierShaded)
},
Compile / scalacOptions -= "-Xfatal-warnings",
libraryDependencies ++= (scalaVersion.value match {
case v if v.startsWith("2.12.") => List(compilerPlugin(silencerPlugin))
case _ => List()
}),
managedSourceDirectories in Compile +=
baseDirectory.value / "src" / "main" / "contraband-scala",
sourceManaged in (Compile, generateContrabands) := baseDirectory.value / "src" / "main" / "contraband-scala",

View File

@ -9,6 +9,7 @@ package sbt
import java.io.File
import com.github.ghik.silencer.silent
import sbt.internal.inc.classpath.{ ClassLoaderCache => IncClassLoaderCache }
import sbt.internal.classpath.ClassLoaderCache
import sbt.internal.server.ServerHandler
@ -34,7 +35,7 @@ object BasicKeys {
"The function that constructs the command prompt from the current build state.",
10000
)
val watch =
@silent val watch =
AttributeKey[Watched]("watched", "Continuous execution configuration.", 1000)
val serverPort =
AttributeKey[Int]("server-port", "The port number used by server command.", 10000)

View File

@ -3641,6 +3641,7 @@ object Classpaths {
ivyRepo.descriptorOptional
} catch { case _: NoSuchMethodError => false }
@com.github.ghik.silencer.silent
private[this] def bootRepository(repo: xsbti.Repository): Resolver = {
import xsbti.Predefined
repo match {
@ -3878,6 +3879,7 @@ trait BuildExtra extends BuildCommon with DefExtra {
// I tried "Def.spaceDelimited().parsed" (after importing Def.parserToInput)
// but it broke actions/run-task
// Maybe it needs to be defined inside a Def.inputTask?
@com.github.ghik.silencer.silent
def inputTask[T](f: TaskKey[Seq[String]] => Initialize[Task[T]]): Initialize[InputTask[T]] =
InputTask.apply(Def.value((s: State) => Def.spaceDelimited()))(f)
@ -3947,7 +3949,7 @@ trait BuildCommon {
/**
* Allows a String to be used where a `NameFilter` is expected.
* Asterisks (`*`) in the string are interpreted as wildcards.
* All other characters must match exactly. See [[sbt.io.GlobFilter]].
* All other characters must match exactly. See GlobFilter.
*/
implicit def globFilter(expression: String): NameFilter = GlobFilter(expression)

View File

@ -154,6 +154,7 @@ object EvaluateTask {
import Keys.state
import std.Transform
@com.github.ghik.silencer.silent
lazy private val sharedProgress = new TaskTimings(reportOnShutdown = true)
def taskTimingProgress: Option[ExecuteProgress[Task]] =
if (SysProp.taskTimingsOnShutdown) Some(sharedProgress)

View File

@ -200,6 +200,7 @@ object BuiltinCommands {
def ScriptCommands: Seq[Command] =
Seq(ignore, exit, Script.command, setLogLevel, early, act, nop)
@com.github.ghik.silencer.silent
def DefaultCommands: Seq[Command] =
Seq(
multi,

View File

@ -81,7 +81,7 @@ abstract class AutoPlugin extends Plugins.Basic with PluginsFunctions {
def trigger: PluginTrigger = noTrigger
/**
* This AutoPlugin requires the plugins the [[Plugins]] matcher returned by this method. See [[trigger]].
* This AutoPlugin requires the plugins the Plugins matcher returned by this method. See [[trigger]].
*/
def requires: Plugins = plugins.JvmPlugin
@ -89,20 +89,20 @@ abstract class AutoPlugin extends Plugins.Basic with PluginsFunctions {
override def toString: String = label
/** The [[Configuration]]s to add to each project that activates this AutoPlugin.*/
/** The `Configuration`s to add to each project that activates this AutoPlugin.*/
def projectConfigurations: Seq[Configuration] = Nil
/** The [[Setting]]s to add in the scope of each project that activates this AutoPlugin. */
/** The `Setting`s to add in the scope of each project that activates this AutoPlugin. */
def projectSettings: Seq[Setting[_]] = Nil
/**
* The [[Setting]]s to add to the build scope for each project that activates this AutoPlugin.
* The `Setting` to add to the build scope for each project that activates this AutoPlugin.
* The settings returned here are guaranteed to be added to a given build scope only once
* regardless of how many projects for that build activate this AutoPlugin.
*/
def buildSettings: Seq[Setting[_]] = Nil
/** The [[Setting]]s to add to the global scope exactly once if any project activates this AutoPlugin. */
/** The `Setting`s to add to the global scope exactly once if any project activates this AutoPlugin. */
def globalSettings: Seq[Setting[_]] = Nil
// TODO?: def commands: Seq[Command]

View File

@ -78,7 +78,7 @@ final class StructureIndex(
* A resolved build unit. (`ResolvedBuildUnit` would be a better name to distinguish it from the loaded, but unresolved `BuildUnit`.)
* @param unit The loaded, but unresolved [[BuildUnit]] this was resolved from.
* @param defined The definitive map from project IDs to resolved projects.
* These projects have had [[Reference]]s resolved and [[AutoPlugin]]s evaluated.
* These projects have had `Reference`s resolved and [[AutoPlugin]]s evaluated.
* @param rootProjects The list of project IDs for the projects considered roots of this build.
* The first root project is used as the default in several situations where a project is not otherwise selected.
*/
@ -91,7 +91,7 @@ final class LoadedBuildUnit(
/**
* The project to use as the default when one is not otherwise selected.
* [[LocalRootProject]] resolves to this from within the same build.
* `LocalRootProject` resolves to this from within the same build.
*/
val root = rootProjects.headOption.getOrElse(
throw new java.lang.AssertionError(

View File

@ -10,11 +10,13 @@ package sbt.internal
import java.nio.file.Path
import java.util.concurrent.atomic.AtomicReference
import com.github.ghik.silencer.silent
import sbt.{ ProjectRef, State, Watched }
import sbt.internal.io.{ EventMonitor, Source, WatchState => WS }
import sbt.internal.util.AttributeKey
import sbt.nio.file.Glob
@silent
private[internal] trait DeprecatedContinuous {
protected type StartMessage =
Option[Either[WS => String, (Int, ProjectRef, Seq[String]) => Option[String]]]
@ -55,6 +57,8 @@ private[internal] trait DeprecatedContinuous {
}
}
}
@silent
private[sbt] object DeprecatedContinuous {
private[sbt] val taskDefinitions = Seq(
sbt.Keys.watchTransitiveSources := sbt.Defaults.watchTransitiveSourcesTask.value,

View File

@ -17,8 +17,9 @@ import sbt.util.{ CacheStore, CacheStoreFactory, Logger, Tracked, Level }
import sbt.io.IO
import sbt.io.syntax._
import sbt.Project.richInitializeTask
import sbt.dsl.LinterLevel.Ignore
import sjsonnew.JsonFormat
// This is to turn off "`state` is inside the if expression of a regular task." etc
import sbt.dsl.LinterLevel.Ignore
private[sbt] object LibraryManagement {

View File

@ -27,7 +27,7 @@ import scala.collection.JavaConverters._
import sbt.io.IO
/**
* Defines a compiler reporter that uses event logging provided by a [[ManagedLogger]].
* Defines a compiler reporter that uses event logging provided by a `ManagedLogger`.
*
* @param maximumErrors The maximum errors.
* @param logger The event managed logger.

View File

@ -16,7 +16,7 @@ object PublishBinPlugin extends AutoPlugin {
override def globalSettings = Seq(publishLocalBin := (()))
override def projectSettings = Def settings (
publishLocalBin := Classpaths.publishTask(publishLocalBinConfig, deliverLocal).value,
publishLocalBin := Classpaths.publishTask(publishLocalBinConfig).value,
publishLocalBinConfig := {
Classpaths.publishConfig(
false, // publishMavenStyle.value,

View File

@ -7,7 +7,7 @@
package sbt.util
import scala.util.{ Failure, Try, Success }
import scala.util.{ Failure, Try, Success => USuccess }
import java.io.File
import sbt.io.IO
@ -182,7 +182,7 @@ object Tracked {
import CacheImplicits.LongJsonFormat
def save(store: CacheStore, value: I): Unit = {
Hasher.hash(value) match {
case Success(keyHash) => store.write[Long](keyHash.toLong)
case USuccess(keyHash) => store.write[Long](keyHash.toLong)
case Failure(e) =>
if (isStrictMode) throw e
else ()
@ -191,9 +191,9 @@ object Tracked {
def changed(store: CacheStore, value: I): Boolean =
Try { store.read[Long] } match {
case Success(prev: Long) =>
case USuccess(prev: Long) =>
Hasher.hash(value) match {
case Success(keyHash: Int) => keyHash.toLong != prev
case USuccess(keyHash: Int) => keyHash.toLong != prev
case Failure(e) =>
if (isStrictMode) throw e
else true