diff --git a/compile/api/src/main/scala/sbt/ClassToAPI.scala b/compile/api/src/main/scala/sbt/ClassToAPI.scala index a6107fab6..fbfe1e930 100644 --- a/compile/api/src/main/scala/sbt/ClassToAPI.scala +++ b/compile/api/src/main/scala/sbt/ClassToAPI.scala @@ -73,7 +73,7 @@ object ClassToAPI { val fields = mergeMap(c, c.getDeclaredFields, c.getFields, fieldToDef(enclPkg)) val constructors = mergeMap(c, c.getDeclaredConstructors, c.getConstructors, constructorToDef(enclPkg)) val classes = merge[Class[_]](c, c.getDeclaredClasses, c.getClasses, toDefinitions(cmap), (_: Seq[Class[_]]).partition(isStatic), _.getEnclosingClass != c) - val all = (methods ++ fields ++ constructors ++ classes) + val all = methods ++ fields ++ constructors ++ classes val parentJavaTypes = allSuperTypes(c) if (!Modifier.isPrivate(c.getModifiers)) cmap.inherited ++= parentJavaTypes.collect { case c: Class[_] => c } @@ -111,7 +111,7 @@ object ClassToAPI { } @tailrec def flattenAll(interfaces: Seq[Type], accum: Seq[Type] = Seq.empty): Seq[Type] = { - if (!interfaces.isEmpty) { + if (interfaces.nonEmpty) { val raw = interfaces map { case p: ParameterizedType => p.getRawType; case i => i } val children = raw flatMap { case i: Class[_] => i.getGenericInterfaces; case _ => Seq.empty } flattenAll(children, accum ++ interfaces ++ children) diff --git a/compile/inc/notes b/compile/inc/notes index b198bfc2f..11d7537f5 100644 --- a/compile/inc/notes +++ b/compile/inc/notes @@ -1,6 +1,6 @@ each compilation group gets an Analysis an sbt-style project could have multiple compilation groups or there could be multiple projects per compilation group. -Tradiationally, there has been a main group and a test group. +Traditionally, there has been a main group and a test group. Each Analysis is associated with one or more classpath entries. Typically, it will be associated with the output directory and/or any artifacts produced from that output directory. diff --git a/compile/inc/src/main/scala/sbt/inc/Analysis.scala b/compile/inc/src/main/scala/sbt/inc/Analysis.scala index d9a9dee26..b692d9a31 100644 --- a/compile/inc/src/main/scala/sbt/inc/Analysis.scala +++ b/compile/inc/src/main/scala/sbt/inc/Analysis.scala @@ -155,7 +155,7 @@ private class MAnalysis(val stamps: Stamps, val apis: APIs, val relations: Relat def --(sources: Iterable[File]): Analysis = { val newRelations = relations -- sources - def keep[T](f: (Relations, T) => Set[_]): T => Boolean = !f(newRelations, _).isEmpty + def keep[T](f: (Relations, T) => Set[_]): T => Boolean = f(newRelations, _).nonEmpty val newAPIs = apis.removeInternal(sources).filterExt(keep(_ usesExternal _)) val newStamps = stamps.filter(keep(_ produced _), sources, keep(_ usesBinary _)) diff --git a/compile/inc/src/main/scala/sbt/inc/Incremental.scala b/compile/inc/src/main/scala/sbt/inc/Incremental.scala index 7973cbf7a..63d066d53 100644 --- a/compile/inc/src/main/scala/sbt/inc/Incremental.scala +++ b/compile/inc/src/main/scala/sbt/inc/Incremental.scala @@ -38,7 +38,7 @@ object Incremental { val analysis = manageClassfiles(options) { classfileManager => incremental.cycle(initialInv, sources, binaryChanges, previous, doCompile, classfileManager, 1) } - (!initialInv.isEmpty, analysis) + (initialInv.nonEmpty, analysis) } // the name of system property that was meant to enable debugging mode of incremental compiler but diff --git a/compile/inc/src/main/scala/sbt/inc/IncrementalCommon.scala b/compile/inc/src/main/scala/sbt/inc/IncrementalCommon.scala index 744bc30ac..e854c66a2 100644 --- a/compile/inc/src/main/scala/sbt/inc/IncrementalCommon.scala +++ b/compile/inc/src/main/scala/sbt/inc/IncrementalCommon.scala @@ -119,7 +119,7 @@ private[inc] abstract class IncrementalCommon(log: Logger, options: IncOptions) protected def sameAPI[T](src: T, a: Source, b: Source): Option[APIChange[T]] - def shortcutSameSource(a: Source, b: Source): Boolean = !a.hash.isEmpty && !b.hash.isEmpty && sameCompilation(a.compilation, b.compilation) && (a.hash.deep equals b.hash.deep) + def shortcutSameSource(a: Source, b: Source): Boolean = a.hash.nonEmpty && b.hash.nonEmpty && sameCompilation(a.compilation, b.compilation) && (a.hash.deep equals b.hash.deep) def sameCompilation(a: Compilation, b: Compilation): Boolean = a.startTime == b.startTime && a.outputs.corresponds(b.outputs) { case (co1, co2) => co1.sourceDirectory == co2.sourceDirectory && co1.outputDirectory == co2.outputDirectory } diff --git a/compile/inc/src/main/scala/sbt/inc/MemberRefInvalidator.scala b/compile/inc/src/main/scala/sbt/inc/MemberRefInvalidator.scala index 9c977cb42..28ac92515 100644 --- a/compile/inc/src/main/scala/sbt/inc/MemberRefInvalidator.scala +++ b/compile/inc/src/main/scala/sbt/inc/MemberRefInvalidator.scala @@ -54,7 +54,7 @@ private[inc] class MemberRefInvalidator(log: Logger) { def get[T](memberRef: Relation[File, T], usedNames: Relation[File, String], apiChange: APIChange[_]): T => Set[File] = apiChange match { case _: APIChangeDueToMacroDefinition[_] => new InvalidateUnconditionally(memberRef) - case NamesChange(_, modifiedNames) if !modifiedNames.implicitNames.isEmpty => + case NamesChange(_, modifiedNames) if modifiedNames.implicitNames.nonEmpty => new InvalidateUnconditionally(memberRef) case NamesChange(modifiedSrcFile, modifiedNames) => new NameHashFilteredInvalidator[T](usedNames, memberRef, modifiedNames.regularNames) @@ -65,7 +65,7 @@ private[inc] class MemberRefInvalidator(log: Logger) { def invalidationReason(apiChange: APIChange[_]): String = apiChange match { case APIChangeDueToMacroDefinition(modifiedSrcFile) => s"The $modifiedSrcFile source file declares a macro." - case NamesChange(modifiedSrcFile, modifiedNames) if !modifiedNames.implicitNames.isEmpty => + case NamesChange(modifiedSrcFile, modifiedNames) if modifiedNames.implicitNames.nonEmpty => s"""|The $modifiedSrcFile source file has the following implicit definitions changed: |\t${modifiedNames.implicitNames.mkString(", ")}.""".stripMargin case NamesChange(modifiedSrcFile, modifiedNames) => @@ -82,7 +82,7 @@ private[inc] class MemberRefInvalidator(log: Logger) { private class InvalidateUnconditionally[T](memberRef: Relation[File, T]) extends (T => Set[File]) { def apply(from: T): Set[File] = { val invalidated = memberRef.reverse(from) - if (!invalidated.isEmpty) + if (invalidated.nonEmpty) log.debug(s"The following member ref dependencies of $from are invalidated:\n" + formatInvalidated(invalidated)) invalidated diff --git a/compile/integration/src/main/scala/sbt/compiler/AggressiveCompile.scala b/compile/integration/src/main/scala/sbt/compiler/AggressiveCompile.scala index c4ce04804..5f001c8fc 100644 --- a/compile/integration/src/main/scala/sbt/compiler/AggressiveCompile.scala +++ b/compile/integration/src/main/scala/sbt/compiler/AggressiveCompile.scala @@ -90,7 +90,7 @@ class AggressiveCompile(cacheFile: File) { val (javaSrcs, scalaSrcs) = incSrc partition javaOnly logInputs(log, javaSrcs.size, scalaSrcs.size, outputDirs) def compileScala() = - if (!scalaSrcs.isEmpty) { + if (scalaSrcs.nonEmpty) { val sources = if (order == Mixed) incSrc else scalaSrcs val arguments = cArgs(Nil, absClasspath, None, options.options) timed("Scala compilation", log) { @@ -98,7 +98,7 @@ class AggressiveCompile(cacheFile: File) { } } def compileJava() = - if (!javaSrcs.isEmpty) { + if (javaSrcs.nonEmpty) { import Path._ @tailrec def ancestor(f1: File, f2: File): Boolean = if (f2 eq null) false else if (f1 == f2) true else ancestor(f1, f2.getParentFile) @@ -173,7 +173,7 @@ class AggressiveCompile(cacheFile: File) { val scalaMsg = Analysis.counted("Scala source", "", "s", scalaCount) val javaMsg = Analysis.counted("Java source", "", "s", javaCount) val combined = scalaMsg ++ javaMsg - if (!combined.isEmpty) + if (combined.nonEmpty) log.info(combined.mkString("Compiling ", " and ", " to " + outputDirs.map(_.getAbsolutePath).mkString(",") + "...")) } private def extract(previous: Option[(Analysis, CompileSetup)], incOptions: IncOptions): (Analysis, Option[CompileSetup]) = diff --git a/compile/interface/src/main/scala/xsbt/CompilerInterface.scala b/compile/interface/src/main/scala/xsbt/CompilerInterface.scala index 834a34ab1..10684e3f2 100644 --- a/compile/interface/src/main/scala/xsbt/CompilerInterface.scala +++ b/compile/interface/src/main/scala/xsbt/CompilerInterface.scala @@ -141,7 +141,7 @@ private final class CachedCompiler0(args: Array[String], output: Output, initial final class Compat { def allConditionalWarnings = List[CondWarnCompat]() } val warnings = run.allConditionalWarnings - if (!warnings.isEmpty) + if (warnings.nonEmpty) compiler.logUnreportedWarnings(warnings.map(cw => ("" /*cw.what*/ , cw.warnings.toList))) } diff --git a/compile/src/main/scala/sbt/LoggerReporter.scala b/compile/src/main/scala/sbt/LoggerReporter.scala index 8156e6343..8922d195f 100644 --- a/compile/src/main/scala/sbt/LoggerReporter.scala +++ b/compile/src/main/scala/sbt/LoggerReporter.scala @@ -124,7 +124,7 @@ class LoggerReporter(maximumErrors: Int, log: Logger, sourcePositionMapper: Posi false else { val key = new PositionKey(pos) - if (positions.get(key).map(_.ordinal >= severity.ordinal).getOrElse(false)) + if (positions.get(key).exists(_.ordinal >= severity.ordinal)) true else { positions(key) = severity diff --git a/compile/src/main/scala/sbt/compiler/javac/JavaErrorParser.scala b/compile/src/main/scala/sbt/compiler/javac/JavaErrorParser.scala index 5b5bcacd0..69218f159 100644 --- a/compile/src/main/scala/sbt/compiler/javac/JavaErrorParser.scala +++ b/compile/src/main/scala/sbt/compiler/javac/JavaErrorParser.scala @@ -30,7 +30,7 @@ object JavaNoPosition extends Position { } /** A wrapper around xsbti.Problem with java-specific options. */ -final case class JavaProblem(val position: Position, val severity: Severity, val message: String) extends xsbti.Problem { +final case class JavaProblem(position: Position, severity: Severity, message: String) extends xsbti.Problem { override def category: String = "javac" // TODO - what is this even supposed to be? For now it appears unused. override def toString = s"$severity @ $position - $message" } diff --git a/interface/src/main/java/xsbti/api/Modifiers.java b/interface/src/main/java/xsbti/api/Modifiers.java index 78fa13901..5e103c7ec 100644 --- a/interface/src/main/java/xsbti/api/Modifiers.java +++ b/interface/src/main/java/xsbti/api/Modifiers.java @@ -10,7 +10,7 @@ public final class Modifiers implements java.io.Serializable private static final int LazyBit = 5; private static final int MacroBit = 6; - private static final int flag(boolean set, int bit) + private static int flag(boolean set, int bit) { return set ? (1 << bit) : 0; } @@ -30,7 +30,7 @@ public final class Modifiers implements java.io.Serializable private final byte flags; - private final boolean flag(int bit) + private boolean flag(int bit) { return (flags & (1 << bit)) != 0; } diff --git a/interface/src/main/java/xsbti/compile/CompileOrder.java b/interface/src/main/java/xsbti/compile/CompileOrder.java index 62b15bf1f..5683f75d9 100644 --- a/interface/src/main/java/xsbti/compile/CompileOrder.java +++ b/interface/src/main/java/xsbti/compile/CompileOrder.java @@ -30,5 +30,5 @@ public enum CompileOrder * Then, Java sources are passed to the Java compiler, which generates class files for the Java sources. * The Scala classes compiled in the first step are included on the classpath to the Java compiler. */ - ScalaThenJava; + ScalaThenJava } \ No newline at end of file diff --git a/ivy/src/main/scala/sbt/ConflictWarning.scala b/ivy/src/main/scala/sbt/ConflictWarning.scala index 6e6b8a37d..082a478b6 100644 --- a/ivy/src/main/scala/sbt/ConflictWarning.scala +++ b/ivy/src/main/scala/sbt/ConflictWarning.scala @@ -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 { diff --git a/ivy/src/main/scala/sbt/EvictionWarning.scala b/ivy/src/main/scala/sbt/EvictionWarning.scala index 25ad9014b..cb786ca3f 100644 --- a/ivy/src/main/scala/sbt/EvictionWarning.scala +++ b/ivy/src/main/scala/sbt/EvictionWarning.scala @@ -93,7 +93,7 @@ object EvictionPair { } else "" r.module.revision + callers - }).headOption map { " -> " + _ } getOrElse "" + }) map { " -> " + _ } getOrElse "" Seq(s"\t* ${a.organization}:${a.name}:${revsStr}$winnerRev") } } @@ -160,7 +160,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 _ => } @@ -180,21 +180,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" } diff --git a/ivy/src/main/scala/sbt/Ivy.scala b/ivy/src/main/scala/sbt/Ivy.scala index c0e7d508a..8b3bfe5ec 100644 --- a/ivy/src/main/scala/sbt/Ivy.scala +++ b/ivy/src/main/scala/sbt/Ivy.scala @@ -19,7 +19,7 @@ import org.apache.ivy.core.cache.{ CacheMetadataOptions, DefaultRepositoryCacheM 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.{ IvyNode, ResolveData, ResolvedModuleRevision, ResolveEngine } import org.apache.ivy.core.settings.IvySettings @@ -496,7 +496,7 @@ private[sbt] object IvySbt { private def hasInfo(module: ModuleID, x: scala.xml.NodeSeq) = { val info = { x } \ "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.") @@ -508,7 +508,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 = @@ -582,7 +582,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) diff --git a/ivy/src/main/scala/sbt/IvyActions.scala b/ivy/src/main/scala/sbt/IvyActions.scala index a6754b138..39af5bee9 100644 --- a/ivy/src/main/scala/sbt/IvyActions.scala +++ b/ivy/src/main/scala/sbt/IvyActions.scala @@ -226,7 +226,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("$", "_", "")) @@ -375,16 +375,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 { diff --git a/ivy/src/main/scala/sbt/MakePom.scala b/ivy/src/main/scala/sbt/MakePom.scala index eba0cd94d..904be0c8c 100644 --- a/ivy/src/main/scala/sbt/MakePom.scala +++ b/ivy/src/main/scala/sbt/MakePom.scala @@ -258,7 +258,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 @@ -298,15 +298,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) { excls } + if (warns.nonEmpty) log.warn(warns.mkString(IO.Newline)) + if (excls.nonEmpty) { excls } else NodeSeq.Empty } def makeExclusion(exclRule: ExcludeRule): Either[String, NodeSeq] = diff --git a/ivy/src/main/scala/sbt/ResolutionCache.scala b/ivy/src/main/scala/sbt/ResolutionCache.scala index 41721a784..0fd7a0a06 100644 --- a/ivy/src/main/scala/sbt/ResolutionCache.scala +++ b/ivy/src/main/scala/sbt/ResolutionCache.scala @@ -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 = { diff --git a/ivy/src/main/scala/sbt/VersionNumber.scala b/ivy/src/main/scala/sbt/VersionNumber.scala index 7db8c8fef..182d44edc 100644 --- a/ivy/src/main/scala/sbt/VersionNumber.scala +++ b/ivy/src/main/scala/sbt/VersionNumber.scala @@ -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, _, _) => diff --git a/ivy/src/main/scala/sbt/ivyint/CachedResolutionResolveEngine.scala b/ivy/src/main/scala/sbt/ivyint/CachedResolutionResolveEngine.scala index 32442167a..76b576412 100644 --- a/ivy/src/main/scala/sbt/ivyint/CachedResolutionResolveEngine.scala +++ b/ivy/src/main/scala/sbt/ivyint/CachedResolutionResolveEngine.scala @@ -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 _ => diff --git a/ivy/src/main/scala/sbt/ivyint/ErrorMessageAuthenticator.scala b/ivy/src/main/scala/sbt/ivyint/ErrorMessageAuthenticator.scala index e59e36e34..bb5996834 100644 --- a/ivy/src/main/scala/sbt/ivyint/ErrorMessageAuthenticator.scala +++ b/ivy/src/main/scala/sbt/ivyint/ErrorMessageAuthenticator.scala @@ -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 } /** diff --git a/launch/interface/src/main/java/xsbti/CrossValue.java b/launch/interface/src/main/java/xsbti/CrossValue.java index 763cc8be8..fbeee82cf 100644 --- a/launch/interface/src/main/java/xsbti/CrossValue.java +++ b/launch/interface/src/main/java/xsbti/CrossValue.java @@ -2,5 +2,5 @@ package xsbti; public enum CrossValue { - Disabled, Full, Binary; + Disabled, Full, Binary } diff --git a/launch/interface/src/main/java/xsbti/Manage.java b/launch/interface/src/main/java/xsbti/Manage.java index fb5fcecd2..db63e12d4 100644 --- a/launch/interface/src/main/java/xsbti/Manage.java +++ b/launch/interface/src/main/java/xsbti/Manage.java @@ -2,5 +2,5 @@ package xsbti; enum Manage { - Nop, Clean, Refresh; + Nop, Clean, Refresh } \ No newline at end of file diff --git a/launch/src/main/scala/xsbt/boot/Create.scala b/launch/src/main/scala/xsbt/boot/Create.scala index 8e77dc93d..f09a4dac2 100644 --- a/launch/src/main/scala/xsbt/boot/Create.scala +++ b/launch/src/main/scala/xsbt/boot/Create.scala @@ -31,7 +31,7 @@ object Initialize { val properties = readProperties(file) val uninitialized = for (property <- appProperties; init <- select(property) if properties.getProperty(property.name) == null) yield initialize(properties, property.name, init) - if (!uninitialized.isEmpty) writeProperties(properties, file, "") + if (uninitialized.nonEmpty) writeProperties(properties, file, "") } def initialize(properties: Properties, name: String, init: PropertyInit) { init match { diff --git a/launch/src/main/scala/xsbt/boot/Launch.scala b/launch/src/main/scala/xsbt/boot/Launch.scala index afe4b285b..8e8863457 100644 --- a/launch/src/main/scala/xsbt/boot/Launch.scala +++ b/launch/src/main/scala/xsbt/boot/Launch.scala @@ -24,7 +24,7 @@ object Launch { case PropertiesFile => parseAndInitializeConfig(configLocation, currentDirectory) } if (arguments.isLocate) { - if (!newArgs2.isEmpty) { + if (newArgs2.nonEmpty) { // TODO - Print the arguments without exploding proguard size. System.err.println("Warning: --locate option ignores arguments.") } diff --git a/launch/src/main/scala/xsbt/boot/ResolveValues.scala b/launch/src/main/scala/xsbt/boot/ResolveValues.scala index 5e57c1243..0e69d0194 100644 --- a/launch/src/main/scala/xsbt/boot/ResolveValues.scala +++ b/launch/src/main/scala/xsbt/boot/ResolveValues.scala @@ -13,7 +13,7 @@ object ResolveValues { private def notEmpty(s: String) = if (isEmpty(s)) None else Some(s) } -import ResolveValues.{ trim } +import ResolveValues.trim final class ResolveValues(conf: LaunchConfiguration) { private def propertiesFile = conf.boot.properties private lazy val properties = readProperties(propertiesFile) diff --git a/main/actions/src/main/scala/sbt/Sync.scala b/main/actions/src/main/scala/sbt/Sync.scala index e69fea0c4..7e0f9f062 100644 --- a/main/actions/src/main/scala/sbt/Sync.scala +++ b/main/actions/src/main/scala/sbt/Sync.scala @@ -63,7 +63,7 @@ object Sync { case (target, srcs) => "\n\t" + target + "\nfrom\n\t" + srcs.mkString("\n\t\t") } - if (!dups.isEmpty) + if (dups.nonEmpty) sys.error("Duplicate mappings:" + dups.mkString) } diff --git a/main/actions/src/main/scala/sbt/TestResultLogger.scala b/main/actions/src/main/scala/sbt/TestResultLogger.scala index e8524a185..0f2e01378 100644 --- a/main/actions/src/main/scala/sbt/TestResultLogger.scala +++ b/main/actions/src/main/scala/sbt/TestResultLogger.scala @@ -142,7 +142,7 @@ object TestResultLogger { } def show(label: String, level: Level.Value, tests: Iterable[String]): Unit = - if (!tests.isEmpty) { + if (tests.nonEmpty) { log.log(level, label) log.log(level, tests.mkString("\t", "\n\t", "")) } diff --git a/main/actions/src/main/scala/sbt/Tests.scala b/main/actions/src/main/scala/sbt/Tests.scala index 9dee65e78..fb8b156e6 100644 --- a/main/actions/src/main/scala/sbt/Tests.scala +++ b/main/actions/src/main/scala/sbt/Tests.scala @@ -133,7 +133,7 @@ object Tests { for (option <- config.options) { option match { case Filter(include) => testFilters += include - case Filters(includes) => if (!orderedFilters.isEmpty) sys.error("Cannot define multiple ordered test filters.") else orderedFilters = includes + case Filters(includes) => if (orderedFilters.nonEmpty) sys.error("Cannot define multiple ordered test filters.") else orderedFilters = includes case Exclude(exclude) => excludeTestsSet ++= exclude case Listeners(listeners) => testListeners ++= listeners case Setup(setupFunction) => setup += setupFunction diff --git a/main/actions/src/test/scala/sbt/compiler/EvalTest.scala b/main/actions/src/test/scala/sbt/compiler/EvalTest.scala index fdbc6fe3d..95c7d9309 100644 --- a/main/actions/src/test/scala/sbt/compiler/EvalTest.scala +++ b/main/actions/src/test/scala/sbt/compiler/EvalTest.scala @@ -39,7 +39,7 @@ object EvalTest extends Properties("eval") { val v = value(result).asInstanceOf[{ def i: Int }].i (label("Value", v) |: (v == i)) && (label("Type", result.tpe) |: (result.tpe == LocalType)) && - (label("Files", result.generated) |: (!result.generated.isEmpty)) + (label("Files", result.generated) |: result.generated.nonEmpty) } } @@ -79,7 +79,7 @@ val p = { private[this] def hasErrors(line: Int, src: String) = { val is = reporter.infos - ("Has errors" |: (!is.isEmpty)) && + ("Has errors" |: is.nonEmpty) && all(is.toSeq.map(validPosition(line, src)): _*) } private[this] def validPosition(line: Int, src: String)(i: Info) = diff --git a/main/src/main/scala/sbt/Act.scala b/main/src/main/scala/sbt/Act.scala index f0aa68dd4..3606de881 100644 --- a/main/src/main/scala/sbt/Act.scala +++ b/main/src/main/scala/sbt/Act.scala @@ -172,7 +172,7 @@ object Act { def extrasParser(knownKeys: Map[String, AttributeKey[_]], knownValues: IMap[AttributeKey, Set]): Parser[AttributeMap] = { - val validKeys = knownKeys.filter { case (_, key) => knownValues get key exists (!_.isEmpty) } + val validKeys = knownKeys.filter { case (_, key) => knownValues get key exists (_.nonEmpty) } if (validKeys.isEmpty) failure("No valid extra keys.") else diff --git a/main/src/main/scala/sbt/Aggregation.scala b/main/src/main/scala/sbt/Aggregation.scala index 76c48b596..1a9cf039c 100644 --- a/main/src/main/scala/sbt/Aggregation.scala +++ b/main/src/main/scala/sbt/Aggregation.scala @@ -151,7 +151,7 @@ final object Aggregation { base.map { res => () => val newState = res() - if (show.settingValues && !settings.isEmpty) printSettings(settings, show.print) + if (show.settingValues && settings.nonEmpty) printSettings(settings, show.print) newState } } diff --git a/main/src/main/scala/sbt/BuildLoader.scala b/main/src/main/scala/sbt/BuildLoader.scala index d22327073..a515775e4 100644 --- a/main/src/main/scala/sbt/BuildLoader.scala +++ b/main/src/main/scala/sbt/BuildLoader.scala @@ -10,15 +10,15 @@ import Alternatives._ import Types.{ const, idFun } final class MultiHandler[S, T](builtIn: S => Option[T], root: Option[S => Option[T]], nonRoots: List[(URI, S => Option[T])], getURI: S => URI, log: S => Logger) { - def applyFun: S => Option[T] = apply _ + def applyFun: S => Option[T] = apply def apply(info: S): Option[T] = (baseLoader(info), applyNonRoots(info)) match { case (None, Nil) => None case (None, xs @ (_, nr) :: ignored) => - if (!ignored.isEmpty) warn("Using first of multiple matching non-root build resolvers for " + getURI(info), log(info), xs) + if (ignored.nonEmpty) warn("Using first of multiple matching non-root build resolvers for " + getURI(info), log(info), xs) Some(nr) case (Some(b), xs) => - if (!xs.isEmpty) warn("Ignoring shadowed non-root build resolver(s) for " + getURI(info), log(info), xs) + if (xs.nonEmpty) warn("Ignoring shadowed non-root build resolver(s) for " + getURI(info), log(info), xs) Some(b) } diff --git a/main/src/main/scala/sbt/BuildStructure.scala b/main/src/main/scala/sbt/BuildStructure.scala index 9e82d2584..30dfcf4e2 100644 --- a/main/src/main/scala/sbt/BuildStructure.scala +++ b/main/src/main/scala/sbt/BuildStructure.scala @@ -38,7 +38,7 @@ final class StructureIndex( * The first root project is used as the default in several situations where a project is not otherwise selected. */ final class LoadedBuildUnit(val unit: BuildUnit, val defined: Map[String, ResolvedProject], val rootProjects: Seq[String], val buildSettings: Seq[Setting[_]]) extends BuildUnitBase { - assert(!rootProjects.isEmpty, "No root projects defined for build unit " + unit) + assert(rootProjects.nonEmpty, "No root projects defined for build unit " + unit) /** * The project to use as the default when one is not otherwise selected. * [[LocalRootProject]] resolves to this from within the same build. @@ -112,7 +112,7 @@ final class DetectedModules[T](val modules: Seq[(String, T)]) { } /** Auto-detected auto plugin. */ -case class DetectedAutoPlugin(val name: String, val value: AutoPlugin, val hasAutoImport: Boolean) +case class DetectedAutoPlugin(name: String, value: AutoPlugin, hasAutoImport: Boolean) /** * Auto-discovered modules for the build definition project. These include modules defined in build definition sources diff --git a/main/src/main/scala/sbt/Cross.scala b/main/src/main/scala/sbt/Cross.scala index e77e94a88..c023ec9a3 100644 --- a/main/src/main/scala/sbt/Cross.scala +++ b/main/src/main/scala/sbt/Cross.scala @@ -27,7 +27,7 @@ object Cross { val optionalCommand = token(Space ~> matched(state.combinedParser)) ?? "" spacedVersion ~ optionalCommand } - token(SwitchCommand ~> OptSpace) flatMap { sp => versionAndCommand(!sp.isEmpty) } + token(SwitchCommand ~> OptSpace) flatMap { sp => versionAndCommand(sp.nonEmpty) } } def spacedFirst(name: String) = opOrIDSpaced(name) ~ any.+ diff --git a/main/src/main/scala/sbt/EvaluateConfigurations.scala b/main/src/main/scala/sbt/EvaluateConfigurations.scala index 80b3f8d89..28450f0ec 100644 --- a/main/src/main/scala/sbt/EvaluateConfigurations.scala +++ b/main/src/main/scala/sbt/EvaluateConfigurations.scala @@ -215,7 +215,7 @@ object EvaluateConfigurations { /** Configures the use of the old sbt parser. */ private[sbt] def useOldParser: Boolean = - sys.props.get("sbt.parser.simple").map(java.lang.Boolean.parseBoolean).getOrElse(false) + sys.props.get("sbt.parser.simple").exists(java.lang.Boolean.parseBoolean) /** * Splits a set of lines into (imports, expressions). That is, * anything on the right of the tuple is a scala expression (definition or setting). diff --git a/main/src/main/scala/sbt/Load.scala b/main/src/main/scala/sbt/Load.scala index 7ac5ca259..b9dad65e3 100755 --- a/main/src/main/scala/sbt/Load.scala +++ b/main/src/main/scala/sbt/Load.scala @@ -256,12 +256,12 @@ object Load { // the files aren't properly returned, even though they should be. // TODO - figure out where the caching of whether or not to generate classfiles occurs, and // put cleanups there, perhaps. - if (!keepSet.isEmpty) { + if (keepSet.nonEmpty) { def keepFile(f: File) = keepSet(f.getCanonicalPath) import Path._ val existing = (baseTarget.***.get).filterNot(_.isDirectory) val toDelete = existing.filterNot(keepFile) - if (!toDelete.isEmpty) { + if (toDelete.nonEmpty) { IO.delete(toDelete) } } @@ -711,11 +711,11 @@ object Load { // How to merge SbtFiles we read into one thing def merge(ls: Seq[LoadedSbtFile]): LoadedSbtFile = (LoadedSbtFile.empty /: ls) { _ merge _ } // Loads a given file, or pulls from the cache. - def memoLoadSettingsFile(src: File): LoadedSbtFile = memoSettings.get(src) getOrElse { + def memoLoadSettingsFile(src: File): LoadedSbtFile = memoSettings.getOrElse(src, { val lf = loadSettingsFile(src) memoSettings.put(src, lf.clearProjects) // don't load projects twice lf - } + }) // Loads a set of sbt files, sorted by their lexical name (current behavior of sbt). def loadFiles(fs: Seq[File]): LoadedSbtFile = merge(fs.sortBy(_.getName).map(memoLoadSettingsFile)) @@ -777,7 +777,7 @@ object Load { def hasDefinition(dir: File) = { import Path._ - !(dir * -GlobFilter(DefaultTargetName)).get.isEmpty + (dir * -GlobFilter(DefaultTargetName)).get.nonEmpty } def noPlugins(dir: File, config: sbt.LoadBuildConfiguration): sbt.LoadedPlugins = loadPluginDefinition(dir, config, PluginData(config.globalPluginClasspath, None, None)) diff --git a/main/src/main/scala/sbt/Plugins.scala b/main/src/main/scala/sbt/Plugins.scala index 6d789ac18..228b8048d 100644 --- a/main/src/main/scala/sbt/Plugins.scala +++ b/main/src/main/scala/sbt/Plugins.scala @@ -139,7 +139,7 @@ object Plugins extends PluginsFunctions { // TODO: defined should return all the plugins val allReqs = (defined0 flatMap { asRequirements }).toSet val diff = allReqs diff defined0.toSet - val defined = if (!diff.isEmpty) diff.toList ::: defined0 + val defined = if (diff.nonEmpty) diff.toList ::: defined0 else defined0 val byAtom = defined map { x => (Atom(x.label), x) } @@ -170,7 +170,7 @@ object Plugins extends PluginsFunctions { } val forbidden: Set[AutoPlugin] = (selectedPlugins flatMap { Plugins.asExclusions }).toSet val c = selectedPlugins.toSet & forbidden - if (!c.isEmpty) { + if (c.nonEmpty) { exlusionConflictError(requestedPlugins, selectedPlugins, c.toSeq sortBy {_.label}) } val retval = topologicalSort(selectedPlugins, log) @@ -217,12 +217,12 @@ object Plugins extends PluginsFunctions { else Nil) ++ { val reqs = selected filter { x => asRequirements(x) contains c } - if (!reqs.isEmpty) List(s"""required by ${reqs.mkString(", ")}""") + if (reqs.nonEmpty) List(s"""required by ${reqs.mkString(", ")}""") else Nil } ++ { val exs = selected filter { x => asExclusions(x) contains c } - if (!exs.isEmpty) List(s"""excluded by ${exs.mkString(", ")}""") + if (exs.nonEmpty) List(s"""excluded by ${exs.mkString(", ")}""") else Nil } s""" - conflict: ${c.label} is ${reasons.mkString("; ")}""" diff --git a/main/src/main/scala/sbt/SessionSettings.scala b/main/src/main/scala/sbt/SessionSettings.scala index 1e61c82f0..5f59f0974 100755 --- a/main/src/main/scala/sbt/SessionSettings.scala +++ b/main/src/main/scala/sbt/SessionSettings.scala @@ -126,7 +126,7 @@ object SessionSettings { /** Checks to see if any session settings are being discarded and issues a warning. */ def checkSession(newSession: SessionSettings, oldState: State) { val oldSettings = (oldState get Keys.sessionSettings).toList.flatMap(_.append).flatMap(_._2) - if (newSession.append.isEmpty && !oldSettings.isEmpty) + if (newSession.append.isEmpty && oldSettings.nonEmpty) oldState.log.warn("Discarding " + pluralize(oldSettings.size, " session setting") + ". Use 'session save' to persist session settings.") } @@ -167,7 +167,7 @@ object SessionSettings { def saveSomeSettings(s: State)(include: ProjectRef => Boolean): State = withSettings(s) { session => val newSettings = - for ((ref, settings) <- session.append if !settings.isEmpty && include(ref)) yield { + for ((ref, settings) <- session.append if settings.nonEmpty && include(ref)) yield { val (news, olds) = writeSettings(ref, settings.toList, session.original, Project.structure(s)) (ref -> news, olds) } @@ -206,7 +206,7 @@ object SessionSettings { val newSettings = settings diff replace val oldContent = IO.readLines(writeTo) val (_, exist) = SbtRefactorings.applySessionSettings((writeTo, oldContent), replace) - val adjusted = if (!newSettings.isEmpty && needsTrailingBlank(exist)) exist :+ "" else exist + val adjusted = if (newSettings.nonEmpty && needsTrailingBlank(exist)) exist :+ "" else exist val lines = adjusted ++ newSettings.flatMap(x => x._2 :+ "") IO.writeLines(writeTo, lines) val (newWithPos, _) = ((List[SessionSetting](), adjusted.size + 1) /: newSettings) { @@ -218,12 +218,12 @@ object SessionSettings { } @deprecated("This method will no longer be public", "0.13.7") - def needsTrailingBlank(lines: Seq[String]) = !lines.isEmpty && !lines.takeRight(1).exists(_.trim.isEmpty) + def needsTrailingBlank(lines: Seq[String]) = lines.nonEmpty && !lines.takeRight(1).exists(_.trim.isEmpty) /** Prints all the user-defined SessionSettings (not raw) to System.out. */ def printAllSettings(s: State): State = withSettings(s) { session => - for ((ref, settings) <- session.append if !settings.isEmpty) { + for ((ref, settings) <- session.append if settings.nonEmpty) { println("In " + Reference.display(ref)) printSettings(settings) } diff --git a/main/src/test/scala/Delegates.scala b/main/src/test/scala/Delegates.scala index d74d8526f..84ad678d1 100644 --- a/main/src/test/scala/Delegates.scala +++ b/main/src/test/scala/Delegates.scala @@ -11,14 +11,14 @@ import Prop._ import Gen._ object Delegates extends Properties("delegates") { - property("generate non-empty configs") = forAll { (c: Seq[Config]) => !c.isEmpty } - property("generate non-empty tasks") = forAll { (t: Seq[Taskk]) => !t.isEmpty } + property("generate non-empty configs") = forAll { (c: Seq[Config]) => c.nonEmpty } + property("generate non-empty tasks") = forAll { (t: Seq[Taskk]) => t.nonEmpty } property("no duplicate scopes") = forAll { (keys: Keys) => allDelegates(keys) { (_, ds) => ds.distinct.size == ds.size } } property("delegates non-empty") = forAll { (keys: Keys) => - allDelegates(keys) { (_, ds) => !ds.isEmpty } + allDelegates(keys) { (_, ds) => ds.nonEmpty } } property("An initially Global axis is Global in all delegates") = allAxes(alwaysGlobal) diff --git a/main/src/test/scala/TagsTest.scala b/main/src/test/scala/TagsTest.scala index 8eb6846bc..9fa087908 100644 --- a/main/src/test/scala/TagsTest.scala +++ b/main/src/test/scala/TagsTest.scala @@ -1,7 +1,7 @@ package sbt import org.scalacheck._ -import Gen.{ listOf } +import Gen.listOf import Prop._ import Tags._ diff --git a/project/Release.scala b/project/Release.scala index 5412a1172..1aef1a9ef 100644 --- a/project/Release.scala +++ b/project/Release.scala @@ -1,6 +1,6 @@ import sbt._ import Keys._ -import Status.{ publishStatus } +import Status.publishStatus import org.apache.ivy.util.url.CredentialsStore import com.typesafe.sbt.JavaVersionCheckPlugin.autoImport._ diff --git a/project/Transform.scala b/project/Transform.scala index fea7661e3..c5ab9d026 100644 --- a/project/Transform.scala +++ b/project/Transform.scala @@ -18,7 +18,7 @@ object Transform { def conscriptSettings(launch: Reference) = Seq( conscriptConfigs <<= (managedResources in launch in Compile, sourceDirectory in Compile).map { (res, src) => - val source = res.filter(_.getName == "sbt.boot.properties").headOption getOrElse sys.error("No managed boot.properties file.") + val source = res.find(_.getName == "sbt.boot.properties") getOrElse sys.error("No managed boot.properties file.") copyConscriptProperties(source, src / "conscript") () } diff --git a/project/Util.scala b/project/Util.scala index 0e932a68e..039e9d298 100644 --- a/project/Util.scala +++ b/project/Util.scala @@ -124,12 +124,12 @@ object Util { def cleanPom(pomNode: scala.xml.Node) = { import scala.xml._ - def cleanNodes(nodes: Seq[Node]): Seq[Node] = nodes flatMap (_ match { - case elem @ Elem(prefix, "dependency", attributes, scope, children @ _*) if excludePomDependency(elem) => + def cleanNodes(nodes: Seq[Node]): Seq[Node] = nodes flatMap ({ + case elem@Elem(prefix, "dependency", attributes, scope, children@_*) if excludePomDependency(elem) => NodeSeq.Empty - case Elem(prefix, "classifier", attributes, scope, children @ _*) => + case Elem(prefix, "classifier", attributes, scope, children@_*) => NodeSeq.Empty - case Elem(prefix, label, attributes, scope, children @ _*) => + case Elem(prefix, label, attributes, scope, children@_*) => Elem(prefix, label, attributes, scope, cleanNodes(children): _*).theSeq case other => other }) diff --git a/run/src/main/scala/sbt/Run.scala b/run/src/main/scala/sbt/Run.scala index b2fc3add6..e7d55a851 100644 --- a/run/src/main/scala/sbt/Run.scala +++ b/run/src/main/scala/sbt/Run.scala @@ -50,9 +50,9 @@ class Run(instance: ScalaInstance, trapExit: Boolean, nativeTmp: File) extends S def execute() = try { run0(mainClass, classpath, options, log) } catch { case e: java.lang.reflect.InvocationTargetException => throw e.getCause } - def directExecute() = try { execute; None } catch { case e: Exception => log.trace(e); Some(e.toString) } + def directExecute() = try { execute(); None } catch { case e: Exception => log.trace(e); Some(e.toString) } - if (trapExit) Run.executeTrapExit(execute, log) else directExecute + if (trapExit) Run.executeTrapExit(execute(), log) else directExecute() } private def run0(mainClassName: String, classpath: Seq[File], options: Seq[String], log: Logger) { log.debug(" Classpath:\n\t" + classpath.mkString("\n\t")) @@ -62,9 +62,9 @@ class Run(instance: ScalaInstance, trapExit: Boolean, nativeTmp: File) extends S } private def invokeMain(loader: ClassLoader, main: Method, options: Seq[String]) { val currentThread = Thread.currentThread - val oldLoader = Thread.currentThread.getContextClassLoader() + val oldLoader = Thread.currentThread.getContextClassLoader currentThread.setContextClassLoader(loader) - try { main.invoke(null, options.toArray[String].asInstanceOf[Array[String]]) } + try { main.invoke(null, options.toArray[String]) } finally { currentThread.setContextClassLoader(oldLoader) } } def getMainMethod(mainClassName: String, loader: ClassLoader) = diff --git a/sbt/src/sbt-test/dependency-management/info/project/InfoTest.scala b/sbt/src/sbt-test/dependency-management/info/project/InfoTest.scala index 3fe11e7e3..0410bfca5 100644 --- a/sbt/src/sbt-test/dependency-management/info/project/InfoTest.scala +++ b/sbt/src/sbt-test/dependency-management/info/project/InfoTest.scala @@ -38,5 +38,5 @@ object InfoTest extends Build } else if( deliveredWithCustom(d) ) sys.error("Expected empty 'info' tag, got: \n" + (d \ "info")) else () } - def deliveredWithCustom(d: NodeSeq) = !(d \ "info" \ "license").isEmpty && !(d \ "info" \ "description").isEmpty + def deliveredWithCustom(d: NodeSeq) = (d \ "info" \ "license").nonEmpty && (d \ "info" \ "description").nonEmpty } \ No newline at end of file diff --git a/sbt/src/sbt-test/dependency-management/inline-dependencies-a/build.sbt b/sbt/src/sbt-test/dependency-management/inline-dependencies-a/build.sbt index 41e371a5b..9ea22504b 100644 --- a/sbt/src/sbt-test/dependency-management/inline-dependencies-a/build.sbt +++ b/sbt/src/sbt-test/dependency-management/inline-dependencies-a/build.sbt @@ -4,7 +4,7 @@ ivyPaths <<= baseDirectory( dir => new IvyPaths(dir, Some(dir / "ivy-home"))) TaskKey[Unit]("check") <<= update map { report => val files = report.matching( moduleFilter(organization = "org.scalacheck", name = "scalacheck", revision = "1.5") ) - assert(!files.isEmpty, "ScalaCheck module not found in update report") + assert(files.nonEmpty, "ScalaCheck module not found in update report") val missing = files.filter(! _.exists) assert(missing.isEmpty, "Reported ScalaCheck artifact files don't exist: " + missing.mkString(", ")) } diff --git a/sbt/src/sbt-test/dependency-management/ivy-settings-a/build.sbt b/sbt/src/sbt-test/dependency-management/ivy-settings-a/build.sbt index 7d398a91d..7c11071a3 100644 --- a/sbt/src/sbt-test/dependency-management/ivy-settings-a/build.sbt +++ b/sbt/src/sbt-test/dependency-management/ivy-settings-a/build.sbt @@ -2,5 +2,5 @@ seq(externalIvySettings(), externalIvyFile()) TaskKey[Unit]("check") := { val files = update.value.matching( moduleFilter(organization = "org.scalacheck", name = "scalacheck*", revision = "1.9") ) - assert(!files.isEmpty, "ScalaCheck module not found in update report") + assert(files.nonEmpty, "ScalaCheck module not found in update report") } \ No newline at end of file diff --git a/sbt/src/sbt-test/dependency-management/ivy-settings-b/build.sbt b/sbt/src/sbt-test/dependency-management/ivy-settings-b/build.sbt index 49e490c09..955227dfa 100644 --- a/sbt/src/sbt-test/dependency-management/ivy-settings-b/build.sbt +++ b/sbt/src/sbt-test/dependency-management/ivy-settings-b/build.sbt @@ -4,5 +4,5 @@ libraryDependencies += "org.scalacheck" % "scalacheck" % "1.5" TaskKey[Unit]("check") <<= (baseDirectory, update) map { (base, report) => val files = report.matching( moduleFilter(organization = "org.scalacheck", name = "scalacheck", revision = "1.5") ) - assert(!files.isEmpty, "ScalaCheck module not found in update report") + assert(files.nonEmpty, "ScalaCheck module not found in update report") } \ No newline at end of file diff --git a/sbt/src/sbt-test/dependency-management/pom-type/build.sbt b/sbt/src/sbt-test/dependency-management/pom-type/build.sbt index e06101113..899fa1aab 100644 --- a/sbt/src/sbt-test/dependency-management/pom-type/build.sbt +++ b/sbt/src/sbt-test/dependency-management/pom-type/build.sbt @@ -8,6 +8,6 @@ checkPom := { val pomFile = makePom.value val pom = xml.XML.loadFile(pomFile) val tpe = pom \\ "type" - if(!tpe.isEmpty) + if(tpe.nonEmpty) error("Expected no sections, got: " + tpe + " in \n\n" + pom) } \ No newline at end of file diff --git a/sbt/src/sbt-test/dependency-management/sources/project/Test.scala b/sbt/src/sbt-test/dependency-management/sources/project/Test.scala index bf8b162b4..30b4035b6 100644 --- a/sbt/src/sbt-test/dependency-management/sources/project/Test.scala +++ b/sbt/src/sbt-test/dependency-management/sources/project/Test.scala @@ -26,6 +26,6 @@ object Test extends Build def checkBinaries(report: UpdateReport): Unit = { val srcs = getSources(report) - if(!srcs.isEmpty) sys.error("Sources retrieved:\n\t" + srcs.mkString("\n\t")) else () + if(srcs.nonEmpty) sys.error("Sources retrieved:\n\t" + srcs.mkString("\n\t")) else () } } \ No newline at end of file diff --git a/sbt/src/sbt-test/project/default-settings/build.sbt b/sbt/src/sbt-test/project/default-settings/build.sbt index a00c6c634..2abcd6b5a 100644 --- a/sbt/src/sbt-test/project/default-settings/build.sbt +++ b/sbt/src/sbt-test/project/default-settings/build.sbt @@ -4,5 +4,5 @@ val root = Project("root", file("."), settings=Defaults.defaultSettings) TaskKey[Unit]("checkArtifacts", "test") := { val arts = packagedArtifacts.value - assert(!arts.isEmpty, "Packaged artifacts must not be empty!") + assert(arts.nonEmpty, "Packaged artifacts must not be empty!") } \ No newline at end of file diff --git a/scripted/base/src/main/scala/xsbt/test/TestScriptParser.scala b/scripted/base/src/main/scala/xsbt/test/TestScriptParser.scala index afb8ae05b..04af324ba 100644 --- a/scripted/base/src/main/scala/xsbt/test/TestScriptParser.scala +++ b/scripted/base/src/main/scala/xsbt/test/TestScriptParser.scala @@ -30,7 +30,7 @@ private object TestScriptParser { import TestScriptParser._ class TestScriptParser(handlers: Map[Char, StatementHandler]) extends RegexParsers { - require(!handlers.isEmpty) + require(handlers.nonEmpty) override def skipWhitespace = false import IO.read diff --git a/scripted/sbt/src/main/scala/sbt/test/ScriptedTests.scala b/scripted/sbt/src/main/scala/sbt/test/ScriptedTests.scala index 5afb9b737..b2b3336bd 100644 --- a/scripted/sbt/src/main/scala/sbt/test/ScriptedTests.scala +++ b/scripted/sbt/src/main/scala/sbt/test/ScriptedTests.scala @@ -156,7 +156,7 @@ private[test] final class ListTests(baseDirectory: File, accept: ScriptedTest => val (included, skipped) = allTests.toList.partition(test => accept(ScriptedTest(groupName, test.getName))) if (included.isEmpty) log.warn("Test group " + groupName + " skipped.") - else if (!skipped.isEmpty) { + else if (skipped.nonEmpty) { log.warn("Tests skipped in group " + group.getName + ":") skipped.foreach(testName => log.warn(" " + testName.getName)) } diff --git a/tasks/src/main/scala/sbt/Execute.scala b/tasks/src/main/scala/sbt/Execute.scala index 2ebaef558..f8419cf9c 100644 --- a/tasks/src/main/scala/sbt/Execute.scala +++ b/tasks/src/main/scala/sbt/Execute.scala @@ -73,7 +73,7 @@ private[sbt] final class Execute[A[_] <: AnyRef](config: Config, triggers: Trigg def processAll()(implicit strategy: Strategy) { @tailrec def next() { pre { - assert(!reverse.isEmpty, "Nothing to process.") + assert(reverse.nonEmpty, "Nothing to process.") if (!state.values.exists(_ == Running)) { snapshotCycleCheck() assert(false, "Internal task engine error: nothing running. This usually indicates a cycle in tasks.\n Calling tasks (internal task engine state):\n" + dumpCalling) @@ -81,7 +81,7 @@ private[sbt] final class Execute[A[_] <: AnyRef](config: Config, triggers: Trigg } (strategy.take()).process() - if (!reverse.isEmpty) next() + if (reverse.nonEmpty) next() } next() diff --git a/tasks/standard/src/test/scala/TaskRunnerFork.scala b/tasks/standard/src/test/scala/TaskRunnerFork.scala index 3201cb9f6..ba40e4c5c 100644 --- a/tasks/standard/src/test/scala/TaskRunnerFork.scala +++ b/tasks/standard/src/test/scala/TaskRunnerFork.scala @@ -27,7 +27,7 @@ object TaskRunnerForkTest extends Properties("TaskRunner Fork") { tryRun(List.range(0, a).map(inner).join, false, workers) } property("fork and reduce") = forAll(TaskListGen, MaxWorkersGen) { (m: List[Int], workers: Int) => - (!m.isEmpty) ==> { + m.nonEmpty ==> { val expected = m.reduceLeft(_ + _) checkResult(tryRun(m.tasks.reduced(_ + _), false, workers), expected) } diff --git a/testing/agent/src/main/java/sbt/ForkMain.java b/testing/agent/src/main/java/sbt/ForkMain.java index 32cbb62ef..15f53ce25 100755 --- a/testing/agent/src/main/java/sbt/ForkMain.java +++ b/testing/agent/src/main/java/sbt/ForkMain.java @@ -132,7 +132,7 @@ public class ForkMain { private static class Run { - void run(ObjectInputStream is, ObjectOutputStream os) throws Exception { + void run(ObjectInputStream is, ObjectOutputStream os) { try { runTests(is, os); } catch (RunAborted e) { diff --git a/testing/agent/src/main/java/sbt/ForkTags.java b/testing/agent/src/main/java/sbt/ForkTags.java index 31ee70223..7fe3f365b 100644 --- a/testing/agent/src/main/java/sbt/ForkTags.java +++ b/testing/agent/src/main/java/sbt/ForkTags.java @@ -4,6 +4,6 @@ package sbt; public enum ForkTags { - Error, Warn, Info, Debug, Done; + Error, Warn, Info, Debug, Done } diff --git a/testing/src/main/scala/sbt/JUnitXmlTestsListener.scala b/testing/src/main/scala/sbt/JUnitXmlTestsListener.scala index 6403b38eb..2611486ec 100644 --- a/testing/src/main/scala/sbt/JUnitXmlTestsListener.scala +++ b/testing/src/main/scala/sbt/JUnitXmlTestsListener.scala @@ -1,7 +1,7 @@ package sbt import java.io.{ IOException, StringWriter, PrintWriter, File } -import java.net.{ InetAddress } +import java.net.InetAddress import scala.collection.mutable.ListBuffer import scala.util.DynamicVariable diff --git a/testing/src/main/scala/sbt/TestFramework.scala b/testing/src/main/scala/sbt/TestFramework.scala index 0bbab2058..e31b22fdd 100644 --- a/testing/src/main/scala/sbt/TestFramework.scala +++ b/testing/src/main/scala/sbt/TestFramework.scala @@ -22,7 +22,7 @@ object TestFrameworks { val JUnit = new TestFramework("com.novocode.junit.JUnitFramework") } -case class TestFramework(val implClassNames: String*) { +case class TestFramework(implClassNames: String*) { @tailrec private def createFramework(loader: ClassLoader, log: Logger, frameworkClassNames: List[String]): Option[Framework] = { frameworkClassNames match { @@ -150,7 +150,7 @@ object TestFramework { for (framework <- frameworks.find(isTestForFramework)) map.getOrElseUpdate(framework, new HashSet[TestDefinition]) += test } - if (!frameworks.isEmpty) + if (frameworks.nonEmpty) for (test <- tests) assignTest(test) map.toMap.mapValues(_.toSet) } diff --git a/util/collection/src/main/scala/sbt/AList.scala b/util/collection/src/main/scala/sbt/AList.scala index 10e1454e7..24368219b 100644 --- a/util/collection/src/main/scala/sbt/AList.scala +++ b/util/collection/src/main/scala/sbt/AList.scala @@ -46,7 +46,7 @@ object AList { def traverse[M[_], N[_], P[_]](s: List[M[T]], f: M ~> (N ∙ P)#l)(implicit np: Applicative[N]): N[List[P[T]]] = ??? } - /** AList for the abitrary arity data structure KList. */ + /** AList for the arbitrary arity data structure KList. */ def klist[KL[M[_]] <: KList[M] { type Transform[N[_]] = KL[N] }]: AList[KL] = new AList[KL] { def transform[M[_], N[_]](k: KL[M], f: M ~> N) = k.transform(f) def foldr[M[_], T](k: KL[M], f: (M[_], T) => T, init: T): T = k.foldr(f, init) diff --git a/util/collection/src/main/scala/sbt/Settings.scala b/util/collection/src/main/scala/sbt/Settings.scala index de7d9a8fb..a8e5b1d6c 100644 --- a/util/collection/src/main/scala/sbt/Settings.scala +++ b/util/collection/src/main/scala/sbt/Settings.scala @@ -24,14 +24,14 @@ private final class Settings0[Scope](val data: Map[Scope, AttributeMap], val del def get[T](scope: Scope, key: AttributeKey[T]): Option[T] = delegates(scope).toStream.flatMap(sc => getDirect(sc, key)).headOption def definingScope(scope: Scope, key: AttributeKey[_]): Option[Scope] = - delegates(scope).toStream.filter(sc => getDirect(sc, key).isDefined).headOption + delegates(scope).toStream.find(sc => getDirect(sc, key).isDefined) def getDirect[T](scope: Scope, key: AttributeKey[T]): Option[T] = (data get scope).flatMap(_ get key) def set[T](scope: Scope, key: AttributeKey[T], value: T): Settings[Scope] = { - val map = (data get scope) getOrElse AttributeMap.empty + val map = data getOrElse(scope, AttributeMap.empty) val newData = data.updated(scope, map.put(key, value)) new Settings0(newData, delegates) } @@ -85,7 +85,7 @@ trait Init[Scope] { */ private[sbt] final def validated[T](key: ScopedKey[T], selfRefOk: Boolean): ValidationCapture[T] = new ValidationCapture(key, selfRefOk) - @deprecated("0.13.7", "Use the version with default arguments and default paramter.") + @deprecated("0.13.7", "Use the version with default arguments and default parameter.") final def derive[T](s: Setting[T], allowDynamic: Boolean, filter: Scope => Boolean, trigger: AttributeKey[_] => Boolean): Setting[T] = derive(s, allowDynamic, filter, trigger, false) /** @@ -258,7 +258,7 @@ trait Init[Scope] { def Undefined(defining: Setting[_], referencedKey: ScopedKey[_]): Undefined = new Undefined(defining, referencedKey) def Uninitialized(validKeys: Seq[ScopedKey[_]], delegates: Scope => Seq[Scope], keys: Seq[Undefined], runtime: Boolean)(implicit display: Show[ScopedKey[_]]): Uninitialized = { - assert(!keys.isEmpty) + assert(keys.nonEmpty) val suffix = if (keys.length > 1) "s" else "" val prefix = if (runtime) "Runtime reference" else "Reference" val keysString = keys.map(u => showUndefined(u, validKeys, delegates)).mkString("\n\n ", "\n\n ", "") @@ -487,7 +487,7 @@ trait Init[Scope] { override def default(_id: => Long): DefaultSetting[T] = new DerivedSetting[T](sk, i, p, filter, trigger) with DefaultSetting[T] { val id = _id } override def toString = "derived " + super.toString } - // Only keep the first occurence of this setting and move it to the front so that it has lower precedence than non-defaults. + // Only keep the first occurrence of this setting and move it to the front so that it has lower precedence than non-defaults. // This is intended for internal sbt use only, where alternatives like Plugin.globalSettings are not available. private[Init] sealed trait DefaultSetting[T] extends Setting[T] { val id: Long diff --git a/util/collection/src/test/scala/SettingsTest.scala b/util/collection/src/test/scala/SettingsTest.scala index dbad035c6..d97b1056a 100644 --- a/util/collection/src/test/scala/SettingsTest.scala +++ b/util/collection/src/test/scala/SettingsTest.scala @@ -42,10 +42,10 @@ object SettingsTest extends Properties("settings") { { val genScopedKeys = { // We wan - // t to generate lists of keys that DO NOT inclue the "ch" key we use to check thigns. + // t to generate lists of keys that DO NOT inclue the "ch" key we use to check things. val attrKeys = mkAttrKeys[Int](nr).filter(_.forall(_.label != "ch")) attrKeys map (_ map (ak => ScopedKey(Scope(0), ak))) - }.label("scopedKeys").filter(!_.isEmpty) + }.label("scopedKeys").filter(_.nonEmpty) forAll(genScopedKeys) { scopedKeys => try { // Note; It's evil to grab last IF you haven't verified the set can't be empty. diff --git a/util/complete/src/main/scala/sbt/complete/Parser.scala b/util/complete/src/main/scala/sbt/complete/Parser.scala index 393501792..c52d16b91 100644 --- a/util/complete/src/main/scala/sbt/complete/Parser.scala +++ b/util/complete/src/main/scala/sbt/complete/Parser.scala @@ -187,7 +187,7 @@ object Parser extends ParserMain { @deprecated("This method is deprecated and will be removed in the next major version. Use the parser directly to check for invalid completions.", since = "0.13.2") def checkMatches(a: Parser[_], completions: Seq[String]) { val bad = completions.filter(apply(a)(_).resultEmpty.isFailure) - if (!bad.isEmpty) sys.error("Invalid example completions: " + bad.mkString("'", "', '", "'")) + if (bad.nonEmpty) sys.error("Invalid example completions: " + bad.mkString("'", "', '", "'")) } def tuple[A, B](a: Option[A], b: Option[B]): Option[(A, B)] = @@ -378,7 +378,7 @@ trait ParserMain { def unapply[A, B](t: (A, B)): Some[(A, B)] = Some(t) } - /** Parses input `str` using `parser`. If successful, the result is provided wrapped in `Right`. If unsuccesful, an error message is provided in `Left`.*/ + /** Parses input `str` using `parser`. If successful, the result is provided wrapped in `Right`. If unsuccessful, an error message is provided in `Left`.*/ def parse[T](str: String, parser: Parser[T]): Either[String, T] = Parser.result(parser, str).left.map { failures => val (msgs, pos) = failures() @@ -480,7 +480,7 @@ trait ParserMain { def matched(t: Parser[_], seen: Vector[Char] = Vector.empty, partial: Boolean = false): Parser[String] = t match { - case i: Invalid => if (partial && !seen.isEmpty) success(seen.mkString) else i + case i: Invalid => if (partial && seen.nonEmpty) success(seen.mkString) else i case _ => if (t.result.isEmpty) new MatchedString(t, seen, partial) @@ -634,7 +634,7 @@ private final class HetParser[A, B](a: Parser[A], b: Parser[B]) extends ValidPar override def toString = "(" + a + " || " + b + ")" } private final class ParserSeq[T](a: Seq[Parser[T]], errors: => Seq[String]) extends ValidParser[Seq[T]] { - assert(!a.isEmpty) + assert(a.nonEmpty) lazy val resultEmpty: Result[Seq[T]] = { val res = a.map(_.resultEmpty) diff --git a/util/io/src/main/scala/sbt/PathMapper.scala b/util/io/src/main/scala/sbt/PathMapper.scala index b172c6ba9..4db009184 100644 --- a/util/io/src/main/scala/sbt/PathMapper.scala +++ b/util/io/src/main/scala/sbt/PathMapper.scala @@ -92,14 +92,14 @@ trait Mapper { import Alternatives._ /** - * Selects all descendents of `base` directory and maps them to a path relative to `base`. + * Selects all descendants of `base` directory and maps them to a path relative to `base`. * `base` itself is not included. */ def allSubpaths(base: File): Traversable[(File, String)] = selectSubpaths(base, AllPassFilter) /** - * Selects descendents of `base` directory matching `filter` and maps them to a path relative to `base`. + * Selects descendants of `base` directory matching `filter` and maps them to a path relative to `base`. * `base` itself is not included. */ def selectSubpaths(base: File, filter: FileFilter): Traversable[(File, String)] = diff --git a/util/logic/src/main/scala/sbt/logic/Logic.scala b/util/logic/src/main/scala/sbt/logic/Logic.scala index 72f2b2f64..856394251 100644 --- a/util/logic/src/main/scala/sbt/logic/Logic.scala +++ b/util/logic/src/main/scala/sbt/logic/Logic.scala @@ -277,7 +277,7 @@ object Logic { } /** Represents the set of atoms in the heads of clauses and in the bodies (formulas) of clauses. */ - final case class Atoms(val inHead: Set[Atom], val inFormula: Set[Atom]) { + final case class Atoms(inHead: Set[Atom], inFormula: Set[Atom]) { /** Concatenates this with `as`. */ def ++(as: Atoms): Atoms = Atoms(inHead ++ as.inHead, inFormula ++ as.inFormula) /** Atoms that cannot be true because they do not occur in a head. */ diff --git a/util/process/src/main/scala/sbt/Process.scala b/util/process/src/main/scala/sbt/Process.scala index 66b7e03c6..79435367d 100644 --- a/util/process/src/main/scala/sbt/Process.scala +++ b/util/process/src/main/scala/sbt/Process.scala @@ -34,7 +34,7 @@ object Process extends ProcessExtra { /** create ProcessBuilder with working dir set to File and extra environment variables */ def apply(command: Seq[String], cwd: File, extraEnv: (String, String)*): ProcessBuilder = apply(command, Some(cwd), extraEnv: _*) - /** create ProcessBuilder with working dir optionaly set to File and extra environment variables */ + /** create ProcessBuilder with working dir optionally set to File and extra environment variables */ def apply(command: String, cwd: Option[File], extraEnv: (String, String)*): ProcessBuilder = { apply(command.split("""\s+"""), cwd, extraEnv: _*) // not smart to use this on windows, because CommandParser uses \ to escape ". @@ -43,7 +43,7 @@ object Process extends ProcessExtra { case Right((cmd, args)) => apply(cmd :: args, cwd, extraEnv : _*) }*/ } - /** create ProcessBuilder with working dir optionaly set to File and extra environment variables */ + /** create ProcessBuilder with working dir optionally set to File and extra environment variables */ def apply(command: Seq[String], cwd: Option[File], extraEnv: (String, String)*): ProcessBuilder = { val jpb = new JProcessBuilder(command.toArray: _*) cwd.foreach(jpb directory _) @@ -63,7 +63,7 @@ object Process extends ProcessExtra { def cat(file: SourcePartialBuilder, files: SourcePartialBuilder*): ProcessBuilder = cat(file :: files.toList) def cat(files: Seq[SourcePartialBuilder]): ProcessBuilder = { - require(!files.isEmpty) + require(files.nonEmpty) files.map(_.cat).reduceLeft(_ #&& _) } } diff --git a/util/process/src/test/scala/TestedProcess.scala b/util/process/src/test/scala/TestedProcess.scala index 5daea8bab..f83207a07 100644 --- a/util/process/src/test/scala/TestedProcess.scala +++ b/util/process/src/test/scala/TestedProcess.scala @@ -16,7 +16,7 @@ object cat { catFiles(args.toList) System.exit(0) } catch { - case e => + case e: Throwable => e.printStackTrace() System.err.println("Error: " + e.toString) System.exit(1)