Add -Ywarn-unused & -Ywarn-unused-import, & fix warnings

This commit is contained in:
Dale Wijnand 2016-06-19 11:42:31 +01:00
parent 28a40163e7
commit 121e7f5d9e
25 changed files with 18 additions and 50 deletions

View File

@ -14,6 +14,7 @@ def commonSettings: Seq[Setting[_]] = Seq(
testOptions += Tests.Argument(TestFrameworks.ScalaCheck, "-w", "1"), testOptions += Tests.Argument(TestFrameworks.ScalaCheck, "-w", "1"),
javacOptions in compile ++= Seq("-target", "6", "-source", "6", "-Xlint", "-Xlint:-serial"), javacOptions in compile ++= Seq("-target", "6", "-source", "6", "-Xlint", "-Xlint:-serial"),
crossScalaVersions := Seq(scala210, scala211), crossScalaVersions := Seq(scala210, scala211),
scalacOptions ++= Seq("-Ywarn-unused", "-Ywarn-unused-import"),
previousArtifact := None, // Some(organization.value %% moduleName.value % "1.0.0"), previousArtifact := None, // Some(organization.value %% moduleName.value % "1.0.0"),
publishArtifact in Compile := true, publishArtifact in Compile := true,
publishArtifact in Test := false publishArtifact in Test := false

View File

@ -3,7 +3,6 @@ package appmacro
import scala.reflect._ import scala.reflect._
import macros._ import macros._
import scala.tools.nsc.Global
import ContextUtil.{ DynamicDependencyError, DynamicReferenceError } import ContextUtil.{ DynamicDependencyError, DynamicReferenceError }
object ContextUtil { object ContextUtil {

View File

@ -23,7 +23,6 @@ trait MonadInstance extends Instance {
import scala.reflect._ import scala.reflect._
import macros._ import macros._
import reflect.internal.annotations.compileTimeOnly
object Instance { object Instance {
final val ApplyName = "app" final val ApplyName = "app"

View File

@ -1,8 +1,6 @@
package sbt.internal.util package sbt.internal.util
package appmacro package appmacro
import Types.Id
import scala.tools.nsc.Global
import scala.reflect._ import scala.reflect._
import macros._ import macros._
@ -59,7 +57,6 @@ object KListBuilder extends TupleBuilder {
val klistType: Type = (inputs :\ knilType)((in, klist) => kconsType(in.tpe, klist)) val klistType: Type = (inputs :\ knilType)((in, klist) => kconsType(in.tpe, klist))
val representationC = internal.polyType(tcVariable :: Nil, klistType) val representationC = internal.polyType(tcVariable :: Nil, klistType)
val resultType = appliedType(representationC, idTC :: Nil)
val input = klist val input = klist
val alistInstance: ctx.universe.Tree = TypeApply(select(Ident(alist), "klist"), TypeTree(representationC) :: Nil) val alistInstance: ctx.universe.Tree = TypeApply(select(Ident(alist), "klist"), TypeTree(representationC) :: Nil)
def extract(param: ValDef) = bindKList(param, Nil, inputs.map(_.local)) def extract(param: ValDef) = bindKList(param, Nil, inputs.map(_.local))

View File

@ -1,8 +1,6 @@
package sbt.internal.util package sbt.internal.util
package appmacro package appmacro
import Types.Id
import scala.tools.nsc.Global
import scala.reflect._ import scala.reflect._
import macros._ import macros._

View File

@ -1,7 +1,6 @@
package sbt.internal.util package sbt.internal.util
package appmacro package appmacro
import Types.Id
import scala.tools.nsc.Global import scala.tools.nsc.Global
import scala.reflect._ import scala.reflect._
import macros._ import macros._
@ -17,11 +16,10 @@ object TupleNBuilder extends TupleBuilder {
def make(c: blackbox.Context)(mt: c.Type, inputs: Inputs[c.universe.type]): BuilderResult[c.type] = new BuilderResult[c.type] { def make(c: blackbox.Context)(mt: c.Type, inputs: Inputs[c.universe.type]): BuilderResult[c.type] = new BuilderResult[c.type] {
val util = ContextUtil[c.type](c) val util = ContextUtil[c.type](c)
import c.universe.{ Apply => ApplyTree, _ } import c.universe._
import util._ import util._
val global: Global = c.universe.asInstanceOf[Global] val global: Global = c.universe.asInstanceOf[Global]
val mTC: Type = mt.asInstanceOf[c.universe.Type]
val ctx: c.type = c val ctx: c.type = c
val representationC: PolyType = { val representationC: PolyType = {
@ -30,7 +28,6 @@ object TupleNBuilder extends TupleBuilder {
val tuple = global.definitions.tupleType(tupleTypeArgs) val tuple = global.definitions.tupleType(tupleTypeArgs)
internal.polyType(tcVariable :: Nil, tuple.asInstanceOf[Type]) internal.polyType(tcVariable :: Nil, tuple.asInstanceOf[Type])
} }
val resultType = appliedType(representationC, idTC :: Nil)
val input: Tree = mkTuple(inputs.map(_.expr)) val input: Tree = mkTuple(inputs.map(_.expr))
val alistInstance: Tree = { val alistInstance: Tree = {

View File

@ -7,7 +7,7 @@ import sbinary.{ CollectionTypes, DefaultProtocol, Format, Input, JavaFormats, O
import java.io.{ ByteArrayInputStream, ByteArrayOutputStream, File, InputStream, OutputStream } import java.io.{ ByteArrayInputStream, ByteArrayOutputStream, File, InputStream, OutputStream }
import java.net.{ URI, URL } import java.net.{ URI, URL }
import Types.:+: import Types.:+:
import DefaultProtocol.{ asProduct2, asSingleton, BooleanFormat, ByteFormat, IntFormat, wrap } import DefaultProtocol.{ asSingleton, BooleanFormat, ByteFormat, IntFormat, wrap }
import scala.xml.NodeSeq import scala.xml.NodeSeq
import scala.language.existentials import scala.language.existentials

View File

@ -3,7 +3,7 @@
*/ */
package sbt.internal.util package sbt.internal.util
import java.io.{ File, FileNotFoundException } import java.io.File
import sbinary.{ DefaultProtocol, Format, Operations } import sbinary.{ DefaultProtocol, Format, Operations }
import scala.reflect.Manifest import scala.reflect.Manifest
import sbt.io.IO import sbt.io.IO

View File

@ -3,7 +3,7 @@
*/ */
package sbt.internal.util package sbt.internal.util
import java.io.{ File, IOException } import java.io.File
import sbinary.{ DefaultProtocol, Format } import sbinary.{ DefaultProtocol, Format }
import DefaultProtocol._ import DefaultProtocol._
import scala.reflect.Manifest import scala.reflect.Manifest

View File

@ -3,10 +3,8 @@
*/ */
package sbt.internal.util package sbt.internal.util
import Types.:+: import sbinary.{ Format, Input, Output => Out }
import sbinary.{ DefaultProtocol, Format, Input, Output => Out } import java.io.File
import DefaultProtocol.ByteFormat
import java.io.{ File, InputStream, OutputStream }
import sbt.io.Using import sbt.io.Using
trait InputCache[I] { trait InputCache[I] {

View File

@ -94,7 +94,6 @@ object Dag {
*/ */
private[sbt] def findNegativeCycle[Node](graph: DirectedSignedGraph[Node]): List[graph.Arrow] = private[sbt] def findNegativeCycle[Node](graph: DirectedSignedGraph[Node]): List[graph.Arrow] =
{ {
import scala.annotation.tailrec
import graph._ import graph._
val finished = new mutable.HashSet[Node] val finished = new mutable.HashSet[Node]
val visited = new mutable.HashSet[Node] val visited = new mutable.HashSet[Node]

View File

@ -3,7 +3,7 @@ package sbt.internal.util
import java.lang.Runnable import java.lang.Runnable
import java.util.concurrent.{ atomic, Executor, LinkedBlockingQueue } import java.util.concurrent.{ atomic, Executor, LinkedBlockingQueue }
import atomic.{ AtomicBoolean, AtomicInteger } import atomic.{ AtomicBoolean, AtomicInteger }
import Types.{ :+:, ConstK, Id } import Types.{ ConstK, Id }
object EvaluationState extends Enumeration { object EvaluationState extends Enumeration {
val New, Blocked, Ready, Calling, Evaluated = Value val New, Blocked, Ready, Calling, Evaluated = Value

View File

@ -3,8 +3,6 @@
*/ */
package sbt.internal.util package sbt.internal.util
import Types._
// Used to emulate ~> literals // Used to emulate ~> literals
trait Param[A[_], B[_]] { trait Param[A[_], B[_]] {
type T type T

View File

@ -278,7 +278,6 @@ trait Init[Scope] {
def flattenLocals(compiled: CompiledMap): Map[ScopedKey[_], Flattened] = def flattenLocals(compiled: CompiledMap): Map[ScopedKey[_], Flattened] =
{ {
import collection.breakOut
val locals = compiled flatMap { case (key, comp) => if (key.key.isLocal) Seq[Compiled[_]](comp) else Nil } val locals = compiled flatMap { case (key, comp) => if (key.key.isLocal) Seq[Compiled[_]](comp) else Nil }
val ordered = Dag.topologicalSort(locals)(_.dependencies.flatMap(dep => if (dep.key.isLocal) Seq[Compiled[_]](compiled(dep)) else Nil)) val ordered = Dag.topologicalSort(locals)(_.dependencies.flatMap(dep => if (dep.key.isLocal) Seq[Compiled[_]](compiled(dep)) else Nil))
def flatten(cmap: Map[ScopedKey[_], Flattened], key: ScopedKey[_], deps: Iterable[ScopedKey[_]]): Flattened = def flatten(cmap: Map[ScopedKey[_], Flattened], key: ScopedKey[_], deps: Iterable[ScopedKey[_]]): Flattened =
@ -340,11 +339,6 @@ trait Init[Scope] {
derivsByDef.getOrElseUpdate(key, new Deriveds(key, new mutable.ListBuffer)).settings += s derivsByDef.getOrElseUpdate(key, new Deriveds(key, new mutable.ListBuffer)).settings += s
} }
// sort derived settings so that dependencies come first
// this is necessary when verifying that a derived setting's dependencies exist
val ddeps = (d: Deriveds) => d.dependencies.flatMap(derivsByDef.get)
val sortedDerivs = Dag.topologicalSort(derivsByDef.values)(ddeps)
// index derived settings by triggering key. This maps a key to the list of settings potentially derived from it. // index derived settings by triggering key. This maps a key to the list of settings potentially derived from it.
val derivedBy = new mutable.HashMap[AttributeKey[_], mutable.ListBuffer[Derived]] val derivedBy = new mutable.HashMap[AttributeKey[_], mutable.ListBuffer[Derived]]
for (s <- derived; d <- s.triggeredBy) for (s <- derived; d <- s.triggeredBy)

View File

@ -3,8 +3,6 @@
*/ */
package sbt.internal.util package sbt.internal.util
import Types._
// compilation test // compilation test
object LiteralTest { object LiteralTest {
def x[A[_], B[_]](f: A ~> B) = f def x[A[_], B[_]](f: A ~> B) = f

View File

@ -32,7 +32,6 @@ object SettingsExample extends Init[Scope] {
object SettingsUsage { object SettingsUsage {
import SettingsExample._ import SettingsExample._
import Types._
// Define some keys // Define some keys
val a = AttributeKey[Int]("a") val a = AttributeKey[Int]("a")

View File

@ -5,9 +5,8 @@ package sbt.internal.util
import jline.console.ConsoleReader import jline.console.ConsoleReader
import jline.console.history.{ FileHistory, MemoryHistory } import jline.console.history.{ FileHistory, MemoryHistory }
import java.io.{ File, InputStream, PrintWriter, FileInputStream, FileDescriptor, FilterInputStream } import java.io.{ File, InputStream, FileInputStream, FileDescriptor, FilterInputStream }
import complete.Parser import complete.Parser
import java.util.concurrent.atomic.AtomicBoolean
import scala.concurrent.duration.Duration import scala.concurrent.duration.Duration
import scala.annotation.tailrec import scala.annotation.tailrec

View File

@ -23,7 +23,6 @@ object EditDistance {
for (i <- 1 to n; s_i = s(i - 1); j <- 1 to m) { for (i <- 1 to n; s_i = s(i - 1); j <- 1 to m) {
val t_j = t(j - 1) val t_j = t(j - 1)
val cost = if (s_i == t_j) matchCost else if (lower(s_i) == lower(t_j)) caseCost else subCost val cost = if (s_i == t_j) matchCost else if (lower(s_i) == lower(t_j)) caseCost else subCost
val tcost = if (s_i == t_j) matchCost else transposeCost
val c1 = d(i - 1)(j) + deleteCost val c1 = d(i - 1)(j) + deleteCost
val c2 = d(i)(j - 1) + insertCost val c2 = d(i)(j - 1) + insertCost

View File

@ -4,7 +4,6 @@
package sbt.internal.util package sbt.internal.util
package complete package complete
import java.io.File
import sbt.io.IO import sbt.io.IO
object HistoryCommands { object HistoryCommands {

View File

@ -5,7 +5,7 @@ package sbt.internal.util
package complete package complete
import jline.console.ConsoleReader import jline.console.ConsoleReader
import jline.console.completer.{ CandidateListCompletionHandler, Completer, CompletionHandler } import jline.console.completer.{ Completer, CompletionHandler }
import scala.annotation.tailrec import scala.annotation.tailrec
import collection.JavaConversions import collection.JavaConversions

View File

@ -1,6 +1,5 @@
package sbt.internal.util package sbt.internal.util
import sbt.util._
import java.io.{ BufferedWriter, PrintStream, PrintWriter } import java.io.{ BufferedWriter, PrintStream, PrintWriter }
sealed trait ConsoleOut { sealed trait ConsoleOut {

View File

@ -5,7 +5,7 @@ package sbt.internal.util
import sbt.util._ import sbt.util._
import org.scalacheck._ import org.scalacheck._
import Arbitrary.{ arbitrary => arb, _ } import Arbitrary._
import Gen.{ listOfN, oneOf } import Gen.{ listOfN, oneOf }
import Prop._ import Prop._

View File

@ -6,7 +6,7 @@ import java.io.File
import sbt.util.Logger import sbt.util.Logger
import sbt.internal.util.{ ConsoleLogger, BufferedLogger, FullLogger } import sbt.internal.util.{ ConsoleLogger, BufferedLogger, FullLogger }
import sbt.io.IO.wrapNull import sbt.io.IO.wrapNull
import sbt.io.{ DirectoryFilter, HiddenFileFilter, Path, GlobFilter } import sbt.io.{ DirectoryFilter, HiddenFileFilter }
import sbt.io.syntax._ import sbt.io.syntax._
import sbt.internal.io.Resources import sbt.internal.io.Resources
@ -49,9 +49,6 @@ final class ScriptedTests(resourceBaseDirectory: File, bufferLog: Boolean, handl
def scriptedTest(group: String, name: String, log: Logger): Seq[() => Option[String]] = def scriptedTest(group: String, name: String, log: Logger): Seq[() => Option[String]] =
scriptedTest(group, name, { _ => () }, log) scriptedTest(group, name, { _ => () }, log)
def scriptedTest(group: String, name: String, prescripted: File => Unit, log: Logger): Seq[() => Option[String]] = { def scriptedTest(group: String, name: String, prescripted: File => Unit, log: Logger): Seq[() => Option[String]] = {
import Path._
import GlobFilter._
var failed = false
for (groupDir <- (resourceBaseDirectory * group).get; nme <- (groupDir * name).get) yield { for (groupDir <- (resourceBaseDirectory * group).get; nme <- (groupDir * name).get) yield {
val g = groupDir.getName val g = groupDir.getName
val n = nme.getName val n = nme.getName

View File

@ -5,7 +5,7 @@ package sbt
package internal package internal
package scripted package scripted
import java.io.{ BufferedReader, File, InputStreamReader } import java.io.File
import scala.util.parsing.combinator._ import scala.util.parsing.combinator._
import scala.util.parsing.input.Positional import scala.util.parsing.input.Positional
import Character.isWhitespace import Character.isWhitespace

View File

@ -8,9 +8,8 @@ import CacheIO.{ fromFile, toFile }
import sbinary.Format import sbinary.Format
import scala.pickling.PicklingException import scala.pickling.PicklingException
import scala.reflect.Manifest import scala.reflect.Manifest
import scala.collection.mutable
import sbt.io.IO.{ delete, read, write } import sbt.io.IO.{ delete, read, write }
import sbt.io.{ IO, Path } import sbt.io.IO
import sbt.io.Using import sbt.io.Using
import sbt.io.syntax._ import sbt.io.syntax._
import sbt.serialization._ import sbt.serialization._
@ -257,7 +256,6 @@ object FileFunction {
def cached(cacheBaseDirectory: File)(inStyle: FilesInfo.Style, outStyle: FilesInfo.Style)(action: UpdateFunction): Set[File] => Set[File] = def cached(cacheBaseDirectory: File)(inStyle: FilesInfo.Style, outStyle: FilesInfo.Style)(action: UpdateFunction): Set[File] => Set[File] =
{ {
import Path._
lazy val inCache = Difference.inputs(cacheBaseDirectory / "in-cache", inStyle) lazy val inCache = Difference.inputs(cacheBaseDirectory / "in-cache", inStyle)
lazy val outCache = Difference.outputs(cacheBaseDirectory / "out-cache", outStyle) lazy val outCache = Difference.outputs(cacheBaseDirectory / "out-cache", outStyle)
inputs => inputs =>