Fix additional warnings

This commit is contained in:
Pierre DAL-PRA 2015-08-07 00:23:14 +02:00
parent 39462b6e36
commit 8f1fb2d232
21 changed files with 54 additions and 61 deletions

View File

@ -12,7 +12,7 @@ object CacheTest // extends Properties("Cache test")
import FileInfo.hash._
import Ordering._
import sbinary.DefaultProtocol.FileFormat
def test {
def test(): Unit = {
lazy val create = new File("test")
val length = cached(lengthCache) {
@ -28,4 +28,4 @@ object CacheTest // extends Properties("Cache test")
}
c(create :+: fileLength :+: HNil)
}
}
}

View File

@ -81,7 +81,7 @@ object TestCaseGenerators {
private[this] def lzy[T <: AnyRef](x: T) = SafeLazy.strict(x)
def genNameHash(defn: String): Gen[xsbti.api._internalOnly_NameHash] =
value(new xsbti.api._internalOnly_NameHash(defn, defn.hashCode()))
const(new xsbti.api._internalOnly_NameHash(defn, defn.hashCode()))
def genNameHashes(defns: Seq[String]): Gen[xsbti.api._internalOnly_NameHashes] = {
def partitionAccordingToMask[T](mask: List[Boolean], xs: List[T]): (List[T], List[T]) = {

View File

@ -266,7 +266,7 @@ class ExtractAPI[GlobalType <: CallbackGlobal](val global: GlobalType,
private def mkStructure(info: Type, s: Symbol, inherit: Boolean): xsbti.api.Structure =
{
val (declared, inherited) = info.members.reverse.partition(_.owner == s)
val (declared, inherited) = info.members.toList.reverse.partition(_.owner == s)
val baseTypes = info.baseClasses.tail.map(info.baseType)
val ds = if (s.isModuleClass) removeConstructors(declared) else declared
val is = if (inherit) removeConstructors(inherited) else Nil

View File

@ -148,7 +148,7 @@ object AnalyzingCompiler {
} catch { case e: xsbti.CompileFailed => throw new CompileFailed(e.arguments, "Error compiling sbt component '" + id + "'", e.problems) }
import sbt.Path._
copy(resources pair rebase(dir, outputDirectory))
zip((outputDirectory ***) x_! relativeTo(outputDirectory), targetJar)
zip((outputDirectory ***) pair (relativeTo(outputDirectory), false), targetJar)
}
}
}

View File

@ -7,14 +7,14 @@ import java.util.Date
import org.apache.ivy.core.settings.IvySettings
import org.apache.ivy.core.{ IvyContext, LogOptions }
import org.apache.ivy.core.module.descriptor.{ Artifact => IArtifact, DefaultModuleDescriptor, DefaultDependencyDescriptor, ModuleDescriptor, DependencyDescriptor }
import org.apache.ivy.core.module.descriptor.{ Artifact => IArtifact, DefaultModuleDescriptor, ModuleDescriptor, DependencyDescriptor }
import org.apache.ivy.core.resolve.{ ResolvedModuleRevision, ResolveData }
import org.apache.ivy.plugins.latest.LatestStrategy
import org.apache.ivy.plugins.repository.file.{ FileRepository => IFileRepository, FileResource }
import org.apache.ivy.plugins.repository.url.URLResource
import org.apache.ivy.plugins.resolver._
import org.apache.ivy.plugins.resolver.util.{ HasLatestStrategy, ResolvedResource }
import org.apache.ivy.util.{ Message, MessageLogger, StringUtils => IvyStringUtils }
import org.apache.ivy.util.{ Message, StringUtils => IvyStringUtils }
private[sbt] case class SbtChainResolver(
name: String,
@ -88,9 +88,9 @@ private[sbt] case class SbtChainResolver(
// - If `isReturnFirst` is true, you return the first value found
// - If not, we will ATTEMPT to look at the publish date, which is not correctly discovered for Maven modules and
// leads to undefined behavior.
val useLatest = (dd.isChanging || (IvySbt.isChanging(dd.getDependencyRevisionId))) && updateOptions.latestSnapshots
val useLatest = (dd.isChanging || IvySbt.isChanging(dd.getDependencyRevisionId)) && updateOptions.latestSnapshots
if (useLatest) {
Message.verbose(s"${getName} is changing. Checking all resolvers on the chain")
Message.verbose(s"$getName is changing. Checking all resolvers on the chain")
}
val data = new ResolveData(data0, doValidate(data0))
// Returns the value if we've already been resolved from some other branch of the resolution tree.
@ -146,7 +146,7 @@ private[sbt] case class SbtChainResolver(
Left(ex)
} finally {
oldLatest map { _ => doSetLatestStrategy(resolver, oldLatest) }
checkInterrupted
checkInterrupted()
}
}
}
@ -179,7 +179,7 @@ private[sbt] case class SbtChainResolver(
}
}).reverse.headOption map {
case (rmr, resolver) =>
Message.warn(s"Choosing ${resolver} for ${rmr.getId}")
Message.warn(s"Choosing $resolver for ${rmr.getId}")
// Now that we know the real latest revision, let's force Ivy to use it
val artifactOpt = findFirstArtifactRef(rmr.getDescriptor, dd, data, resolver)
artifactOpt match {
@ -191,7 +191,7 @@ private[sbt] case class SbtChainResolver(
case Some(artifactRef) =>
val systemMd = toSystem(rmr.getDescriptor)
getRepositoryCacheManager.cacheModuleDescriptor(resolver, artifactRef,
toSystem(dd), systemMd.getAllArtifacts().head, None.orNull, getCacheOptions(data))
toSystem(dd), systemMd.getAllArtifacts.head, None.orNull, getCacheOptions(data))
}
rmr
}
@ -223,7 +223,7 @@ private[sbt] case class SbtChainResolver(
case r: FileResource =>
try {
val parser = rmr.getDescriptor.getParser
val md = parser.parseDescriptor(settings, r.getFile.toURL, r, false)
val md = parser.parseDescriptor(settings, r.getFile.toURI.toURL, r, false)
Some(new ResolvedModuleRevision(resolver, resolver, md, rmr.getReport, true))
} catch {
case _: ParseException => None
@ -246,7 +246,7 @@ private[sbt] case class SbtChainResolver(
Option(artifact.getUrl) map { url =>
Message.verbose("\tusing url for " + artifact + ": " + url)
val resource =
if ("file" == url.getProtocol) new FileResource(new IFileRepository(), new File(url.getPath()))
if ("file" == url.getProtocol) new FileResource(new IFileRepository(), new File(url.getPath))
else new URLResource(url)
new ResolvedResource(resource, artifact.getModuleRevisionId.getRevision)
}
@ -262,7 +262,7 @@ private[sbt] case class SbtChainResolver(
artifactRef(af, data.getDate).toIterator
}
}
if (artifactRefs.hasNext) Some(artifactRefs.next)
if (artifactRefs.hasNext) Some(artifactRefs.next())
else None
}
/** Ported from ChainResolver#forcedRevision. */

View File

@ -4,7 +4,6 @@ import Path._, Configurations._
import java.io.File
import org.specs2._
import cross.CrossVersionUtil
import sbt.PublishConfiguration
import sbt.ivyint.SbtChainResolver
trait BaseIvySpecification extends Specification {
@ -59,15 +58,9 @@ trait BaseIvySpecification extends Specification {
IvyActions.updateEither(module, config, UnresolvedWarningConfiguration(), LogicalClock.unknown, Some(currentDependency), log)
}
def cleanIvyCache: Unit =
{
IO.delete(currentTarget / "cache")
}
def cleanIvyCache(): Unit = IO.delete(currentTarget / "cache")
def cleanCachedResolutionCache(module: IvySbt#Module): Unit =
{
IvyActions.cleanCachedResolutionCache(module, log)
}
def cleanCachedResolutionCache(module: IvySbt#Module): Unit = IvyActions.cleanCachedResolutionCache(module, log)
def ivyUpdate(module: IvySbt#Module) =
ivyUpdateEither(module) match {

View File

@ -28,7 +28,7 @@ class CachedResolutionSpec extends BaseIvySpecification {
import ShowLines._
def e1 = {
cleanIvyCache
cleanIvyCache()
val m = module(ModuleID("com.example", "foo", "0.1.0", Some("compile")),
Seq(commonsIo13), Some("2.10.2"), UpdateOptions().withCachedResolution(true))
val report = ivyUpdate(m)
@ -67,7 +67,7 @@ class CachedResolutionSpec extends BaseIvySpecification {
// #2046 says that netty:3.2.0.Final is incorrectly evicted by netty:3.2.1.Final
def e3 = {
// log.setLevel(Level.Debug)
cleanIvyCache
cleanIvyCache()
val m = module(ModuleID("com.example", "foo", "0.3.0", Some("compile")),
Seq(avro177, dataAvro1940, netty320),
Some("2.10.2"), UpdateOptions().withCachedResolution(true))

View File

@ -134,7 +134,7 @@ object BasicCommands {
private[this] def className: Parser[String] =
{
val base = StringBasic & not('-' ~> any.*, "Class name cannot start with '-'.")
def single(s: String) = Completions.single(Completion.displayStrict(s))
def single(s: String) = Completions.single(Completion.displayOnly(s))
val compl = TokenCompletions.fixed((seen, level) => if (seen.startsWith("-")) Completions.nil else single("<class name>"))
token(base, compl)
}

View File

@ -96,7 +96,7 @@ object MainLoop {
ErrorHandling.wideConvert { state.process(Command.process) } match {
case Right(s) => s
case Left(t: xsbti.FullReload) => throw t
case Left(t) => handleException(t, state)
case Left(t) => state.handleError(t)
}
@deprecated("Use State.handleError", "0.13.0")

View File

@ -63,7 +63,7 @@ object Watched {
case e: Exception =>
val log = s.log
log.error("Error occurred obtaining files to watch. Terminating continuous execution...")
MainLoop.handleException(e, s, log)
State.handleException(e, s, log)
(false, watchState, s.fail)
}

View File

@ -247,7 +247,7 @@ object EvaluateTask {
{
val root = ProjectRef(pluginDef.root, Load.getRootProject(pluginDef.units)(pluginDef.root))
val pluginKey = pluginData
val config = extractedConfig(Project.extract(state), pluginDef, state)
val config = extractedTaskConfig(Project.extract(state), pluginDef, state)
val evaluated = apply(pluginDef, ScopedKey(pluginKey.scope, pluginKey.key), state, root, config)
val (newS, result) = evaluated getOrElse sys.error("Plugin data does not exist for plugin definition at " + pluginDef.root)
Project.runUnloadHooks(newS) // discard states

View File

@ -40,8 +40,8 @@ final case class Extracted(structure: BuildStructure, session: SessionSettings,
{
import EvaluateTask._
val rkey = resolve(key.scopedKey)
val config = extractedConfig(this, structure)
val value: Option[(State, Result[T])] = apply(structure, key.task.scopedKey, state, currentRef, config)
val config = extractedTaskConfig(this, structure, state)
val value: Option[(State, Result[T])] = apply(structure, key.scopedKey, state, currentRef, config)
val (newS, result) = getOrError(rkey.scope, rkey.key, value)
(newS, processResult(result, newS.log))
}

View File

@ -184,7 +184,7 @@ object Load {
def reapply(newSettings: Seq[Setting[_]], structure: sbt.BuildStructure)(implicit display: Show[ScopedKey[_]]): sbt.BuildStructure =
{
val transformed = finalTransforms(newSettings)
val newData = makeSettings(transformed, structure.delegates, structure.scopeLocal)
val newData = Def.make(transformed)(structure.delegates, structure.scopeLocal, display)
val newIndex = structureIndex(newData, transformed, index => BuildUtil(structure.root, structure.units, index, newData), structure.units)
val newStreams = mkStreams(structure.units, structure.root, newData)
new sbt.BuildStructure(units = structure.units, root = structure.root, settings = transformed, data = newData, index = newIndex, streams = newStreams, delegates = structure.delegates, scopeLocal = structure.scopeLocal)

View File

@ -141,7 +141,7 @@ sealed trait Project extends ProjectDefinition[ProjectReference] {
def aggregate(refs: ProjectReference*): Project = copy(aggregate = (aggregate: Seq[ProjectReference]) ++ refs)
/** Appends settings to the current settings sequence for this project. */
def settings(ss: SettingsDefinition*): Project = copy(settings = (settings: Seq[Def.Setting[_]]) ++ ss.flatMap(_.settings))
def settings(ss: Def.SettingsDefinition*): Project = copy(settings = (settings: Seq[Def.Setting[_]]) ++ ss.flatMap(_.settings))
@deprecated("Use settingSets method.", "0.13.5")
def autoSettings(select: AddSettings*): Project = settingSets(select.toSeq: _*)
@ -464,7 +464,7 @@ object Project extends ProjectExtra {
def relation(structure: BuildStructure, actual: Boolean)(implicit display: Show[ScopedKey[_]]): Relation[ScopedKey[_], ScopedKey[_]] =
relation(structure.settings, actual)(structure.delegates, structure.scopeLocal, display)
private[sbt] def relation(settings: Seq[Setting[_]], actual: Boolean)(implicit delegates: Scope => Seq[Scope], scopeLocal: Def.ScopeLocal, display: Show[ScopedKey[_]]): Relation[ScopedKey[_], ScopedKey[_]] =
private[sbt] def relation(settings: Seq[Def.Setting[_]], actual: Boolean)(implicit delegates: Scope => Seq[Scope], scopeLocal: Def.ScopeLocal, display: Show[ScopedKey[_]]): Relation[ScopedKey[_], ScopedKey[_]] =
{
type Rel = Relation[ScopedKey[_], ScopedKey[_]]
val cMap = Def.flattenLocals(Def.compiled(settings, actual))

View File

@ -123,7 +123,7 @@ object ParseKey extends Properties("Key parser test") {
// so that it will use the passed-in `Gen` rather than the one imported
// from TestBuild.
def structureGenF(f: (Seq[Scope], Env, ProjectRef) => Structure)(implicit mkEnv: Gen[Env]): Gen[Structure] =
structureGen((s, e, p) => Gen.value(f(s, e, p)))
structureGen((s, e, p) => Gen.const(f(s, e, p)))
// Here we're shadowing the in-scope implicit called `mkEnv` for this method
// so that it will use the passed-in `Gen` rather than the one imported
// from TestBuild.

View File

@ -214,7 +214,7 @@ object TestBuild {
def genAcyclicDirect[A, T](maxDeps: Gen[Int], keyGen: Gen[T], max: Gen[Int])(make: (T, Seq[A]) => A): Gen[Seq[A]] =
genAcyclic[A, T](maxDeps, keyGen, max) { t =>
Gen.value { deps =>
Gen.const { deps =>
make(t, deps)
}
}

View File

@ -2,7 +2,7 @@ package sbt
import org.scalacheck._
import Prop.{ Exception => _, _ }
import Gen.{ alphaNumChar, frequency, listOf1, oneOf }
import Gen.{ alphaNumChar, frequency, nonEmptyListOf }
import java.io.File
object ForkTest extends Properties("Fork") {
@ -14,9 +14,9 @@ object ForkTest extends Properties("Fork") {
final val MaximumClasspathLength = 100000
lazy val genOptionName = frequency((9, Some("-cp")), (9, Some("-classpath")), (1, None))
lazy val pathElement = listOf1(alphaNumChar).map(_.mkString)
lazy val path = listOf1(pathElement).map(_.mkString(File.separator))
lazy val genRelClasspath = listOf1(path)
lazy val pathElement = nonEmptyListOf(alphaNumChar).map(_.mkString)
lazy val path = nonEmptyListOf(pathElement).map(_.mkString(File.separator))
lazy val genRelClasspath = nonEmptyListOf(path)
lazy val requiredEntries =
IO.classLocationFile[scala.Option[_]] ::

View File

@ -12,7 +12,7 @@ object Test extends std.TaskExtra {
def t3[A, B, C](a: Task[A], b: Task[B], c: Task[C]) = multInputTask[({ type l[L[x]] = (L[A], L[B], L[C]) })#l]((a, b, c))(AList.tuple3)
val a = task(3)
val b = task[Boolean](error("test"))
val b = task[Boolean](sys.error("test"))
val b2 = task(true)
val c = task("asdf")

View File

@ -16,8 +16,8 @@ object checkResult {
case i: Incomplete =>
println(i)
"One or more tasks failed" |: false
case e =>
e.printStackTrace
case e: Throwable =>
e.printStackTrace()
"Error in framework" |: false
})
}

View File

@ -44,7 +44,7 @@ object ParserTest extends Properties("Completing Parser") {
val nested = (token("a1") ~ token("b2")) ~ "c3"
val nestedDisplay = (token("a1", "<a1>") ~ token("b2", "<b2>")) ~ "c3"
val spacePort = (token(Space) ~> Port)
val spacePort = token(Space) ~> Port
def p[T](f: T): T = { println(f); f }
@ -58,7 +58,7 @@ object ParserTest extends Properties("Completing Parser") {
def checkAll(in: String, parser: Parser[_], expect: Completions): Prop =
{
val cs = completions(parser, in, 1)
("completions: " + cs) |: ("Expected: " + expect) |: ((cs == expect): Prop)
("completions: " + cs) |: ("Expected: " + expect) |: (cs == expect: Prop)
}
def checkInvalid(in: String) =
@ -68,31 +68,31 @@ object ParserTest extends Properties("Completing Parser") {
def checkInv(in: String, parser: Parser[_]): Prop =
{
val cs = completions(parser, in, 1)
("completions: " + cs) |: ((cs == Completions.nil): Prop)
("completions: " + cs) |: (cs == Completions.nil: Prop)
}
property("nested tokens a") = checkSingle("", Completion.tokenStrict("", "a1"))(Completion.displayStrict("<a1>"))
property("nested tokens a1") = checkSingle("a", Completion.tokenStrict("a", "1"))(Completion.displayStrict("<a1>"))
property("nested tokens a") = checkSingle("", Completion.token("", "a1"))(Completion.displayOnly("<a1>"))
property("nested tokens a1") = checkSingle("a", Completion.token("a", "1"))(Completion.displayOnly("<a1>"))
property("nested tokens a inv") = checkInvalid("b")
property("nested tokens b") = checkSingle("a1", Completion.tokenStrict("", "b2"))(Completion.displayStrict("<b2>"))
property("nested tokens b2") = checkSingle("a1b", Completion.tokenStrict("b", "2"))(Completion.displayStrict("<b2>"))
property("nested tokens b") = checkSingle("a1", Completion.token("", "b2"))(Completion.displayOnly("<b2>"))
property("nested tokens b2") = checkSingle("a1b", Completion.token("b", "2"))(Completion.displayOnly("<b2>"))
property("nested tokens b inv") = checkInvalid("a1a")
property("nested tokens c") = checkSingle("a1b2", Completion.suggestStrict("c3"))()
property("nested tokens c3") = checkSingle("a1b2c", Completion.suggestStrict("3"))()
property("nested tokens c") = checkSingle("a1b2", Completion.suggestion("c3"))()
property("nested tokens c3") = checkSingle("a1b2c", Completion.suggestion("3"))()
property("nested tokens c inv") = checkInvalid("a1b2a")
property("suggest space") = checkOne("", spacePort, Completion.tokenStrict("", " "))
property("suggest port") = checkOne(" ", spacePort, Completion.displayStrict("<port>"))
property("no suggest at end") = checkOne("asdf", "asdf", Completion.suggestStrict(""))
property("no suggest at token end") = checkOne("asdf", token("asdf"), Completion.suggestStrict(""))
property("empty suggest for examples") = checkOne("asdf", any.+.examples("asdf", "qwer"), Completion.suggestStrict(""))
property("empty suggest for examples token") = checkOne("asdf", token(any.+.examples("asdf", "qwer")), Completion.suggestStrict(""))
property("suggest space") = checkOne("", spacePort, Completion.token("", " "))
property("suggest port") = checkOne(" ", spacePort, Completion.displayOnly("<port>"))
property("no suggest at end") = checkOne("asdf", "asdf", Completion.suggestion(""))
property("no suggest at token end") = checkOne("asdf", token("asdf"), Completion.suggestion(""))
property("empty suggest for examples") = checkOne("asdf", any.+.examples("asdf", "qwer"), Completion.suggestion(""))
property("empty suggest for examples token") = checkOne("asdf", token(any.+.examples("asdf", "qwer")), Completion.suggestion(""))
val colors = Set("blue", "green", "red")
val base = (seen: Seq[String]) => token(ID examples (colors -- seen))
val sep = token(Space)
val repeat = repeatDep(base, sep)
def completionStrings(ss: Set[String]): Completions = Completions(ss.map { s => Completion.tokenStrict("", s) })
def completionStrings(ss: Set[String]): Completions = Completions(ss.map { s => Completion.token("", s) })
property("repeatDep no suggestions for bad input") = checkInv(".", repeat)
property("repeatDep suggest all") = checkAll("", repeat, completionStrings(colors))

View File

@ -104,7 +104,7 @@ object TestClauses {
Logic.reduceAll(cs, Set(A, B))
}
def all {
def all(): Unit = {
println(s"Cycles: $cycles")
println(s"xNeg: $excludedNeg")
println(s"xPos: $excludedPos")