Merge pull request #1759 from jedesah/topic/minor_cleanup

Minor code cleanup
This commit is contained in:
eugene yokota 2015-01-14 16:13:06 -05:00
commit 087bedb698
9 changed files with 25 additions and 25 deletions

View File

@ -33,7 +33,7 @@ object ConflictWarning {
}
private[this] def processCrossVersioned(config: ConflictWarning, report: UpdateReport, log: Logger) {
val crossMismatches = crossVersionMismatches(report)
if (!crossMismatches.isEmpty) {
if (crossMismatches.nonEmpty) {
val pre = s"Modules were resolved with conflicting cross-version suffixes in ${config.label}:\n "
val conflictMsgs =
for (((org, rawName), fullNames) <- crossMismatches) yield {

View File

@ -112,7 +112,7 @@ object EvictionPair {
}
else ""
r.module.revision + callers
}).headOption map { " -> " + _ } getOrElse ""
}) map { " -> " + _ } getOrElse ""
Seq(s"\t* ${a.organization}:${a.name}:${revsStr}$winnerRev")
}
}
@ -181,7 +181,7 @@ object EvictionWarning {
pairs foreach {
case p if isScalaArtifact(module, p.organization, p.name) =>
(module.moduleSettings.ivyScala, p.winner) match {
case (Some(s), Some(winner)) if ((s.scalaFullVersion != winner.module.revision) && options.warnScalaVersionEviction) =>
case (Some(s), Some(winner)) if (s.scalaFullVersion != winner.module.revision) && options.warnScalaVersionEviction =>
scalaEvictions += p
case _ =>
}
@ -201,21 +201,21 @@ object EvictionWarning {
implicit val evictionWarningLines: ShowLines[EvictionWarning] = ShowLines { a: EvictionWarning =>
import ShowLines._
val out: mutable.ListBuffer[String] = mutable.ListBuffer()
if (!a.scalaEvictions.isEmpty) {
if (a.scalaEvictions.nonEmpty) {
out += "Scala version was updated by one of library dependencies:"
out ++= (a.scalaEvictions flatMap { _.lines })
out += "To force scalaVersion, add the following:"
out += "\tivyScala := ivyScala.value map { _.copy(overrideScalaVersion = true) }"
}
if (!a.directEvictions.isEmpty || !a.transitiveEvictions.isEmpty) {
if (a.directEvictions.nonEmpty || a.transitiveEvictions.nonEmpty) {
out += "There may be incompatibilities among your library dependencies."
out += "Here are some of the libraries that were evicted:"
out ++= (a.directEvictions flatMap { _.lines })
out ++= (a.transitiveEvictions flatMap { _.lines })
}
if (!a.allEvictions.isEmpty && !a.reportedEvictions.isEmpty && !a.options.showCallers) {
if (a.allEvictions.nonEmpty && a.reportedEvictions.nonEmpty && !a.options.showCallers) {
out += "Run 'evicted' to see detailed eviction warnings"
}

View File

@ -20,7 +20,7 @@ import org.apache.ivy.core.cache.{ ResolutionCacheManager, CacheMetadataOptions,
import org.apache.ivy.core.event.EventManager
import org.apache.ivy.core.module.descriptor.{ Artifact => IArtifact, DefaultArtifact, DefaultDependencyArtifactDescriptor, MDArtifact }
import org.apache.ivy.core.module.descriptor.{ DefaultDependencyDescriptor, DefaultModuleDescriptor, DependencyDescriptor, ModuleDescriptor, License }
import org.apache.ivy.core.module.descriptor.{ OverrideDependencyDescriptorMediator }
import org.apache.ivy.core.module.descriptor.OverrideDependencyDescriptorMediator
import org.apache.ivy.core.module.id.{ ArtifactId, ModuleId, ModuleRevisionId }
import org.apache.ivy.core.resolve._
import org.apache.ivy.core.settings.IvySettings
@ -503,7 +503,7 @@ private[sbt] object IvySbt {
private def hasInfo(module: ModuleID, x: scala.xml.NodeSeq) =
{
val info = <g>{ x }</g> \ "info"
if (!info.isEmpty) {
if (info.nonEmpty) {
def check(found: NodeSeq, expected: String, label: String) =
if (found.isEmpty)
sys.error("Missing " + label + " in inline Ivy XML.")
@ -515,7 +515,7 @@ private[sbt] object IvySbt {
check(info \ "@module", module.name, "name")
check(info \ "@revision", module.revision, "version")
}
!info.isEmpty
info.nonEmpty
}
/** Parses the given in-memory Ivy file 'xml', using the existing 'moduleID' and specifying the given 'defaultConfiguration'. */
private def parseIvyXML(settings: IvySettings, xml: scala.xml.NodeSeq, moduleID: DefaultModuleDescriptor, defaultConfiguration: String, validate: Boolean): CustomXmlParser.CustomParser =
@ -612,7 +612,7 @@ private[sbt] object IvySbt {
for (artifact <- dependency.explicitArtifacts) {
import artifact.{ name, classifier, `type`, extension, url }
val extraMap = extra(artifact)
val ivyArtifact = new DefaultDependencyArtifactDescriptor(dependencyDescriptor, name, `type`, extension, url.getOrElse(null), extraMap)
val ivyArtifact = new DefaultDependencyArtifactDescriptor(dependencyDescriptor, name, `type`, extension, url.orNull, extraMap)
copyConfigurations(artifact, ivyArtifact.addConfiguration)
for (conf <- dependencyDescriptor.getModuleConfigurations)
dependencyDescriptor.addDependencyArtifact(conf, ivyArtifact)

View File

@ -239,7 +239,7 @@ object IvyActions {
{
import config.{ configuration => c, module => mod, _ }
import mod.{ configurations => confs, _ }
assert(!classifiers.isEmpty, "classifiers cannot be empty")
assert(classifiers.nonEmpty, "classifiers cannot be empty")
val baseModules = modules map { m => restrictedCopy(m, true) }
val deps = baseModules.distinct flatMap classifiedArtifacts(classifiers, exclude)
val base = restrictedCopy(id, true).copy(name = id.name + classifiers.mkString("$", "_", ""))
@ -389,16 +389,16 @@ object UnresolvedWarning {
case _ => ""
}
implicit val unresolvedWarningLines: ShowLines[UnresolvedWarning] = ShowLines { a =>
val withExtra = a.resolveException.failed.filter(!_.extraDependencyAttributes.isEmpty)
val withExtra = a.resolveException.failed.filter(_.extraDependencyAttributes.nonEmpty)
val buffer = mutable.ListBuffer[String]()
if (!withExtra.isEmpty) {
if (withExtra.nonEmpty) {
buffer += "\n\tNote: Some unresolved dependencies have extra attributes. Check that these dependencies exist with the requested attributes."
withExtra foreach { id => buffer += "\t\t" + id }
}
if (!a.failedPaths.isEmpty) {
if (a.failedPaths.nonEmpty) {
buffer += "\n\tNote: Unresolved dependencies path:"
a.failedPaths foreach { path =>
if (!path.isEmpty) {
if (path.nonEmpty) {
val head = path.head
buffer += "\t\t" + head._1.toString + sourcePosStr(head._2)
path.tail foreach {

View File

@ -262,7 +262,7 @@ class MakePom(val log: Logger) {
@deprecated("No longer used and will be removed.", "0.12.1")
def classifier(dependency: DependencyDescriptor, includeTypes: Set[String]): NodeSeq =
{
val jarDep = dependency.getAllDependencyArtifacts.filter(d => includeTypes(d.getType)).headOption
val jarDep = dependency.getAllDependencyArtifacts.find(d => includeTypes(d.getType))
jarDep match {
case Some(a) => classifierElem(artifactClassifier(a))
case None => NodeSeq.Empty
@ -302,15 +302,15 @@ class MakePom(val log: Logger) {
val (opt, notOptional) = confs.partition(_ == Optional.name)
val defaultNotOptional = Configurations.defaultMavenConfigurations.find(notOptional contains _.name)
val scope = defaultNotOptional.map(_.name)
(scope, !opt.isEmpty)
(scope, opt.nonEmpty)
}
def exclusions(dependency: DependencyDescriptor): NodeSeq =
{
val excl = dependency.getExcludeRules(dependency.getModuleConfigurations)
val (warns, excls) = IvyUtil.separate(excl.map(makeExclusion))
if (!warns.isEmpty) log.warn(warns.mkString(IO.Newline))
if (!excls.isEmpty) <exclusions>{ excls }</exclusions>
if (warns.nonEmpty) log.warn(warns.mkString(IO.Newline))
if (excls.nonEmpty) <exclusions>{ excls }</exclusions>
else NodeSeq.Empty
}
def makeExclusion(exclRule: ExcludeRule): Either[String, NodeSeq] =

View File

@ -52,7 +52,7 @@ private[sbt] final class ResolutionCache(base: File, settings: IvySettings) exte
throw new IllegalStateException("Ivy file not found in cache for " + mrid + "!")
}
return XmlModuleDescriptorParser.getInstance().parseDescriptor(settings, ivyFile.toURI().toURL(), false)
XmlModuleDescriptorParser.getInstance().parseDescriptor(settings, ivyFile.toURI.toURL, false)
}
def saveResolvedModuleDescriptor(md: ModuleDescriptor): Unit = {

View File

@ -97,7 +97,7 @@ object VersionNumber {
case (0L, _, _, _, 0L, _, _, _) =>
// Major version zero (0.y.z) is for initial development. Anything may change at any time. The public API should not be considered stable.
equalsIgnoreExtra(v1, v2)
case (_, 0, 0, ts1, _, 0, 0, ts2) if (!ts1.isEmpty) || (!ts2.isEmpty) =>
case (_, 0, 0, ts1, _, 0, 0, ts2) if ts1.nonEmpty || ts2.nonEmpty =>
// A pre-release version MAY be denoted by appending a hyphen and a series of dot separated identifiers
equalsIgnoreExtra(v1, v2)
case (x1, _, _, _, x2, _, _, _) =>
@ -125,7 +125,7 @@ object VersionNumber {
(v1, v2) match {
case (v1, v2) if (v1.size >= 3) && (v2.size >= 3) => // A normal version number MUST take the form X.Y.Z
(v1._1.get, v1._2.get, v1._3.get, v1.tags, v2._1.get, v2._2.get, v2._3.get, v2.tags) match {
case (x1, y1, 0, ts1, x2, y2, 0, ts2) if (!ts1.isEmpty) || (!ts2.isEmpty) =>
case (x1, y1, 0, ts1, x2, y2, 0, ts2) if ts1.nonEmpty || ts2.nonEmpty =>
// A pre-release version MAY be denoted by appending a hyphen and a series of dot separated identifiers
equalsIgnoreExtra(v1, v2)
case (x1, y1, _, _, x2, y2, _, _) =>

View File

@ -67,7 +67,7 @@ private[sbt] class CachedResolutionResolveCache() {
// direct dependencies of an internal dependency
val directs0 = directDependencies(internal)
val directs = directs0 filter { dd =>
allConfigurations exists { conf => !dd.getDependencyConfigurations(conf).isEmpty }
allConfigurations exists { conf => dd.getDependencyConfigurations(conf).nonEmpty }
}
directs flatMap { dd => expandInternalDeps(dd, next) }
case _ =>

View File

@ -92,7 +92,7 @@ private[sbt] final class ErrorMessageAuthenticator(original: Option[Authenticato
// TODO - levenshtein distance "did you mean" message.
Message.error(s"Unable to find credentials for [${getRequestingPrompt} @ ${host}].")
val configuredRealms = IvyCredentialsLookup.realmsForHost.getOrElse(host, Set.empty)
if (!configuredRealms.isEmpty) {
if (configuredRealms.nonEmpty) {
Message.error(s" Is one of these realms mispelled for host [${host}]:")
configuredRealms foreach { realm =>
Message.error(s" * ${realm}")
@ -116,7 +116,7 @@ private[sbt] final class ErrorMessageAuthenticator(original: Option[Authenticato
getRequestingScheme))
finally Authenticator.setDefault(this)
}
originalAuthentication.getOrElse(null)
originalAuthentication.orNull
}
/**