From 54d54b9f4f03e2e3339373ed582f2b19359bea31 Mon Sep 17 00:00:00 2001 From: Pierre DAL-PRA Date: Mon, 3 Aug 2015 23:13:59 +0200 Subject: [PATCH] Replace procedure syntax by explicit Unit annotation --- cache/src/main/scala/sbt/Cache.scala | 14 ++-- .../api/src/main/scala/sbt/ClassToAPI.scala | 6 +- .../api/src/main/scala/xsbt/api/APIUtil.scala | 6 +- .../api/src/main/scala/xsbt/api/HashAPI.scala | 41 ++++++------ .../api/src/main/scala/xsbt/api/Visit.scala | 65 +++++++++---------- .../main/scala/sbt/inc/AnalysisStore.scala | 4 +- .../main/scala/sbt/inc/ClassfileManager.scala | 10 +-- .../inc/src/main/scala/sbt/inc/Compile.scala | 2 +- .../sbt/compiler/AggressiveCompile.scala | 2 +- .../sbt/compiler/MixedAnalyzingCompiler.scala | 2 +- .../interface/src/main/scala/xsbt/API.scala | 6 +- .../src/main/scala/xsbt/Analyzer.scala | 3 +- .../main/scala/xsbt/CompilerInterface.scala | 20 +++--- .../main/scala/xsbt/ConsoleInterface.scala | 6 +- .../main/scala/xsbt/DelegatingReporter.scala | 19 +++--- .../src/main/scala/xsbt/Dependency.scala | 6 +- .../main/scala/xsbt/ScaladocInterface.scala | 6 +- .../sbt/compiler/ComponentCompiler.scala | 2 +- .../main/scala/sbt/inc/AnalysisFormats.scala | 2 +- .../main/scala/sbt/inc/FileBasedStore.scala | 4 +- .../scala/sbt/inc/TextAnalysisFormat.scala | 41 +++++------- .../scala/xsbt/api/CompilationFormat.scala | 2 +- .../main/scala/xsbt/api/SourceFormat.scala | 2 +- .../src/main/scala/sbt/LoggerReporter.scala | 12 ++-- .../sbt/compiler/CompilerArguments.scala | 2 +- .../scala/sbt/compiler/CompilerCache.scala | 2 +- .../scala/sbt/compiler/JavaCompiler.scala | 2 +- .../main/scala/sbt/compiler/RawCompiler.scala | 4 +- .../compiler/javac/DiagnosticsReporter.scala | 2 +- .../compiler/javac/ProcessLoggerWriter.scala | 2 +- .../src/test/scala/xsbti/TestCallback.scala | 14 ++-- .../ReplaceMavenConfigurationMappings.scala | 12 ++-- ivy/src/main/scala/sbt/ConflictWarning.scala | 4 +- ivy/src/main/scala/sbt/ConvertResolver.scala | 10 +-- ivy/src/main/scala/sbt/CustomXmlParser.scala | 6 +- ivy/src/main/scala/sbt/Ivy.scala | 24 +++---- ivy/src/main/scala/sbt/IvyActions.scala | 8 +-- ivy/src/main/scala/sbt/IvyCache.scala | 8 +-- ivy/src/main/scala/sbt/IvyLogger.scala | 34 +++++----- ivy/src/main/scala/sbt/IvyScala.scala | 10 +-- ivy/src/main/scala/sbt/MakePom.scala | 3 +- ivy/src/main/scala/sbt/ProjectResolver.scala | 14 ++-- ivy/src/main/scala/sbt/ResolutionCache.scala | 6 +- ivy/src/main/scala/sbt/StringUtilities.scala | 4 +- .../ivyint/ErrorMessageAuthenticator.scala | 4 +- .../actions/src/main/scala/sbt/DotGraph.scala | 8 +-- main/actions/src/main/scala/sbt/Package.scala | 10 +-- .../src/main/scala/sbt/compiler/Eval.scala | 2 +- .../command/src/main/scala/sbt/MainLoop.scala | 8 +-- main/command/src/main/scala/sbt/State.scala | 2 +- main/src/main/scala/sbt/Aggregation.scala | 4 +- main/src/main/scala/sbt/BuildLoader.scala | 4 +- main/src/main/scala/sbt/BuildPaths.scala | 2 +- main/src/main/scala/sbt/BuildUtil.scala | 2 +- main/src/main/scala/sbt/ConsoleProject.scala | 2 +- main/src/main/scala/sbt/Defaults.scala | 4 +- main/src/main/scala/sbt/EvaluateTask.scala | 2 +- main/src/main/scala/sbt/Load.scala | 6 +- main/src/main/scala/sbt/LogManager.scala | 2 +- main/src/main/scala/sbt/Main.scala | 6 +- main/src/main/scala/sbt/Plugins.scala | 4 +- main/src/main/scala/sbt/Project.scala | 4 +- main/src/main/scala/sbt/Resolvers.scala | 9 ++- main/src/main/scala/sbt/SessionSettings.scala | 2 +- .../parser/SplitExpressionsBehavior.scala | 6 +- project/Scripted.scala | 2 +- project/SiteMap.scala | 4 +- project/Transform.scala | 2 +- run/src/main/scala/sbt/Run.scala | 4 +- run/src/main/scala/sbt/TrapExit.scala | 40 ++++++------ .../scala/sbt/TrapExitSecurityException.scala | 2 +- .../update-state-fail/project/Build.scala | 2 +- .../src/main/scala/jartest/Main.scala | 4 +- .../sbt-test/project/auto-plugins/build.sbt | 4 +- sbt/src/sbt-test/project/derived/build.sbt | 2 +- .../project/flatten/test-src/SimpleTest.scala | 6 +- .../project/global-plugin/changes/Build.scala | 3 +- .../src-scala-binary-version/build.sbt | 2 +- sbt/src/sbt-test/run/awt/A.scala | 2 +- sbt/src/sbt-test/run/concurrent/build.sbt | 4 +- .../sbt-test/run/concurrent/changes/C.scala | 8 +-- .../daemon-exit/src/main/scala/Daemon.scala | 13 ++-- .../run/daemon/src/main/scala/Daemon.scala | 6 +- .../error/changes/RunExplicitFailure.scala | 4 +- .../error/changes/RunExplicitSuccess.scala | 4 +- .../run/error/changes/RunSuccess.scala | 4 +- .../run/fork-loader/CheckLoader.scala | 6 +- .../run/fork/src/main/scala/ForkFail.scala | 2 +- .../run/spawn/src/main/scala/Spawn.scala | 30 ++++----- .../implicit-search/changes/C.scala | 3 +- .../inherited-dependencies/B.scala | 6 +- .../inherited-dependencies/build.sbt | 2 +- .../inherited-deps-java/build.sbt | 2 +- .../java-mixed/changes/S1.scala | 2 +- .../java-mixed/changes/S2.scala | 2 +- .../replace-test-a/changes/first.scala | 4 +- .../replace-test-a/changes/second.scala | 4 +- .../source-dependencies/specialized/B.scala | 4 +- .../trait-super/Main.scala | 2 +- .../src/test/scala/ArgumentTest.scala | 4 +- .../main/scala/custom/CustomReporter.scala | 8 +-- .../main/scala/custom/CustomReporter.scala | 14 ++-- .../fork-parallel/src/test/scala/tests.scala | 12 ++-- .../src/test/scala/tests.scala | 15 ++--- .../tests/junit/changes/Failure.scala | 2 +- .../tests/junit/changes/Success.scala | 2 +- .../main/scala/custom/CustomReporter.scala | 8 +-- .../main/scala/custom/CustomReporter.scala | 8 +-- .../main/scala/custom/CustomReporter.scala | 8 +-- .../main/scala/custom/CustomReporter.scala | 8 +-- .../tests/t543/project/Ticket543Test.scala | 8 +-- .../main/scala/custom/CustomReporter.scala | 8 +-- .../tests/test-quick/src/main/scala/B.scala | 2 +- .../main/scala/xsbt/test/FileCommands.scala | 6 +- .../main/scala/xsbt/test/ScriptRunner.scala | 6 +- .../main/scala/sbt/test/ScriptedTests.scala | 6 +- tasks/src/main/scala/sbt/Execute.scala | 34 +++++----- tasks/src/main/scala/sbt/Incomplete.scala | 4 +- .../src/main/scala/sbt/std/Streams.scala | 4 +- .../src/main/scala/sbt/std/System.scala | 4 +- .../src/test/scala/TaskRunnerFork.scala | 2 +- tasks/standard/src/test/scala/Test.scala | 4 +- .../scala/sbt/JUnitXmlTestsListener.scala | 2 +- .../src/main/scala/sbt/TestFramework.scala | 4 +- .../main/scala/sbt/TestReportListener.scala | 12 ++-- .../main/scala/sbt/TestStatusReporter.scala | 12 ++-- .../main/scala/sbt/appmacro/ContextUtil.scala | 2 +- .../main/scala/sbt/classfile/Analyze.scala | 4 +- .../src/main/scala/sbt/classpath/RawURL.scala | 4 +- util/collection/src/main/scala/sbt/Dag.scala | 14 ++-- .../collection/src/main/scala/sbt/INode.scala | 6 +- .../collection/src/main/scala/sbt/Param.scala | 4 +- .../src/main/scala/sbt/Settings.scala | 2 +- .../scala/sbt/complete/JLineCompletion.scala | 10 +-- .../src/main/scala/sbt/complete/Parser.scala | 4 +- util/complete/src/test/scala/ParserTest.scala | 10 +-- .../xsbt/datatype/GenerateDatatypes.scala | 2 +- .../main/scala/xsbt/datatype/Generator.scala | 8 +-- util/io/src/main/scala/sbt/IO.scala | 43 ++++++------ util/io/src/main/scala/sbt/Pack.scala | 12 ++-- util/io/src/test/scala/CopySpec.scala | 8 +-- .../src/main/scala/sbt/ConsoleLogger.scala | 10 +-- .../log/src/main/scala/sbt/FilterLogger.scala | 12 ++-- util/log/src/main/scala/sbt/FullLogger.scala | 6 +- .../log/src/main/scala/sbt/LoggerWriter.scala | 4 +- util/log/src/main/scala/sbt/MultiLogger.scala | 20 +++--- util/log/src/test/scala/LogWriterTest.scala | 14 ++-- .../src/main/scala/sbt/ProcessImpl.scala | 24 +++---- .../src/test/scala/TestedProcess.scala | 9 ++- 149 files changed, 576 insertions(+), 601 deletions(-) diff --git a/cache/src/main/scala/sbt/Cache.scala b/cache/src/main/scala/sbt/Cache.scala index c241394ba..bdfd8cb51 100644 --- a/cache/src/main/scala/sbt/Cache.scala +++ b/cache/src/main/scala/sbt/Cache.scala @@ -40,7 +40,7 @@ object Cache extends CacheImplicits { println(label + ".read: " + v) v } - def write(to: Out, v: Internal) { + def write(to: Out, v: Internal): Unit = { println(label + ".write: " + v) c.write(to, v) } @@ -119,7 +119,7 @@ trait BasicCacheImplicits { if (left <= 0) acc.reverse else next(left - 1, t.read(from) :: acc) next(size, Nil) } - def write(to: Out, vs: Internal) { + def write(to: Out, vs: Internal): Unit = { val size = vs.length IntFormat.writes(to, size) for (v <- vs) t.write(to, v) @@ -165,7 +165,7 @@ trait HListCacheImplicits { val t = tail.read(from) (h, t) } - def write(to: Out, j: Internal) { + def write(to: Out, j: Internal): Unit = { head.write(to, j._1) tail.write(to, j._2) } @@ -185,7 +185,7 @@ trait HListCacheImplicits { val t = tail.reads(from) HCons(h, t) } - def writes(to: Out, hc: H :+: T) { + def writes(to: Out, hc: H :+: T): Unit = { head.writes(to, hc.head) tail.writes(to, hc.tail) } @@ -205,8 +205,8 @@ trait UnionImplicits { val value = cache.read(in) new Found[cache.Internal](cache, clazz, value, index) } - def write(to: Out, i: Internal) { - def write0[I](f: Found[I]) { + def write(to: Out, i: Internal): Unit = { + def write0[I](f: Found[I]): Unit = { ByteFormat.writes(to, f.index.toByte) f.cache.write(to, f.value) } @@ -245,4 +245,4 @@ trait UnionImplicits { def at(i: Int): (InputCache[_ <: UB], Class[_]) def find(forValue: UB): Found[_] } -} \ No newline at end of file +} diff --git a/compile/api/src/main/scala/sbt/ClassToAPI.scala b/compile/api/src/main/scala/sbt/ClassToAPI.scala index acf593daf..37e8a5919 100644 --- a/compile/api/src/main/scala/sbt/ClassToAPI.scala +++ b/compile/api/src/main/scala/sbt/ClassToAPI.scala @@ -44,7 +44,11 @@ object ClassToAPI { c.getEnclosingClass eq null final class ClassMap private[sbt] (private[sbt] val memo: mutable.Map[String, Seq[api.ClassLike]], private[sbt] val inherited: mutable.Set[Class[_]], private[sbt] val lz: mutable.Buffer[xsbti.api.Lazy[_]]) { - def clear() { memo.clear(); inherited.clear(); lz.clear() } + def clear(): Unit = { + memo.clear() + inherited.clear() + lz.clear() + } } def emptyClassMap: ClassMap = new ClassMap(new mutable.HashMap, new mutable.HashSet, new mutable.ListBuffer) diff --git a/compile/api/src/main/scala/xsbt/api/APIUtil.scala b/compile/api/src/main/scala/xsbt/api/APIUtil.scala index 32bec717a..e7c4ac1c8 100644 --- a/compile/api/src/main/scala/xsbt/api/APIUtil.scala +++ b/compile/api/src/main/scala/xsbt/api/APIUtil.scala @@ -29,12 +29,12 @@ object APIUtil { // Don't visit inherited definitions since we consider that a class // that inherits a macro does not have a macro. - override def visitStructure0(structure: Structure) { + override def visitStructure0(structure: Structure): Unit = { visitTypes(structure.parents) visitDefinitions(structure.declared) } - override def visitModifiers(m: Modifiers) { + override def visitModifiers(m: Modifiers): Unit = { hasMacro ||= m.isMacro super.visitModifiers(m) } @@ -63,4 +63,4 @@ object APIUtil { private[this] def lzy[T <: AnyRef](t: T): Lazy[T] = SafeLazy.strict(t) private[this] val emptyType = new EmptyType -} \ No newline at end of file +} diff --git a/compile/api/src/main/scala/xsbt/api/HashAPI.scala b/compile/api/src/main/scala/xsbt/api/HashAPI.scala index 30b6d7654..89452f237 100644 --- a/compile/api/src/main/scala/xsbt/api/HashAPI.scala +++ b/compile/api/src/main/scala/xsbt/api/HashAPI.scala @@ -49,7 +49,7 @@ final class HashAPI(includePrivate: Boolean, includeParamNames: Boolean, include private[this] val visitedStructures = visitedMap[Structure] private[this] val visitedClassLike = visitedMap[ClassLike] private[this] def visitedMap[T] = new mutable.HashMap[T, List[Hash]] - private[this] def visit[T](map: mutable.Map[T, List[Hash]], t: T)(hashF: T => Unit) { + private[this] def visit[T](map: mutable.Map[T, List[Hash]], t: T)(hashF: T => Unit): Unit = { map.put(t, hash :: map.getOrElse(t, Nil)) match { case Some(x :: _) => extend(x) case _ => @@ -102,11 +102,11 @@ final class HashAPI(includePrivate: Boolean, includeParamNames: Boolean, include @inline final def hashString(s: String): Unit = extend(stringHash(s)) @inline final def hashBoolean(b: Boolean): Unit = extend(if (b) TrueHash else FalseHash) - @inline final def hashSeq[T](s: Seq[T], hashF: T => Unit) { + @inline final def hashSeq[T](s: Seq[T], hashF: T => Unit): Unit = { extend(s.length) s foreach hashF } - final def hashSymmetric[T](ts: TraversableOnce[T], hashF: T => Unit) { + final def hashSymmetric[T](ts: TraversableOnce[T], hashF: T => Unit): Unit = { val current = hash val mA = magicA val mB = magicB @@ -123,7 +123,7 @@ final class HashAPI(includePrivate: Boolean, includeParamNames: Boolean, include extend(symmetricHash(hashes, 0xb592f7ae)) // constant from MurmurHash3 } - @inline final def extend(a: Hash) { + @inline final def extend(a: Hash): Unit = { hash = extendHash(hash, a, magicA, magicB) magicA = nextMagicA(magicA) magicB = nextMagicB(magicB) @@ -166,7 +166,7 @@ final class HashAPI(includePrivate: Boolean, includeParamNames: Boolean, include } hashSymmetric(ds, (hashDefinitionCombined _).tupled) } - def hashDefinition(d: Definition) { + def hashDefinition(d: Definition): Unit = { hashString(d.name) hashAnnotations(d.annotations) hashModifiers(d.modifiers) @@ -180,20 +180,20 @@ final class HashAPI(includePrivate: Boolean, includeParamNames: Boolean, include } } final def hashClass(c: ClassLike): Unit = visit(visitedClassLike, c)(hashClass0) - def hashClass0(c: ClassLike) { + def hashClass0(c: ClassLike): Unit = { extend(ClassHash) hashParameterizedDefinition(c) hashType(c.selfType) hashStructure(c.structure, includeDefinitions) } - def hashField(f: FieldLike) { + def hashField(f: FieldLike): Unit = { f match { case v: Var => extend(VarHash) case v: Val => extend(ValHash) } hashType(f.tpe) } - def hashDef(d: Def) { + def hashDef(d: Def): Unit = { extend(DefHash) hashParameterizedDefinition(d) hashValueParameters(d.valueParameters) @@ -236,23 +236,23 @@ final class HashAPI(includePrivate: Boolean, includeParamNames: Boolean, include hashBoolean(parameter.hasDefault) } - def hashParameterizedDefinition[T <: ParameterizedDefinition](d: T) { + def hashParameterizedDefinition[T <: ParameterizedDefinition](d: T): Unit = { hashTypeParameters(d.typeParameters) } - def hashTypeDeclaration(d: TypeDeclaration) { + def hashTypeDeclaration(d: TypeDeclaration): Unit = { extend(TypeDeclHash) hashParameterizedDefinition(d) hashType(d.lowerBound) hashType(d.upperBound) } - def hashTypeAlias(d: TypeAlias) { + def hashTypeAlias(d: TypeAlias): Unit = { extend(TypeAliasHash) hashParameterizedDefinition(d) hashType(d.tpe) } def hashTypeParameters(parameters: Seq[TypeParameter]) = hashSeq(parameters, hashTypeParameter) - def hashTypeParameter(parameter: TypeParameter) { + def hashTypeParameter(parameter: TypeParameter): Unit = { hashString(parameter.id) extend(parameter.variance.ordinal) hashTypeParameters(parameter.typeParameters) @@ -267,7 +267,7 @@ final class HashAPI(includePrivate: Boolean, includeParamNames: Boolean, include hashAnnotationArguments(annotation.arguments) } def hashAnnotationArguments(args: Seq[AnnotationArgument]) = hashSeq(args, hashAnnotationArgument) - def hashAnnotationArgument(arg: AnnotationArgument) { + def hashAnnotationArgument(arg: AnnotationArgument): Unit = { hashString(arg.name) hashString(arg.value) } @@ -288,11 +288,11 @@ final class HashAPI(includePrivate: Boolean, includeParamNames: Boolean, include case pr: ParameterRef => hashParameterRef(pr) } - def hashParameterRef(p: ParameterRef) { + def hashParameterRef(p: ParameterRef): Unit = { extend(ParameterRefHash) hashString(p.id) } - def hashSingleton(s: Singleton) { + def hashSingleton(s: Singleton): Unit = { extend(SingletonHash) hashPath(s.path) } @@ -302,11 +302,11 @@ final class HashAPI(includePrivate: Boolean, includeParamNames: Boolean, include case s: Super => hashSuperPath(s) case id: Id => hashIdPath(id) } - def hashSuperPath(s: Super) { + def hashSuperPath(s: Super): Unit = { extend(SuperHash) hashPath(s.qualifier) } - def hashIdPath(id: Id) { + def hashIdPath(id: Id): Unit = { extend(IdPathHash) hashString(id.id) } @@ -333,19 +333,19 @@ final class HashAPI(includePrivate: Boolean, includeParamNames: Boolean, include hashString(p.id) hashType(p.prefix) } - def hashParameterized(p: Parameterized) { + def hashParameterized(p: Parameterized): Unit = { extend(ParameterizedHash) hashType(p.baseType) hashTypes(p.typeArguments) } - def hashAnnotated(a: Annotated) { + def hashAnnotated(a: Annotated): Unit = { extend(AnnotatedHash) hashType(a.baseType) hashAnnotations(a.annotations) } final def hashStructure(structure: Structure, includeDefinitions: Boolean) = visit(visitedStructures, structure)(structure => hashStructure0(structure, includeDefinitions)) - def hashStructure0(structure: Structure, includeDefinitions: Boolean) { + def hashStructure0(structure: Structure, includeDefinitions: Boolean): Unit = { extend(StructureHash) hashTypes(structure.parents, includeDefinitions) if (includeDefinitions) { @@ -359,4 +359,3 @@ final class HashAPI(includePrivate: Boolean, includeParamNames: Boolean, include hashType(base) } } - diff --git a/compile/api/src/main/scala/xsbt/api/Visit.scala b/compile/api/src/main/scala/xsbt/api/Visit.scala index 9cbb44ea0..f6e2d2058 100644 --- a/compile/api/src/main/scala/xsbt/api/Visit.scala +++ b/compile/api/src/main/scala/xsbt/api/Visit.scala @@ -17,12 +17,12 @@ class Visit { s.definitions foreach visitDefinition } - def visitPackage(p: Package) { + def visitPackage(p: Package): Unit = { visitString(p.name) } def visitDefinitions(ds: Seq[Definition]) = ds foreach visitDefinition - def visitDefinition(d: Definition) { + def visitDefinition(d: Definition): Unit = { visitString(d.name) visitAnnotations(d.annotations) visitModifiers(d.modifiers) @@ -36,21 +36,21 @@ class Visit { } } final def visitClass(c: ClassLike): Unit = if (visitedClassLike add c) visitClass0(c) - def visitClass0(c: ClassLike) { + def visitClass0(c: ClassLike): Unit = { visitParameterizedDefinition(c) visitType(c.selfType) visitStructure(c.structure) } - def visitField(f: FieldLike) { + def visitField(f: FieldLike): Unit = { visitType(f.tpe) f match { case v: Var => visitVar(v) case v: Val => visitVal(v) } } - def visitVar(v: Var) {} - def visitVal(v: Val) {} - def visitDef(d: Def) { + def visitVar(v: Var): Unit = () + def visitVal(v: Val): Unit = () + def visitDef(d: Def): Unit = { visitParameterizedDefinition(d) visitValueParameters(d.valueParameters) visitType(d.returnType) @@ -71,15 +71,15 @@ class Visit { case thisq: ThisQualifier => visitThisQualifier(thisq) case id: IdQualifier => visitIdQualifier(id) } - def visitIdQualifier(id: IdQualifier) { + def visitIdQualifier(id: IdQualifier): Unit = { visitString(id.value) } - def visitUnqualified(unq: Unqualified) {} - def visitThisQualifier(thisq: ThisQualifier) {} - def visitPublic(pub: Public) {} - def visitPrivate(p: Private) { visitQualifier(p.qualifier) } - def visitProtected(p: Protected) { visitQualifier(p.qualifier) } - def visitModifiers(m: Modifiers) {} + def visitUnqualified(unq: Unqualified): Unit = () + def visitThisQualifier(thisq: ThisQualifier): Unit = () + def visitPublic(pub: Public): Unit = () + def visitPrivate(p: Private): Unit = visitQualifier(p.qualifier) + def visitProtected(p: Protected): Unit = visitQualifier(p.qualifier) + def visitModifiers(m: Modifiers): Unit = () def visitValueParameters(valueParameters: Seq[ParameterList]) = valueParameters foreach visitValueParameterList def visitValueParameterList(list: ParameterList) = list.parameters foreach visitValueParameter @@ -89,21 +89,20 @@ class Visit { visitType(parameter.tpe) } - def visitParameterizedDefinition[T <: ParameterizedDefinition](d: T) { - visitTypeParameters(d.typeParameters) - } - def visitTypeDeclaration(d: TypeDeclaration) { + def visitParameterizedDefinition[T <: ParameterizedDefinition](d: T): Unit = visitTypeParameters(d.typeParameters) + + def visitTypeDeclaration(d: TypeDeclaration): Unit = { visitParameterizedDefinition(d) visitType(d.lowerBound) visitType(d.upperBound) } - def visitTypeAlias(d: TypeAlias) { + def visitTypeAlias(d: TypeAlias): Unit = { visitParameterizedDefinition(d) visitType(d.tpe) } def visitTypeParameters(parameters: Seq[TypeParameter]) = parameters foreach visitTypeParameter - def visitTypeParameter(parameter: TypeParameter) { + def visitTypeParameter(parameter: TypeParameter): Unit = { visitTypeParameters(parameter.typeParameters) visitType(parameter.lowerBound) visitType(parameter.upperBound) @@ -116,13 +115,13 @@ class Visit { visitAnnotationArguments(annotation.arguments) } def visitAnnotationArguments(args: Seq[AnnotationArgument]) = args foreach visitAnnotationArgument - def visitAnnotationArgument(arg: AnnotationArgument) { + def visitAnnotationArgument(arg: AnnotationArgument): Unit = { visitString(arg.name) visitString(arg.value) } def visitTypes(ts: Seq[Type]) = ts.foreach(visitType) - def visitType(t: Type) { + def visitType(t: Type): Unit = { t match { case s: Structure => visitStructure(s) case e: Existential => visitExistential(e) @@ -137,18 +136,18 @@ class Visit { } } - def visitEmptyType() {} - def visitParameterRef(p: ParameterRef) {} - def visitSingleton(s: Singleton) { visitPath(s.path) } + def visitEmptyType(): Unit = () + def visitParameterRef(p: ParameterRef): Unit = () + def visitSingleton(s: Singleton): Unit = visitPath(s.path) def visitPath(path: Path) = path.components foreach visitPathComponent def visitPathComponent(pc: PathComponent) = pc match { case t: This => visitThisPath(t) case s: Super => visitSuperPath(s) case id: Id => visitIdPath(id) } - def visitThisPath(t: This) {} - def visitSuperPath(s: Super) { visitPath(s.qualifier) } - def visitIdPath(id: Id) { visitString(id.id) } + def visitThisPath(t: This): Unit = () + def visitSuperPath(s: Super): Unit = visitPath(s.qualifier) + def visitIdPath(id: Id): Unit = visitString(id.id) def visitConstant(c: Constant) = { @@ -162,16 +161,16 @@ class Visit { visitString(p.id) visitType(p.prefix) } - def visitParameterized(p: Parameterized) { + def visitParameterized(p: Parameterized): Unit = { visitType(p.baseType) visitTypes(p.typeArguments) } - def visitAnnotated(a: Annotated) { + def visitAnnotated(a: Annotated): Unit = { visitType(a.baseType) visitAnnotations(a.annotations) } final def visitStructure(structure: Structure) = if (visitedStructures add structure) visitStructure0(structure) - def visitStructure0(structure: Structure) { + def visitStructure0(structure: Structure): Unit = { visitTypes(structure.parents) visitDefinitions(structure.declared) visitDefinitions(structure.inherited) @@ -181,5 +180,5 @@ class Visit { visitTypeParameters(parameters) visitType(base) } - def visitString(s: String) {} -} \ No newline at end of file + def visitString(s: String): Unit = () +} diff --git a/compile/inc/src/main/scala/sbt/inc/AnalysisStore.scala b/compile/inc/src/main/scala/sbt/inc/AnalysisStore.scala index b505e0ee3..4ecede85a 100644 --- a/compile/inc/src/main/scala/sbt/inc/AnalysisStore.scala +++ b/compile/inc/src/main/scala/sbt/inc/AnalysisStore.scala @@ -12,7 +12,7 @@ trait AnalysisStore { object AnalysisStore { def cached(backing: AnalysisStore): AnalysisStore = new AnalysisStore { private var last: Option[(Analysis, CompileSetup)] = None - def set(analysis: Analysis, setup: CompileSetup) { + def set(analysis: Analysis, setup: CompileSetup): Unit = { backing.set(analysis, setup) last = Some((analysis, setup)) } @@ -27,4 +27,4 @@ object AnalysisStore { def set(analysis: Analysis, setup: CompileSetup): Unit = synchronized { backing.set(analysis, setup) } def get(): Option[(Analysis, CompileSetup)] = synchronized { backing.get() } } -} \ No newline at end of file +} diff --git a/compile/inc/src/main/scala/sbt/inc/ClassfileManager.scala b/compile/inc/src/main/scala/sbt/inc/ClassfileManager.scala index 20179b7bd..507e6ae95 100644 --- a/compile/inc/src/main/scala/sbt/inc/ClassfileManager.scala +++ b/compile/inc/src/main/scala/sbt/inc/ClassfileManager.scala @@ -27,8 +27,8 @@ object ClassfileManager { /** Constructs a minimal ClassfileManager implementation that immediately deletes class files when requested. */ val deleteImmediately: () => ClassfileManager = () => new ClassfileManager { def delete(classes: Iterable[File]): Unit = IO.deleteFilesEmptyDirs(classes) - def generated(classes: Iterable[File]) {} - def complete(success: Boolean) {} + def generated(classes: Iterable[File]): Unit = () + def complete(success: Boolean): Unit = () } @deprecated("Use overloaded variant that takes additional logger argument, instead.", "0.13.5") def transactional(tempDir0: File): () => ClassfileManager = @@ -44,7 +44,7 @@ object ClassfileManager { private[this] val movedClasses = new mutable.HashMap[File, File] private def showFiles(files: Iterable[File]): String = files.map(f => s"\t$f").mkString("\n") - def delete(classes: Iterable[File]) { + def delete(classes: Iterable[File]): Unit = { logger.debug(s"About to delete class files:\n${showFiles(classes)}") val toBeBackedUp = classes.filter(c => c.exists && !movedClasses.contains(c) && !generatedClasses(c)) logger.debug(s"We backup classs files:\n${showFiles(toBeBackedUp)}") @@ -57,7 +57,7 @@ object ClassfileManager { logger.debug(s"Registering generated classes:\n${showFiles(classes)}") generatedClasses ++= classes } - def complete(success: Boolean) { + def complete(success: Boolean): Unit = { if (!success) { logger.debug("Rolling back changes to class files.") logger.debug(s"Removing generated classes:\n${showFiles(generatedClasses)}") @@ -76,4 +76,4 @@ object ClassfileManager { target } } -} \ No newline at end of file +} diff --git a/compile/inc/src/main/scala/sbt/inc/Compile.scala b/compile/inc/src/main/scala/sbt/inc/Compile.scala index a7ccb3dd2..41338e7bd 100644 --- a/compile/inc/src/main/scala/sbt/inc/Compile.scala +++ b/compile/inc/src/main/scala/sbt/inc/Compile.scala @@ -184,7 +184,7 @@ private final class AnalysisCallback(internalMap: File => Option[File], external // empty value used when name hashing algorithm is disabled private val emptyNameHashes = new xsbti.api._internalOnly_NameHashes(Array.empty, Array.empty) - def api(sourceFile: File, source: SourceAPI) { + def api(sourceFile: File, source: SourceAPI): Unit = { import xsbt.api.{ APIUtil, HashAPI } if (APIUtil.isScalaSourceName(sourceFile.getName) && APIUtil.hasMacro(source)) macroSources += sourceFile publicNameHashes(sourceFile) = { diff --git a/compile/integration/src/main/scala/sbt/compiler/AggressiveCompile.scala b/compile/integration/src/main/scala/sbt/compiler/AggressiveCompile.scala index 92fb1a375..d7da7eb8a 100644 --- a/compile/integration/src/main/scala/sbt/compiler/AggressiveCompile.scala +++ b/compile/integration/src/main/scala/sbt/compiler/AggressiveCompile.scala @@ -170,7 +170,7 @@ class AggressiveCompile(cacheFile: File) { log.debug(label + " took " + (elapsed / 1e9) + " s") result } - private[this] def logInputs(log: Logger, javaCount: Int, scalaCount: Int, outputDirs: Seq[File]) { + private[this] def logInputs(log: Logger, javaCount: Int, scalaCount: Int, outputDirs: Seq[File]): Unit = { val scalaMsg = Analysis.counted("Scala source", "", "s", scalaCount) val javaMsg = Analysis.counted("Java source", "", "s", javaCount) val combined = scalaMsg ++ javaMsg diff --git a/compile/integration/src/main/scala/sbt/compiler/MixedAnalyzingCompiler.scala b/compile/integration/src/main/scala/sbt/compiler/MixedAnalyzingCompiler.scala index f3f4bf21d..4081ca473 100644 --- a/compile/integration/src/main/scala/sbt/compiler/MixedAnalyzingCompiler.scala +++ b/compile/integration/src/main/scala/sbt/compiler/MixedAnalyzingCompiler.scala @@ -77,7 +77,7 @@ final class MixedAnalyzingCompiler( result } - private[this] def logInputs(log: Logger, javaCount: Int, scalaCount: Int, outputDirs: Seq[File]) { + private[this] def logInputs(log: Logger, javaCount: Int, scalaCount: Int, outputDirs: Seq[File]): Unit = { val scalaMsg = Analysis.counted("Scala source", "", "s", scalaCount) val javaMsg = Analysis.counted("Java source", "", "s", javaCount) val combined = scalaMsg ++ javaMsg diff --git a/compile/interface/src/main/scala/xsbt/API.scala b/compile/interface/src/main/scala/xsbt/API.scala index 9bd6ae2d7..8af37f6b0 100644 --- a/compile/interface/src/main/scala/xsbt/API.scala +++ b/compile/interface/src/main/scala/xsbt/API.scala @@ -33,7 +33,7 @@ final class API(val global: CallbackGlobal) extends Compat { debug("API phase took : " + ((stop - start) / 1000.0) + " s") } def processUnit(unit: CompilationUnit) = if (!unit.isJava) processScalaUnit(unit) - def processScalaUnit(unit: CompilationUnit) { + def processScalaUnit(unit: CompilationUnit): Unit = { val sourceFile = unit.source.file.file debug("Traversing " + sourceFile) val extractApi = new ExtractAPI[global.type](global, sourceFile) @@ -59,7 +59,7 @@ final class API(val global: CallbackGlobal) extends Compat { definitions += extractApi.classLike(c.owner, c) } /** Record packages declared in the source file*/ - def `package`(p: Symbol) { + def `package`(p: Symbol): Unit = { if ((p eq null) || p == NoSymbol || p.isRoot || p.isRootPackage || p.isEmptyPackageClass || p.isEmptyPackage) () else { @@ -72,7 +72,7 @@ final class API(val global: CallbackGlobal) extends Compat { private abstract class TopLevelTraverser extends Traverser { def `class`(s: Symbol) def `package`(s: Symbol) - override def traverse(tree: Tree) { + override def traverse(tree: Tree): Unit = { tree match { case (_: ClassDef | _: ModuleDef) if isTopLevel(tree.symbol) => `class`(tree.symbol) case p: PackageDef => diff --git a/compile/interface/src/main/scala/xsbt/Analyzer.scala b/compile/interface/src/main/scala/xsbt/Analyzer.scala index 549cd882a..2bf01f630 100644 --- a/compile/interface/src/main/scala/xsbt/Analyzer.scala +++ b/compile/interface/src/main/scala/xsbt/Analyzer.scala @@ -28,7 +28,7 @@ final class Analyzer(val global: CallbackGlobal) extends LocateClassFile { // build list of generated classes for (iclass <- unit.icode) { val sym = iclass.symbol - def addGenerated(separatorRequired: Boolean) { + def addGenerated(separatorRequired: Boolean): Unit = { for (classFile <- outputDirs map (fileForClass(_, sym, separatorRequired)) find (_.exists)) callback.generatedClass(sourceFile, classFile, className(sym, '.', separatorRequired)) } @@ -43,4 +43,3 @@ final class Analyzer(val global: CallbackGlobal) extends LocateClassFile { } } } - diff --git a/compile/interface/src/main/scala/xsbt/CompilerInterface.scala b/compile/interface/src/main/scala/xsbt/CompilerInterface.scala index 10684e3f2..65271d222 100644 --- a/compile/interface/src/main/scala/xsbt/CompilerInterface.scala +++ b/compile/interface/src/main/scala/xsbt/CompilerInterface.scala @@ -29,7 +29,7 @@ final class CompilerInterface { sealed trait GlobalCompat { self: Global => def registerTopLevelSym(sym: Symbol): Unit sealed trait RunCompat { - def informUnitStarting(phase: Phase, unit: CompilationUnit) {} + def informUnitStarting(phase: Phase, unit: CompilationUnit): Unit = () } } sealed abstract class CallbackGlobal(settings: Settings, reporter: reporters.Reporter, output: Output) extends Global(settings, reporter) with GlobalCompat { @@ -43,7 +43,7 @@ sealed abstract class CallbackGlobal(settings: Settings, reporter: reporters.Rep } // Map source files to public inherited dependencies. These dependencies are tracked as the symbol for the dealiased base class. val inheritedDependencies = new mutable.HashMap[File, mutable.Set[Symbol]] - def addInheritedDependencies(file: File, deps: Iterable[Symbol]) { + def addInheritedDependencies(file: File, deps: Iterable[Symbol]): Unit = { inheritedDependencies.getOrElseUpdate(file, new mutable.HashSet) ++= deps } } @@ -52,13 +52,13 @@ class InterfaceCompileFailed(val arguments: Array[String], val problems: Array[P class InterfaceCompileCancelled(val arguments: Array[String], override val toString: String) extends xsbti.CompileCancelled private final class WeakLog(private[this] var log: Logger, private[this] var delegate: Reporter) { - def apply(message: String) { + def apply(message: String): Unit = { assert(log ne null, "Stale reference to logger") log.error(Message(message)) } def logger: Logger = log def reporter: Reporter = delegate - def clear() { + def clear(): Unit = { log = null delegate = null } @@ -95,7 +95,7 @@ private final class CachedCompiler0(args: Array[String], output: Output, initial try { run(sources.toList, changes, callback, log, dreporter, progress) } finally { dreporter.dropDelegate() } } - private[this] def run(sources: List[File], changes: DependencyChanges, callback: AnalysisCallback, log: Logger, dreporter: DelegatingReporter, compileProgress: CompileProgress) { + private[this] def run(sources: List[File], changes: DependencyChanges, callback: AnalysisCallback, log: Logger, dreporter: DelegatingReporter, compileProgress: CompileProgress): Unit = { if (command.shouldStopWithInfo) { dreporter.info(null, command.getInfoMessage(compiler), true) throw new InterfaceCompileFailed(args, Array(), "Compiler option supplied that disabled actual compilation.") @@ -104,10 +104,10 @@ private final class CachedCompiler0(args: Array[String], output: Output, initial debug(log, args.mkString("Calling Scala compiler with arguments (CompilerInterface):\n\t", "\n\t", "")) compiler.set(callback, dreporter) val run = new compiler.Run with compiler.RunCompat { - override def informUnitStarting(phase: Phase, unit: compiler.CompilationUnit) { + override def informUnitStarting(phase: Phase, unit: compiler.CompilationUnit): Unit = { compileProgress.startUnit(phase.name, unit.source.path) } - override def progress(current: Int, total: Int) { + override def progress(current: Int, total: Int): Unit = { if (!compileProgress.advance(current, total)) cancel } @@ -134,7 +134,7 @@ private final class CachedCompiler0(args: Array[String], output: Output, initial debug(log, "Compilation cancelled (CompilerInterface)") throw new InterfaceCompileCancelled(args, "Compilation has been cancelled") } - def processUnreportedWarnings(run: compiler.Run) { + def processUnreportedWarnings(run: compiler.Run): Unit = { // allConditionalWarnings and the ConditionalWarning class are only in 2.10+ final class CondWarnCompat(val what: String, val warnings: mutable.ListBuffer[(compiler.Position, String)]) implicit def compat(run: AnyRef): Compat = new Compat @@ -225,11 +225,11 @@ private final class CachedCompiler0(args: Array[String], output: Output, initial for ((what, warnings) <- seq; (pos, msg) <- warnings) yield callback.problem(what, drep.convert(pos), msg, Severity.Warn, false) } - def set(callback: AnalysisCallback, dreporter: DelegatingReporter) { + def set(callback: AnalysisCallback, dreporter: DelegatingReporter): Unit = { this.callback0 = callback reporter = dreporter } - def clear() { + def clear(): Unit = { callback0 = null superDropRun() reporter = null diff --git a/compile/interface/src/main/scala/xsbt/ConsoleInterface.scala b/compile/interface/src/main/scala/xsbt/ConsoleInterface.scala index 3819f746d..f3cf22a7f 100644 --- a/compile/interface/src/main/scala/xsbt/ConsoleInterface.scala +++ b/compile/interface/src/main/scala/xsbt/ConsoleInterface.scala @@ -13,7 +13,7 @@ class ConsoleInterface { def commandArguments(args: Array[String], bootClasspathString: String, classpathString: String, log: Logger): Array[String] = MakeSettings.sync(args, bootClasspathString, classpathString, log).recreateArgs.toArray[String] - def run(args: Array[String], bootClasspathString: String, classpathString: String, initialCommands: String, cleanupCommands: String, loader: ClassLoader, bindNames: Array[String], bindValues: Array[Any], log: Logger) { + def run(args: Array[String], bootClasspathString: String, classpathString: String, initialCommands: String, cleanupCommands: String, loader: ClassLoader, bindNames: Array[String], bindValues: Array[Any], log: Logger): Unit = { lazy val interpreterSettings = MakeSettings.sync(args.toList, log) val compilerSettings = MakeSettings.sync(args, bootClasspathString, classpathString, log) @@ -36,7 +36,7 @@ class ConsoleInterface { } else super.createInterpreter() - def bind(values: Seq[(String, Any)]) { + def bind(values: Seq[(String, Any)]): Unit = { // for 2.8 compatibility final class Compat { def bindValue(id: String, value: Any) = @@ -53,7 +53,7 @@ class ConsoleInterface { if (!initialCommands.isEmpty) interpreter.interpret(initialCommands) } - override def closeInterpreter() { + override def closeInterpreter(): Unit = { if (!cleanupCommands.isEmpty) interpreter.interpret(cleanupCommands) super.closeInterpreter() diff --git a/compile/interface/src/main/scala/xsbt/DelegatingReporter.scala b/compile/interface/src/main/scala/xsbt/DelegatingReporter.scala index b0513c8a5..b1c7a4f4f 100644 --- a/compile/interface/src/main/scala/xsbt/DelegatingReporter.scala +++ b/compile/interface/src/main/scala/xsbt/DelegatingReporter.scala @@ -17,22 +17,21 @@ private object DelegatingReporter { private final class DelegatingReporter(warnFatal: Boolean, noWarn: Boolean, private[this] var delegate: xsbti.Reporter) extends scala.tools.nsc.reporters.Reporter { import scala.tools.nsc.util.{ FakePos, NoPosition, Position } - def dropDelegate() { delegate = null } - def error(msg: String) { error(FakePos("scalac"), msg) } + def dropDelegate(): Unit = { delegate = null } + def error(msg: String): Unit = error(FakePos("scalac"), msg) - def printSummary() = delegate.printSummary() + def printSummary(): Unit = delegate.printSummary() override def hasErrors = delegate.hasErrors override def hasWarnings = delegate.hasWarnings def problems = delegate.problems - override def comment(pos: Position, msg: String) = delegate.comment(convert(pos), msg) + override def comment(pos: Position, msg: String): Unit = delegate.comment(convert(pos), msg) - override def reset = - { - super.reset - delegate.reset - } - protected def info0(pos: Position, msg: String, rawSeverity: Severity, force: Boolean) { + override def reset(): Unit = { + super.reset + delegate.reset() + } + protected def info0(pos: Position, msg: String, rawSeverity: Severity, force: Boolean): Unit = { val skip = rawSeverity == WARNING && noWarn if (!skip) { val severity = if (warnFatal && rawSeverity == WARNING) ERROR else rawSeverity diff --git a/compile/interface/src/main/scala/xsbt/Dependency.scala b/compile/interface/src/main/scala/xsbt/Dependency.scala index 9db1c97e5..a72f615a6 100644 --- a/compile/interface/src/main/scala/xsbt/Dependency.scala +++ b/compile/interface/src/main/scala/xsbt/Dependency.scala @@ -57,7 +57,7 @@ final class Dependency(val global: CallbackGlobal) extends LocateClassFile { * that is coming from either source code (not necessarily compiled in this compilation * run) or from class file and calls respective callback method. */ - def processDependency(on: Symbol, context: DependencyContext) { + def processDependency(on: Symbol, context: DependencyContext): Unit = { def binaryDependency(file: File, className: String) = callback.binaryDependency(file, className, sourceFile, context) val onSource = on.sourceFile if (onSource == null) { @@ -166,7 +166,7 @@ final class Dependency(val global: CallbackGlobal) extends LocateClassFile { } /** Copied straight from Scala 2.10 as it does not exist in Scala 2.9 compiler */ - private final def debuglog(msg: => String) { + private final def debuglog(msg: => String): Unit = { if (settings.debug.value) log(msg) } @@ -199,4 +199,4 @@ final class Dependency(val global: CallbackGlobal) extends LocateClassFile { // for Scala 2.8 and 2.9 this method is provided through SymbolCompat sym.enclosingTopLevelClass -} \ No newline at end of file +} diff --git a/compile/interface/src/main/scala/xsbt/ScaladocInterface.scala b/compile/interface/src/main/scala/xsbt/ScaladocInterface.scala index 9c54631fa..093fef986 100644 --- a/compile/interface/src/main/scala/xsbt/ScaladocInterface.scala +++ b/compile/interface/src/main/scala/xsbt/ScaladocInterface.scala @@ -18,7 +18,7 @@ private class Runner(args: Array[String], log: Logger, delegate: xsbti.Reporter) def noErrors = !reporter.hasErrors && command.ok import forScope._ - def run() { + def run(): Unit = { debug(log, "Calling Scaladoc with arguments:\n\t" + args.mkString("\n\t")) if (noErrors) { import doc._ // 2.8 trunk and Beta1-RC4 have doc.DocFactory. For other Scala versions, the next line creates forScope.DocFactory @@ -48,7 +48,7 @@ private class Runner(args: Array[String], log: Logger, delegate: xsbti.Reporter) def process(units: Iterator[CompilationUnit]) = error("for 2.8 compatibility only") } } - def document(ignore: Seq[String]) { + def document(ignore: Seq[String]): Unit = { import compiler._ val run = new Run run compile command.files @@ -65,4 +65,4 @@ private class Runner(args: Array[String], log: Logger, delegate: xsbti.Reporter) } } } -} \ No newline at end of file +} diff --git a/compile/ivy/src/main/scala/sbt/compiler/ComponentCompiler.scala b/compile/ivy/src/main/scala/sbt/compiler/ComponentCompiler.scala index 3192e42c6..f203c58ca 100644 --- a/compile/ivy/src/main/scala/sbt/compiler/ComponentCompiler.scala +++ b/compile/ivy/src/main/scala/sbt/compiler/ComponentCompiler.scala @@ -68,7 +68,7 @@ class ComponentCompiler(compiler: RawCompiler, manager: ComponentManager) { val base = id + binSeparator + compiler.scalaInstance.actualVersion if (withJavaVersion) base + "__" + javaVersion else base } - protected def compileAndInstall(id: String, binID: String) { + protected def compileAndInstall(id: String, binID: String): Unit = { val srcID = id + srcExtension IO.withTemporaryDirectory { binaryDirectory => val targetJar = new File(binaryDirectory, id + ".jar") diff --git a/compile/persist/src/main/scala/sbt/inc/AnalysisFormats.scala b/compile/persist/src/main/scala/sbt/inc/AnalysisFormats.scala index 2048b0637..a037d630f 100644 --- a/compile/persist/src/main/scala/sbt/inc/AnalysisFormats.scala +++ b/compile/persist/src/main/scala/sbt/inc/AnalysisFormats.scala @@ -37,7 +37,7 @@ object AnalysisFormats { time(label + ".read.end") r } - def writes(out: Output, t: T) { + def writes(out: Output, t: T): Unit = { time(label + ".write.start") f.writes(out, t) time(label + ".write.end") diff --git a/compile/persist/src/main/scala/sbt/inc/FileBasedStore.scala b/compile/persist/src/main/scala/sbt/inc/FileBasedStore.scala index 2f12b327b..01ceb92e1 100644 --- a/compile/persist/src/main/scala/sbt/inc/FileBasedStore.scala +++ b/compile/persist/src/main/scala/sbt/inc/FileBasedStore.scala @@ -8,7 +8,7 @@ import java.io.File object FileBasedStore { def apply(file: File): AnalysisStore = new AnalysisStore { - def set(analysis: Analysis, setup: CompileSetup) { + def set(analysis: Analysis, setup: CompileSetup): Unit = { Using.fileWriter(IO.utf8)(file) { writer => TextAnalysisFormat.write(writer, analysis, setup) } } @@ -17,4 +17,4 @@ object FileBasedStore { def getUncaught(): (Analysis, CompileSetup) = Using.fileReader(IO.utf8)(file) { reader => TextAnalysisFormat.read(reader) } } -} \ No newline at end of file +} diff --git a/compile/persist/src/main/scala/sbt/inc/TextAnalysisFormat.scala b/compile/persist/src/main/scala/sbt/inc/TextAnalysisFormat.scala index 57da4fabc..74221a9c6 100644 --- a/compile/persist/src/main/scala/sbt/inc/TextAnalysisFormat.scala +++ b/compile/persist/src/main/scala/sbt/inc/TextAnalysisFormat.scala @@ -27,7 +27,7 @@ private[inc] object FormatTimer { ret } - def close(key: String) { + def close(key: String): Unit = { if (printTimings) { println("[%s] %dms".format(key, timers.getOrElse(key, 0L) / 1000000)) } @@ -52,7 +52,7 @@ object TextAnalysisFormat { import AnalysisFormats._ implicit val compilationF = xsbt.api.CompilationFormat - def write(out: Writer, analysis: Analysis, setup: CompileSetup) { + def write(out: Writer, analysis: Analysis, setup: CompileSetup): Unit = { VersionF.write(out) // We start with writing compile setup which contains value of the `nameHashing` // flag that is needed to properly deserialize relations @@ -82,12 +82,12 @@ object TextAnalysisFormat { private[this] object VersionF { val currentVersion = "5" - def write(out: Writer) { + def write(out: Writer): Unit = { out.write("format version: %s\n".format(currentVersion)) } private val versionPattern = """format version: (\w+)""".r - def read(in: BufferedReader) { + def read(in: BufferedReader): Unit = { in.readLine() match { case versionPattern(version) => validateVersion(version) case s: String => throw new ReadException("\"format version: \"", s) @@ -95,7 +95,7 @@ object TextAnalysisFormat { } } - def validateVersion(version: String) { + def validateVersion(version: String): Unit = { // TODO: Support backwards compatibility? if (version != currentVersion) { throw new ReadException("File uses format version %s, but we are compatible with version %s only.".format(version, currentVersion)) @@ -121,14 +121,14 @@ object TextAnalysisFormat { val usedNames = "used names" } - def write(out: Writer, relations: Relations) { + def write(out: Writer, relations: Relations): Unit = { // This ordering is used to persist all values in order. Since all values will be // persisted using their string representation, it makes sense to sort them using // their string representation. val toStringOrd = new Ordering[Any] { def compare(a: Any, b: Any) = a.toString compare b.toString } - def writeRelation[T](header: String, rel: Relation[File, T]) { + def writeRelation[T](header: String, rel: Relation[File, T]): Unit = { writeHeader(out, header) writeSize(out, rel.size) // We sort for ease of debugging and for more efficient reconstruction when reading. @@ -156,7 +156,7 @@ object TextAnalysisFormat { var currentItem: (File, T) = null var currentFile: File = null var currentVals: List[T] = Nil - def closeEntry() { + def closeEntry(): Unit = { if (currentFile != null) forward = (currentFile, currentVals.toSet) :: forward currentFile = currentItem._1 currentVals = currentItem._2 :: Nil @@ -183,7 +183,7 @@ object TextAnalysisFormat { val classNames = "class names" } - def write(out: Writer, stamps: Stamps) { + def write(out: Writer, stamps: Stamps): Unit = { def doWriteMap[V](header: String, m: Map[File, V]) = writeMap(out)(header, m, { v: V => v.toString }) doWriteMap(Headers.products, stamps.products) @@ -212,7 +212,7 @@ object TextAnalysisFormat { val stringToSource = ObjectStringifier.stringToObj[Source] _ val sourceToString = ObjectStringifier.objToString[Source] _ - def write(out: Writer, apis: APIs) { + def write(out: Writer, apis: APIs): Unit = { writeMap(out)(Headers.internal, apis.internal, sourceToString, inlineVals = false) writeMap(out)(Headers.external, apis.external, sourceToString, inlineVals = false) FormatTimer.close("bytes -> base64") @@ -237,7 +237,7 @@ object TextAnalysisFormat { val stringToSourceInfo = ObjectStringifier.stringToObj[SourceInfo] _ val sourceInfoToString = ObjectStringifier.objToString[SourceInfo] _ - def write(out: Writer, infos: SourceInfos) { writeMap(out)(Headers.infos, infos.allInfos, sourceInfoToString, inlineVals = false) } + def write(out: Writer, infos: SourceInfos): Unit = writeMap(out)(Headers.infos, infos.allInfos, sourceInfoToString, inlineVals = false) def read(in: BufferedReader): SourceInfos = SourceInfos.make(readMap(in)(Headers.infos, new File(_), stringToSourceInfo)) } @@ -249,9 +249,8 @@ object TextAnalysisFormat { val stringToCompilation = ObjectStringifier.stringToObj[Compilation] _ val compilationToString = ObjectStringifier.objToString[Compilation] _ - def write(out: Writer, compilations: Compilations) { + def write(out: Writer, compilations: Compilations): Unit = writeSeq(out)(Headers.compilations, compilations.allCompilations, compilationToString) - } def read(in: BufferedReader): Compilations = Compilations.make( readSeq[Compilation](in)(Headers.compilations, stringToCompilation)) @@ -272,7 +271,7 @@ object TextAnalysisFormat { private[this] val multipleOutputMode = "multiple" private[this] val singleOutputKey = new File("output dir") - def write(out: Writer, setup: CompileSetup) { + def write(out: Writer, setup: CompileSetup): Unit = { val (mode, outputAsMap) = setup.output match { case s: SingleOutput => (singleOutputMode, Map(singleOutputKey -> s.outputDirectory)) case m: MultipleOutput => (multipleOutputMode, m.outputGroups.map(x => x.sourceDirectory -> x.outputDirectory).toMap) @@ -341,18 +340,14 @@ object TextAnalysisFormat { // Various helper functions. - private[this] def writeHeader(out: Writer, header: String) { - out.write(header + ":\n") - } + private[this] def writeHeader(out: Writer, header: String): Unit = out.write(header + ":\n") - private[this] def expectHeader(in: BufferedReader, expectedHeader: String) { + private[this] def expectHeader(in: BufferedReader, expectedHeader: String): Unit = { val header = in.readLine() if (header != expectedHeader + ":") throw new ReadException(expectedHeader, if (header == null) "EOF" else header) } - private[this] def writeSize(out: Writer, n: Int) { - out.write("%d items\n".format(n)) - } + private[this] def writeSize(out: Writer, n: Int): Unit = out.write("%d items\n".format(n)) private val itemsPattern = """(\d+) items""".r private[this] def readSize(in: BufferedReader): Int = { @@ -363,7 +358,7 @@ object TextAnalysisFormat { } } - private[this] def writeSeq[T](out: Writer)(header: String, s: Seq[T], t2s: T => String) { + private[this] def writeSeq[T](out: Writer)(header: String, s: Seq[T], t2s: T => String): Unit = { // We write sequences as idx -> element maps, for uniformity with maps/relations. def n = s.length val numDigits = if (n < 2) 1 else math.log10(n - 1).toInt + 1 @@ -376,7 +371,7 @@ object TextAnalysisFormat { private[this] def readSeq[T](in: BufferedReader)(expectedHeader: String, s2t: String => T): Seq[T] = (readPairs(in)(expectedHeader, identity[String], s2t).toSeq.sortBy(_._1) map (_._2)) - private[this] def writeMap[K, V](out: Writer)(header: String, m: Map[K, V], v2s: V => String, inlineVals: Boolean = true)(implicit ord: Ordering[K]) { + private[this] def writeMap[K, V](out: Writer)(header: String, m: Map[K, V], v2s: V => String, inlineVals: Boolean = true)(implicit ord: Ordering[K]): Unit = { writeHeader(out, header) writeSize(out, m.size) m.keys.toSeq.sorted foreach { k => diff --git a/compile/persist/src/main/scala/xsbt/api/CompilationFormat.scala b/compile/persist/src/main/scala/xsbt/api/CompilationFormat.scala index 6a1a164dd..9ad58cc02 100644 --- a/compile/persist/src/main/scala/xsbt/api/CompilationFormat.scala +++ b/compile/persist/src/main/scala/xsbt/api/CompilationFormat.scala @@ -9,7 +9,7 @@ object CompilationFormat extends Format[Compilation] { val oin = new ObjectInputStream(new InputWrapperStream(in)) try { oin.readObject.asInstanceOf[Compilation] } finally { oin.close() } } - def writes(out: Output, src: Compilation) { + def writes(out: Output, src: Compilation): Unit = { val oout = new ObjectOutputStream(new OutputWrapperStream(out)) try { oout.writeObject(src) } finally { oout.close() } } diff --git a/compile/persist/src/main/scala/xsbt/api/SourceFormat.scala b/compile/persist/src/main/scala/xsbt/api/SourceFormat.scala index 34a4489e7..6b6e29aaa 100644 --- a/compile/persist/src/main/scala/xsbt/api/SourceFormat.scala +++ b/compile/persist/src/main/scala/xsbt/api/SourceFormat.scala @@ -19,7 +19,7 @@ object SourceFormat extends Format[Source] { val oin = new ObjectInputStream(new InputWrapperStream(in)) try { oin.readObject.asInstanceOf[Source] } finally { oin.close() } } - def writes(out: Output, src: Source) { + def writes(out: Output, src: Source): Unit = { val oout = new ObjectOutputStream(new OutputWrapperStream(out)) try { oout.writeObject(src) } finally { oout.close() } } diff --git a/compile/src/main/scala/sbt/LoggerReporter.scala b/compile/src/main/scala/sbt/LoggerReporter.scala index 8922d195f..609cdf2a0 100644 --- a/compile/src/main/scala/sbt/LoggerReporter.scala +++ b/compile/src/main/scala/sbt/LoggerReporter.scala @@ -50,7 +50,7 @@ class LoggerReporter(maximumErrors: Int, log: Logger, sourcePositionMapper: Posi reset() - def reset() { + def reset(): Unit = { count.put(Warn, 0) count.put(SInfo, 0) count.put(Error, 0) @@ -60,9 +60,9 @@ class LoggerReporter(maximumErrors: Int, log: Logger, sourcePositionMapper: Posi def hasWarnings = count.get(Warn) > 0 def hasErrors = count.get(Error) > 0 def problems: Array[Problem] = allProblems.toArray - def comment(pos: Position, msg: String) {} + def comment(pos: Position, msg: String): Unit = () - def printSummary() { + def printSummary(): Unit = { val warnings = count.get(Severity.Warn) if (warnings > 0) log.warn(countElementsAsString(warnings, "warning") + " found") @@ -73,7 +73,7 @@ class LoggerReporter(maximumErrors: Int, log: Logger, sourcePositionMapper: Posi def inc(sev: Severity) = count.put(sev, count.get(sev) + 1) - def display(pos: Position, msg: String, severity: Severity) { + def display(pos: Position, msg: String, severity: Severity): Unit = { inc(severity) if (severity != Error || maximumErrors <= 0 || count.get(severity) <= maximumErrors) print(severityLogger(severity), pos, msg) @@ -88,7 +88,7 @@ class LoggerReporter(maximumErrors: Int, log: Logger, sourcePositionMapper: Posi }) } - def print(log: (=> String) => Unit, pos: Position, msg: String) { + def print(log: (=> String) => Unit, pos: Position, msg: String): Unit = { if (pos.sourcePath.isEmpty && pos.line.isEmpty) log(msg) else { @@ -132,4 +132,4 @@ class LoggerReporter(maximumErrors: Int, log: Logger, sourcePositionMapper: Posi } } } -} \ No newline at end of file +} diff --git a/compile/src/main/scala/sbt/compiler/CompilerArguments.scala b/compile/src/main/scala/sbt/compiler/CompilerArguments.scala index a4fec2857..e383fdb56 100644 --- a/compile/src/main/scala/sbt/compiler/CompilerArguments.scala +++ b/compile/src/main/scala/sbt/compiler/CompilerArguments.scala @@ -32,7 +32,7 @@ final class CompilerArguments(scalaInstance: xsbti.compile.ScalaInstance, cp: xs filterLibrary(classpath) ++ include(cp.compiler, scalaInstance.compilerJar) ++ include(cp.extra, scalaInstance.otherJars: _*) private[this] def include(flag: Boolean, jars: File*) = if (flag) jars else Nil private[this] def abs(files: Seq[File]) = files.map(_.getAbsolutePath).sortWith(_ < _) - private[this] def checkScalaHomeUnset() { + private[this] def checkScalaHomeUnset(): Unit = { val scalaHome = System.getProperty("scala.home") assert((scalaHome eq null) || scalaHome.isEmpty, "'scala.home' should not be set (was " + scalaHome + ")") } diff --git a/compile/src/main/scala/sbt/compiler/CompilerCache.scala b/compile/src/main/scala/sbt/compiler/CompilerCache.scala index 25391460a..59e2aae80 100644 --- a/compile/src/main/scala/sbt/compiler/CompilerCache.scala +++ b/compile/src/main/scala/sbt/compiler/CompilerCache.scala @@ -42,7 +42,7 @@ object CompilerCache { def apply(maxInstances: Int): GlobalsCache = new CompilerCache(maxInstances) val fresh: GlobalsCache = new GlobalsCache { - def clear() {} + def clear(): Unit = () def apply(args: Array[String], output: Output, forceNew: Boolean, c: CachedCompilerProvider, log: xLogger, reporter: Reporter): CachedCompiler = c.newCachedCompiler(args, output, log, reporter, /*resident = */ false) } diff --git a/compile/src/main/scala/sbt/compiler/JavaCompiler.scala b/compile/src/main/scala/sbt/compiler/JavaCompiler.scala index 079f23240..1f031848a 100644 --- a/compile/src/main/scala/sbt/compiler/JavaCompiler.scala +++ b/compile/src/main/scala/sbt/compiler/JavaCompiler.scala @@ -89,7 +89,7 @@ object JavaCompiler { val javaCp = ClasspathOptions.javac(cp.compiler) (new CompilerArguments(scalaInstance, javaCp))(sources, augmentedClasspath, Some(outputDirectory), options) } - def compile(contract: JavacContract, sources: Seq[File], classpath: Seq[File], outputDirectory: File, options: Seq[String])(implicit log: Logger) { + def compile(contract: JavacContract, sources: Seq[File], classpath: Seq[File], outputDirectory: File, options: Seq[String])(implicit log: Logger): Unit = { val arguments = commandArguments(sources, classpath, outputDirectory, options, log) onArgsF(arguments) val code: Int = f(contract, arguments, log) diff --git a/compile/src/main/scala/sbt/compiler/RawCompiler.scala b/compile/src/main/scala/sbt/compiler/RawCompiler.scala index 558d318cf..74f89a7e1 100644 --- a/compile/src/main/scala/sbt/compiler/RawCompiler.scala +++ b/compile/src/main/scala/sbt/compiler/RawCompiler.scala @@ -13,7 +13,7 @@ import java.io.File * the scala-library.jar from `scalaInstance` is put on bootclasspath and the scala-compiler jar goes on the classpath. */ class RawCompiler(val scalaInstance: xsbti.compile.ScalaInstance, cp: ClasspathOptions, log: Logger) { - def apply(sources: Seq[File], classpath: Seq[File], outputDirectory: File, options: Seq[String]) { + def apply(sources: Seq[File], classpath: Seq[File], outputDirectory: File, options: Seq[String]): Unit = { // reflection is required for binary compatibility // The following import ensures there is a compile error if the identifiers change, // but should not be otherwise directly referenced @@ -27,7 +27,7 @@ class RawCompiler(val scalaInstance: xsbti.compile.ScalaInstance, cp: ClasspathO checkForFailure(mainClass, arguments.toArray) } def compilerArguments = new CompilerArguments(scalaInstance, cp) - protected def checkForFailure(mainClass: Class[_], args: Array[String]) { + protected def checkForFailure(mainClass: Class[_], args: Array[String]): Unit = { val reporter = mainClass.getMethod("reporter").invoke(null) val failed = reporter.getClass.getMethod("hasErrors").invoke(reporter).asInstanceOf[Boolean] if (failed) throw new CompileFailed(args, "Plain compile failed", Array()) diff --git a/compile/src/main/scala/sbt/compiler/javac/DiagnosticsReporter.scala b/compile/src/main/scala/sbt/compiler/javac/DiagnosticsReporter.scala index aec47137e..49c3fb54a 100644 --- a/compile/src/main/scala/sbt/compiler/javac/DiagnosticsReporter.scala +++ b/compile/src/main/scala/sbt/compiler/javac/DiagnosticsReporter.scala @@ -46,7 +46,7 @@ final class DiagnosticsReporter(reporter: Reporter) extends DiagnosticListener[J Option(source).map(_.toUri.toString) } } - override def report(d: Diagnostic[_ <: JavaFileObject]) { + override def report(d: Diagnostic[_ <: JavaFileObject]): Unit = { val severity = d.getKind match { case Diagnostic.Kind.ERROR => Severity.Error diff --git a/compile/src/main/scala/sbt/compiler/javac/ProcessLoggerWriter.scala b/compile/src/main/scala/sbt/compiler/javac/ProcessLoggerWriter.scala index a399f755a..645ec96ff 100644 --- a/compile/src/main/scala/sbt/compiler/javac/ProcessLoggerWriter.scala +++ b/compile/src/main/scala/sbt/compiler/javac/ProcessLoggerWriter.scala @@ -19,7 +19,7 @@ private class ProcessLoggerWriter(delegate: ProcessLogger, level: Level.Value, n process() } - private[this] def process() { + private[this] def process(): Unit = { val i = buffer.indexOf(nl) if (i >= 0) { log(buffer.substring(0, i)) diff --git a/interface/src/test/scala/xsbti/TestCallback.scala b/interface/src/test/scala/xsbti/TestCallback.scala index 13b65df79..f0658597b 100644 --- a/interface/src/test/scala/xsbti/TestCallback.scala +++ b/interface/src/test/scala/xsbti/TestCallback.scala @@ -13,22 +13,22 @@ class TestCallback(override val nameHashing: Boolean = false) extends AnalysisCa val usedNames = scala.collection.mutable.Map.empty[File, Set[String]].withDefaultValue(Set.empty) val apis: scala.collection.mutable.Map[File, SourceAPI] = scala.collection.mutable.Map.empty - def sourceDependency(dependsOn: File, source: File, inherited: Boolean) { + def sourceDependency(dependsOn: File, source: File, inherited: Boolean): Unit = { val context = if(inherited) DependencyByInheritance else DependencyByMemberRef sourceDependency(dependsOn, source, context) } - def sourceDependency(dependsOn: File, source: File, context: DependencyContext) { sourceDependencies += ((dependsOn, source, context)) } - def binaryDependency(binary: File, name: String, source: File, inherited: Boolean) { + def sourceDependency(dependsOn: File, source: File, context: DependencyContext): Unit = { sourceDependencies += ((dependsOn, source, context)) } + def binaryDependency(binary: File, name: String, source: File, inherited: Boolean): Unit = { val context = if(inherited) DependencyByInheritance else DependencyByMemberRef binaryDependency(binary, name, source, context) } - def binaryDependency(binary: File, name: String, source: File, context: DependencyContext) { binaryDependencies += ((binary, name, source, context)) } - def generatedClass(source: File, module: File, name: String) { products += ((source, module, name)) } + def binaryDependency(binary: File, name: String, source: File, context: DependencyContext): Unit = { binaryDependencies += ((binary, name, source, context)) } + def generatedClass(source: File, module: File, name: String): Unit = { products += ((source, module, name)) } - def usedName(source: File, name: String) { usedNames(source) += name } + def usedName(source: File, name: String): Unit = { usedNames(source) += name } def api(source: File, sourceAPI: SourceAPI): Unit = { assert(!apis.contains(source), s"The `api` method should be called once per source file: $source") apis(source) = sourceAPI } - def problem(category: String, pos: xsbti.Position, message: String, severity: xsbti.Severity, reported: Boolean) {} + def problem(category: String, pos: xsbti.Position, message: String, severity: xsbti.Severity, reported: Boolean): Unit = () } diff --git a/ivy/src/main/scala/org/apache/ivy/plugins/parser/m2/ReplaceMavenConfigurationMappings.scala b/ivy/src/main/scala/org/apache/ivy/plugins/parser/m2/ReplaceMavenConfigurationMappings.scala index 0e85d5b6b..e59bd174e 100644 --- a/ivy/src/main/scala/org/apache/ivy/plugins/parser/m2/ReplaceMavenConfigurationMappings.scala +++ b/ivy/src/main/scala/org/apache/ivy/plugins/parser/m2/ReplaceMavenConfigurationMappings.scala @@ -38,7 +38,7 @@ object ReplaceMavenConfigurationMappings { // NOTE - This code is copied from org.apache.ivy.plugins.parser.m2.PomModuleDescriptorBuilder // except with altered default configurations... REPLACEMENT_MAPPINGS.put("compile", new PomModuleDescriptorBuilder.ConfMapper { - def addMappingConfs(dd: DefaultDependencyDescriptor, isOptional: Boolean) { + def addMappingConfs(dd: DefaultDependencyDescriptor, isOptional: Boolean): Unit = { if (isOptional) { dd.addDependencyConfiguration("optional", "compile(*)") // FIX - Here we take a mroe conservative approach of depending on the compile configuration if master isn't there. @@ -52,7 +52,7 @@ object ReplaceMavenConfigurationMappings { } }) REPLACEMENT_MAPPINGS.put("provided", new PomModuleDescriptorBuilder.ConfMapper { - def addMappingConfs(dd: DefaultDependencyDescriptor, isOptional: Boolean) { + def addMappingConfs(dd: DefaultDependencyDescriptor, isOptional: Boolean): Unit = { if (isOptional) { dd.addDependencyConfiguration("optional", "compile(*)") dd.addDependencyConfiguration("optional", "provided(*)") @@ -70,7 +70,7 @@ object ReplaceMavenConfigurationMappings { }) REPLACEMENT_MAPPINGS.put("runtime", new PomModuleDescriptorBuilder.ConfMapper { - def addMappingConfs(dd: DefaultDependencyDescriptor, isOptional: Boolean) { + def addMappingConfs(dd: DefaultDependencyDescriptor, isOptional: Boolean): Unit = { if (isOptional) { dd.addDependencyConfiguration("optional", "compile(*)") dd.addDependencyConfiguration("optional", "provided(*)") @@ -86,7 +86,7 @@ object ReplaceMavenConfigurationMappings { }) REPLACEMENT_MAPPINGS.put("test", new PomModuleDescriptorBuilder.ConfMapper { - def addMappingConfs(dd: DefaultDependencyDescriptor, isOptional: Boolean) { + def addMappingConfs(dd: DefaultDependencyDescriptor, isOptional: Boolean): Unit = { dd.addDependencyConfiguration("test", "runtime(*)") // FIX - Here we take a mroe conservative approach of depending on the compile configuration if master isn't there. dd.addDependencyConfiguration("test", "master(compile)") @@ -94,7 +94,7 @@ object ReplaceMavenConfigurationMappings { }) REPLACEMENT_MAPPINGS.put("system", new PomModuleDescriptorBuilder.ConfMapper { - def addMappingConfs(dd: DefaultDependencyDescriptor, isOptional: Boolean) { + def addMappingConfs(dd: DefaultDependencyDescriptor, isOptional: Boolean): Unit = { // FIX - Here we take a mroe conservative approach of depending on the compile configuration if master isn't there. dd.addDependencyConfiguration("system", "master(compile)") } @@ -115,4 +115,4 @@ object ReplaceMavenConfigurationMappings { throw new RuntimeException("FAILURE to install Ivy maven hooks. Your ivy-maven interaction may suffer resolution errors", e) } } -} \ 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 082a478b6..a4e011736 100644 --- a/ivy/src/main/scala/sbt/ConflictWarning.scala +++ b/ivy/src/main/scala/sbt/ConflictWarning.scala @@ -28,10 +28,10 @@ object ConflictWarning { @deprecated("Warning on evicted modules is no longer done, so this is the same as `default`. Use a standard Ivy conflict manager.", "0.13.0") def strict(label: String): ConflictWarning = ConflictWarning(label, Level.Error, true) - def apply(config: ConflictWarning, report: UpdateReport, log: Logger) { + def apply(config: ConflictWarning, report: UpdateReport, log: Logger): Unit = { processCrossVersioned(config, report, log) } - private[this] def processCrossVersioned(config: ConflictWarning, report: UpdateReport, log: Logger) { + private[this] def processCrossVersioned(config: ConflictWarning, report: UpdateReport, log: Logger): Unit = { val crossMismatches = crossVersionMismatches(report) if (crossMismatches.nonEmpty) { val pre = s"Modules were resolved with conflicting cross-version suffixes in ${config.label}:\n " diff --git a/ivy/src/main/scala/sbt/ConvertResolver.scala b/ivy/src/main/scala/sbt/ConvertResolver.scala index a01a51380..9768241d5 100644 --- a/ivy/src/main/scala/sbt/ConvertResolver.scala +++ b/ivy/src/main/scala/sbt/ConvertResolver.scala @@ -113,7 +113,7 @@ private[sbt] object ConvertResolver { { val pattern = Collections.singletonList(Resolver.resolvePattern(repo.root, Resolver.mavenStyleBasePattern)) final class PluginCapableResolver extends IBiblioResolver with ChecksumFriendlyURLResolver with DescriptorRequired { - def setPatterns() { + def setPatterns(): Unit = { // done this way for access to protected methods. setArtifactPatterns(pattern) setIvyPatterns(pattern) @@ -189,18 +189,18 @@ private[sbt] object ConvertResolver { def hasExplicitURL(dd: DependencyDescriptor): Boolean = dd.getAllDependencyArtifacts.exists(_.getUrl != null) } - private def initializeMavenStyle(resolver: IBiblioResolver, name: String, root: String) { + private def initializeMavenStyle(resolver: IBiblioResolver, name: String, root: String): Unit = { resolver.setName(name) resolver.setM2compatible(true) resolver.setRoot(root) } - private def initializeSSHResolver(resolver: AbstractSshBasedResolver, repo: SshBasedRepository, settings: IvySettings) { + private def initializeSSHResolver(resolver: AbstractSshBasedResolver, repo: SshBasedRepository, settings: IvySettings): Unit = { resolver.setName(repo.name) resolver.setPassfile(null) initializePatterns(resolver, repo.patterns, settings) initializeConnection(resolver, repo.connection) } - private def initializeConnection(resolver: AbstractSshBasedResolver, connection: RepositoryHelpers.SshConnection) { + private def initializeConnection(resolver: AbstractSshBasedResolver, connection: RepositoryHelpers.SshConnection): Unit = { import resolver._ import connection._ hostname.foreach(setHost) @@ -216,7 +216,7 @@ private[sbt] object ConvertResolver { setUser(user) } } - private def initializePatterns(resolver: AbstractPatternsBasedResolver, patterns: Patterns, settings: IvySettings) { + private def initializePatterns(resolver: AbstractPatternsBasedResolver, patterns: Patterns, settings: IvySettings): Unit = { resolver.setM2compatible(patterns.isMavenCompatible) resolver.setDescriptor(if (patterns.descriptorOptional) BasicResolver.DESCRIPTOR_OPTIONAL else BasicResolver.DESCRIPTOR_REQUIRED) resolver.setCheckconsistency(!patterns.skipConsistencyCheck) diff --git a/ivy/src/main/scala/sbt/CustomXmlParser.scala b/ivy/src/main/scala/sbt/CustomXmlParser.scala index c5462070c..bc8d7544b 100644 --- a/ivy/src/main/scala/sbt/CustomXmlParser.scala +++ b/ivy/src/main/scala/sbt/CustomXmlParser.scala @@ -21,9 +21,9 @@ private[sbt] object CustomXmlParser extends XmlModuleDescriptorParser { super.setResource(new URLResource(url)) super.setInput(url) } - def setInput(bytes: Array[Byte]) { setInput(new ByteArrayInputStream(bytes)) } + def setInput(bytes: Array[Byte]): Unit = setInput(new ByteArrayInputStream(bytes)) /** Overridden because the super implementation overwrites the module descriptor.*/ - override def setResource(res: Resource) {} + override def setResource(res: Resource): Unit = () override def setMd(md: DefaultModuleDescriptor) = { super.setMd(md) @@ -32,4 +32,4 @@ private[sbt] object CustomXmlParser extends XmlModuleDescriptorParser { override def parseDepsConfs(confs: String, dd: DefaultDependencyDescriptor) = super.parseDepsConfs(confs, dd) override def getDefaultConf = defaultConfig.getOrElse(super.getDefaultConf) } -} \ No newline at end of file +} diff --git a/ivy/src/main/scala/sbt/Ivy.scala b/ivy/src/main/scala/sbt/Ivy.scala index 7e4cf3792..e9ac5a23d 100644 --- a/ivy/src/main/scala/sbt/Ivy.scala +++ b/ivy/src/main/scala/sbt/Ivy.scala @@ -231,7 +231,7 @@ final class IvySbt(val configuration: IvyConfiguration) { addScalaToolDependencies(dmd, parser, is) (dmd, parser.getDefaultConf) } - private def addScalaToolDependencies(dmd: DefaultModuleDescriptor, parser: CustomXmlParser.CustomParser, is: IvyScala) { + private def addScalaToolDependencies(dmd: DefaultModuleDescriptor, parser: CustomXmlParser.CustomParser, is: IvyScala): Unit = { IvySbt.addConfigurations(dmd, Configurations.ScalaTool :: Nil) IvySbt.addDependencies(dmd, ScalaArtifacts.toolDependencies(is.scalaOrganization, is.scalaFullVersion), parser) } @@ -257,7 +257,7 @@ private[sbt] object IvySbt { def defaultIvyConfiguration(project: File) = new File(project, DefaultIvyConfigFilename) def defaultPOM(project: File) = new File(project, DefaultMavenFilename) - def loadURI(is: IvySettings, uri: URI) { + def loadURI(is: IvySettings, uri: URI): Unit = { if (uri.getScheme == "file") is.load(new File(uri)) // IVY-1114 else @@ -268,7 +268,7 @@ private[sbt] object IvySbt { * Sets the resolvers for 'settings' to 'resolvers'. This is done by creating a new chain and making it the default. * 'other' is for resolvers that should be in a different chain. These are typically used for publishing or other actions. */ - private def setResolvers(settings: IvySettings, resolvers: Seq[Resolver], other: Seq[Resolver], localOnly: Boolean, updateOptions: UpdateOptions, log: Logger) { + private def setResolvers(settings: IvySettings, resolvers: Seq[Resolver], other: Seq[Resolver], localOnly: Boolean, updateOptions: UpdateOptions, log: Logger): Unit = { def makeChain(label: String, name: String, rs: Seq[Resolver]) = { log.debug(label + " repositories:") val chain = resolverChain(name, rs, localOnly, settings, updateOptions, log) @@ -304,7 +304,7 @@ private[sbt] object IvySbt { } } - def addResolvers(resolvers: Seq[Resolver], settings: IvySettings, log: Logger) { + def addResolvers(resolvers: Seq[Resolver], settings: IvySettings, log: Logger): Unit = { for (r <- resolvers) { log.debug("\t" + r) settings.addResolver(ConvertResolver(r, settings, log)) @@ -320,7 +320,7 @@ private[sbt] object IvySbt { import collection.JavaConversions._ artifact.getQualifiedExtraAttributes.keys.exists(_.asInstanceOf[String] startsWith "m:") } - private def setModuleConfigurations(settings: IvySettings, moduleConfigurations: Seq[ModuleConfiguration], log: Logger) { + private def setModuleConfigurations(settings: IvySettings, moduleConfigurations: Seq[ModuleConfiguration], log: Logger): Unit = { val existing = settings.getResolverNames for (moduleConf <- moduleConfigurations) { import moduleConf._ @@ -332,11 +332,11 @@ private[sbt] object IvySbt { settings.addModuleConfiguration(attributes, settings.getMatcher(EXACT_OR_REGEXP), resolver.name, null, null, null) } } - private def configureCache(settings: IvySettings, localOnly: Boolean, resCacheDir: Option[File]) { + private def configureCache(settings: IvySettings, localOnly: Boolean, resCacheDir: Option[File]): Unit = { configureResolutionCache(settings, localOnly, resCacheDir) configureRepositoryCache(settings, localOnly) } - private[this] def configureResolutionCache(settings: IvySettings, localOnly: Boolean, resCacheDir: Option[File]) { + private[this] def configureResolutionCache(settings: IvySettings, localOnly: Boolean, resCacheDir: Option[File]): Unit = { val base = resCacheDir getOrElse settings.getDefaultResolutionCacheBasedir settings.setResolutionCacheManager(new ResolutionCache(base, settings)) } @@ -385,7 +385,7 @@ private[sbt] object IvySbt { case _ => false } // ignore the original resolver wherever possible to avoid issues like #704 - override def saveResolvers(descriptor: ModuleDescriptor, metadataResolverName: String, artifactResolverName: String) {} + override def saveResolvers(descriptor: ModuleDescriptor, metadataResolverName: String, artifactResolverName: String): Unit = () } manager.setArtifactPattern(PluginPattern + manager.getArtifactPattern) manager.setDataFilePattern(PluginPattern + manager.getDataFilePattern) @@ -411,12 +411,12 @@ private[sbt] object IvySbt { dmd.addExtraAttributeNamespace("e", "http://ant.apache.org/ivy/extra") /** Adds the ivy.xml main artifact. */ - private def addMainArtifact(moduleID: DefaultModuleDescriptor) { + private def addMainArtifact(moduleID: DefaultModuleDescriptor): Unit = { val artifact = DefaultArtifact.newIvyArtifact(moduleID.getResolvedModuleRevisionId, moduleID.getPublicationDate) moduleID.setModuleArtifact(artifact) moduleID.check() } - private def setConflictManager(moduleID: DefaultModuleDescriptor, conflict: ConflictManager, is: IvySettings) { + private def setConflictManager(moduleID: DefaultModuleDescriptor, conflict: ConflictManager, is: IvySettings): Unit = { val mid = ModuleId.newInstance(conflict.organization, conflict.module) val matcher = is.getMatcher(PatternMatcher.EXACT_OR_REGEXP) val manager = is.getConflictManager(conflict.name) @@ -555,7 +555,7 @@ private[sbt] object IvySbt { } /** This method is used to add inline dependencies to the provided module. */ - def addDependencies(moduleID: DefaultModuleDescriptor, dependencies: Seq[ModuleID], parser: CustomXmlParser.CustomParser) { + def addDependencies(moduleID: DefaultModuleDescriptor, dependencies: Seq[ModuleID], parser: CustomXmlParser.CustomParser): Unit = { val converted = dependencies map { dependency => convertDependency(moduleID, dependency, parser) } val unique = if (hasDuplicateDependencies(converted)) mergeDuplicateDefinitions(converted) else converted unique foreach moduleID.addDependency @@ -579,7 +579,7 @@ private[sbt] object IvySbt { */ def mergeDuplicateDefinitions(dependencies: Seq[DependencyDescriptor]): Seq[DependencyDescriptor] = { - // need to preserve basic order of dependencies: can't use dependencies.groupBy + // need to preserve basic order of dependencies: can't use dependencies.groupBy val deps = new java.util.LinkedHashMap[ModuleRevisionId, List[DependencyDescriptor]] for (dd <- dependencies) { val id = dd.getDependencyRevisionId diff --git a/ivy/src/main/scala/sbt/IvyActions.scala b/ivy/src/main/scala/sbt/IvyActions.scala index ef2db547e..33436452c 100644 --- a/ivy/src/main/scala/sbt/IvyActions.scala +++ b/ivy/src/main/scala/sbt/IvyActions.scala @@ -61,7 +61,7 @@ object UpdateLogging extends Enumeration { object IvyActions { /** Installs the dependencies of the given 'module' from the resolver named 'from' to the resolver named 'to'.*/ - def install(module: IvySbt#Module, from: String, to: String, log: Logger) { + def install(module: IvySbt#Module, from: String, to: String, log: Logger): Unit = { module.withModule(log) { (ivy, md, default) => for (dependency <- md.getDependencies) { log.info("Installing " + dependency) @@ -89,7 +89,7 @@ object IvyActions { } /** Creates a Maven pom from the given Ivy configuration*/ - def makePom(module: IvySbt#Module, configuration: MakePomConfiguration, log: Logger) { + def makePom(module: IvySbt#Module, configuration: MakePomConfiguration, log: Logger): Unit = { import configuration.{ allRepositories, moduleInfo, configurations, extra, file, filterRepositories, process, includeTypes } module.withModule(log) { (ivy, md, default) => (new MakePom(log)).write(ivy, md, moduleInfo, configurations, includeTypes, extra, process, filterRepositories, allRepositories, file) @@ -112,7 +112,7 @@ object IvyActions { def deliveredFile(ivy: Ivy, pattern: String, md: ModuleDescriptor): File = ivy.getSettings.resolveFile(IvyPatternHelper.substitute(pattern, md.getResolvedModuleRevisionId)) - def publish(module: IvySbt#Module, configuration: PublishConfiguration, log: Logger) { + def publish(module: IvySbt#Module, configuration: PublishConfiguration, log: Logger): Unit = { import configuration._ module.withModule(log) { case (ivy, md, default) => @@ -368,7 +368,7 @@ object IvyActions { } } } - private[this] def checkFilesPresent(artifacts: Seq[(IArtifact, File)]) { + private[this] def checkFilesPresent(artifacts: Seq[(IArtifact, File)]): Unit = { val missing = artifacts filter { case (a, file) => !file.exists } if (missing.nonEmpty) sys.error("Missing files for publishing:\n\t" + missing.map(_._2.getAbsolutePath).mkString("\n\t")) diff --git a/ivy/src/main/scala/sbt/IvyCache.scala b/ivy/src/main/scala/sbt/IvyCache.scala index 51e02b60c..ce2ddd9f2 100644 --- a/ivy/src/main/scala/sbt/IvyCache.scala +++ b/ivy/src/main/scala/sbt/IvyCache.scala @@ -28,7 +28,7 @@ private object NotInCache { class IvyCache(val ivyHome: Option[File]) { def lockFile = new File(ivyHome getOrElse Path.userHome, ".sbt.cache.lock") /** Caches the given 'file' with the given ID. It may be retrieved or cleared using this ID.*/ - def cacheJar(moduleID: ModuleID, file: File, lock: Option[xsbti.GlobalLock], log: Logger) { + def cacheJar(moduleID: ModuleID, file: File, lock: Option[xsbti.GlobalLock], log: Logger): Unit = { val artifact = defaultArtifact(moduleID) val resolved = new ResolvedResource(new FileResource(new IvyFileRepository, file), moduleID.revision) withDefaultCache(lock, log) { cache => @@ -37,7 +37,7 @@ class IvyCache(val ivyHome: Option[File]) { } } /** Clears the cache of the jar for the given ID.*/ - def clearCachedJar(id: ModuleID, lock: Option[xsbti.GlobalLock], log: Logger) { + def clearCachedJar(id: ModuleID, lock: Option[xsbti.GlobalLock], log: Logger): Unit = { try { withCachedJar(id, lock, log)(_.delete) } catch { case e: Exception => log.debug("Error cleaning cached jar: " + e.toString) } } @@ -87,11 +87,11 @@ class IvyCache(val ivyHome: Option[File]) { } /** Required by Ivy for copying to the cache.*/ private class FileDownloader extends ResourceDownloader with NotNull { - def download(artifact: IvyArtifact, resource: Resource, dest: File) { + def download(artifact: IvyArtifact, resource: Resource, dest: File): Unit = { if (dest.exists()) dest.delete() val part = new File(dest.getAbsolutePath + ".part") FileUtil.copy(resource.openStream, part, null) if (!part.renameTo(dest)) sys.error("Could not move temporary file " + part + " to final location " + dest) } -} \ No newline at end of file +} diff --git a/ivy/src/main/scala/sbt/IvyLogger.scala b/ivy/src/main/scala/sbt/IvyLogger.scala index 42131a174..94268672e 100644 --- a/ivy/src/main/scala/sbt/IvyLogger.scala +++ b/ivy/src/main/scala/sbt/IvyLogger.scala @@ -7,8 +7,8 @@ import org.apache.ivy.util.{ Message, MessageLogger, MessageLoggerEngine } /** Interface to Ivy logging. */ private final class IvyLoggerInterface(logger: Logger) extends MessageLogger { - def rawlog(msg: String, level: Int) = log(msg, level) - def log(msg: String, level: Int) { + def rawlog(msg: String, level: Int): Unit = log(msg, level) + def log(msg: String, level: Int): Unit = { import Message.{ MSG_DEBUG, MSG_VERBOSE, MSG_INFO, MSG_WARN, MSG_ERR } level match { case MSG_DEBUG => debug(msg) @@ -20,32 +20,32 @@ private final class IvyLoggerInterface(logger: Logger) extends MessageLogger { } //DEBUG level messages are very verbose and rarely useful to users. // TODO: provide access to this information some other way - def debug(msg: String) {} - def verbose(msg: String) = logger.verbose(msg) - def deprecated(msg: String) = warn(msg) - def info(msg: String) = logger.info(msg) - def rawinfo(msg: String) = info(msg) - def warn(msg: String) = logger.warn(msg) - def error(msg: String) = if (SbtIvyLogger.acceptError(msg)) logger.error(msg) + def debug(msg: String): Unit = () + def verbose(msg: String): Unit = logger.verbose(msg) + def deprecated(msg: String): Unit = warn(msg) + def info(msg: String): Unit = logger.info(msg) + def rawinfo(msg: String): Unit = info(msg) + def warn(msg: String): Unit = logger.warn(msg) + def error(msg: String): Unit = if (SbtIvyLogger.acceptError(msg)) logger.error(msg) private def emptyList = java.util.Collections.emptyList[String] def getProblems = emptyList def getWarns = emptyList def getErrors = emptyList - def clearProblems = () - def sumupProblems = clearProblems() - def progress = () - def endProgress = () + def clearProblems(): Unit = () + def sumupProblems(): Unit = clearProblems() + def progress(): Unit = () + def endProgress(): Unit = () - def endProgress(msg: String) = info(msg) + def endProgress(msg: String): Unit = info(msg) def isShowProgress = false - def setShowProgress(progress: Boolean) {} + def setShowProgress(progress: Boolean): Unit = () } private final class SbtMessageLoggerEngine extends MessageLoggerEngine { /** This is a hack to filter error messages about 'unknown resolver ...'. */ - override def error(msg: String) = if (SbtIvyLogger.acceptError(msg)) super.error(msg) - override def sumupProblems = clearProblems() + override def error(msg: String): Unit = if (SbtIvyLogger.acceptError(msg)) super.error(msg) + override def sumupProblems(): Unit = clearProblems() } private object SbtIvyLogger { val UnknownResolver = "unknown resolver" diff --git a/ivy/src/main/scala/sbt/IvyScala.scala b/ivy/src/main/scala/sbt/IvyScala.scala index d2697e308..2614df994 100644 --- a/ivy/src/main/scala/sbt/IvyScala.scala +++ b/ivy/src/main/scala/sbt/IvyScala.scala @@ -37,7 +37,7 @@ final case class IvyScala(scalaFullVersion: String, scalaBinaryVersion: String, private object IvyScala { /** Performs checks/adds filters on Scala dependencies (if enabled in IvyScala). */ - def checkModule(module: DefaultModuleDescriptor, conf: String, log: Logger)(check: IvyScala) { + def checkModule(module: DefaultModuleDescriptor, conf: String, log: Logger)(check: IvyScala): Unit = { if (check.checkExplicit) checkDependencies(module, check.scalaBinaryVersion, check.configurations, log) if (check.filterImplicit) @@ -45,12 +45,12 @@ private object IvyScala { if (check.overrideScalaVersion) overrideScalaVersion(module, check.scalaFullVersion) } - def overrideScalaVersion(module: DefaultModuleDescriptor, version: String) { + def overrideScalaVersion(module: DefaultModuleDescriptor, version: String): Unit = { overrideVersion(module, Organization, LibraryID, version) overrideVersion(module, Organization, CompilerID, version) overrideVersion(module, Organization, ReflectID, version) } - def overrideVersion(module: DefaultModuleDescriptor, org: String, name: String, version: String) { + def overrideVersion(module: DefaultModuleDescriptor, org: String, name: String, version: String): Unit = { val id = new ModuleId(org, name) val over = new OverrideDependencyDescriptorMediator(null, version) module.addDependencyDescriptorMediator(id, ExactPatternMatcher.INSTANCE, over) @@ -60,7 +60,7 @@ private object IvyScala { * Checks the immediate dependencies of module for dependencies on scala jars and verifies that the version on the * dependencies matches scalaVersion. */ - private def checkDependencies(module: ModuleDescriptor, scalaBinaryVersion: String, configurations: Iterable[Configuration], log: Logger) { + private def checkDependencies(module: ModuleDescriptor, scalaBinaryVersion: String, configurations: Iterable[Configuration], log: Logger): Unit = { val configSet = if (configurations.isEmpty) (c: String) => true else configurationSet(configurations) def binaryScalaWarning(dep: DependencyDescriptor): Option[String] = { @@ -88,7 +88,7 @@ private object IvyScala { * done because these jars are provided by the ScalaInstance of the project. The version of Scala to use * is done by setting scalaVersion in the project definition. */ - private def excludeScalaJars(module: DefaultModuleDescriptor, configurations: Iterable[Configuration]) { + private def excludeScalaJars(module: DefaultModuleDescriptor, configurations: Iterable[Configuration]): Unit = { val configurationNames = { val names = module.getConfigurationsNames diff --git a/ivy/src/main/scala/sbt/MakePom.scala b/ivy/src/main/scala/sbt/MakePom.scala index 81121bf7f..e2018612f 100644 --- a/ivy/src/main/scala/sbt/MakePom.scala +++ b/ivy/src/main/scala/sbt/MakePom.scala @@ -83,9 +83,8 @@ class MakePom(val log: Logger) { write(process(toPom(ivy, module, moduleInfo, configurations, includeTypes, extra, filterRepositories, allRepositories)), output) // use \n as newline because toString uses PrettyPrinter, which hard codes line endings to be \n def write(node: XNode, output: File): Unit = write(toString(node), output, "\n") - def write(xmlString: String, output: File, newline: String) { + def write(xmlString: String, output: File, newline: String): Unit = IO.write(output, "" + newline + xmlString) - } def toString(node: XNode): String = new PrettyPrinter(1000, 4).format(node) @deprecated("Use `toPom(Ivy, ModuleDescriptor, ModuleInfo, Option[Iterable[Configuration]], Set[String], NodeSeq, MavenRepository => Boolean, Boolean)` instead", "0.11.2") diff --git a/ivy/src/main/scala/sbt/ProjectResolver.scala b/ivy/src/main/scala/sbt/ProjectResolver.scala index a51e0abb8..61c811e7b 100644 --- a/ivy/src/main/scala/sbt/ProjectResolver.scala +++ b/ivy/src/main/scala/sbt/ProjectResolver.scala @@ -70,12 +70,12 @@ class ProjectResolver(name: String, map: Map[ModuleRevisionId, ModuleDescriptor] // doesn't support publishing def publish(artifact: IArtifact, src: File, overwrite: Boolean) = sys.error("Publish not supported by ProjectResolver") - def beginPublishTransaction(module: ModuleRevisionId, overwrite: Boolean) {} - def abortPublishTransaction() {} - def commitPublishTransaction() {} + def beginPublishTransaction(module: ModuleRevisionId, overwrite: Boolean): Unit = () + def abortPublishTransaction(): Unit = () + def commitPublishTransaction(): Unit = () - def reportFailure() {} - def reportFailure(art: IArtifact) {} + def reportFailure(): Unit = () + def reportFailure(art: IArtifact): Unit = () def listOrganisations() = new Array[OrganisationEntry](0) def listModules(org: OrganisationEntry) = new Array[ModuleEntry](0) @@ -85,8 +85,8 @@ class ProjectResolver(name: String, map: Map[ModuleRevisionId, ModuleDescriptor] private[this] var settings: Option[ResolverSettings] = None - def dumpSettings() {} - def setSettings(settings: ResolverSettings) { this.settings = Some(settings) } + def dumpSettings(): Unit = () + def setSettings(settings: ResolverSettings): Unit = { this.settings = Some(settings) } def getRepositoryCacheManager = settings match { case Some(s) => s.getDefaultRepositoryCacheManager; case None => sys.error("No settings defined for ProjectResolver") } } diff --git a/ivy/src/main/scala/sbt/ResolutionCache.scala b/ivy/src/main/scala/sbt/ResolutionCache.scala index 0fd7a0a06..a68c52417 100644 --- a/ivy/src/main/scala/sbt/ResolutionCache.scala +++ b/ivy/src/main/scala/sbt/ResolutionCache.scala @@ -28,7 +28,7 @@ private[sbt] final class ResolutionCache(base: File, settings: IvySettings) exte private[this] val reportBase: File = new File(base, ReportDirectory) def getResolutionCacheRoot: File = base - def clean() { IO.delete(base) } + def clean(): Unit = IO.delete(base) override def toString = Name def getResolvedIvyFileInCache(mrid: ModuleRevisionId): File = @@ -66,7 +66,7 @@ private[sbt] object ResolutionCache { * Removes cached files from the resolution cache for the module with ID `mrid` * and the resolveId (as set on `ResolveOptions`). */ - private[sbt] def cleanModule(mrid: ModuleRevisionId, resolveId: String, manager: ResolutionCacheManager) { + private[sbt] def cleanModule(mrid: ModuleRevisionId, resolveId: String, manager: ResolutionCacheManager): Unit = { val files = Option(manager.getResolvedIvyFileInCache(mrid)).toList ::: Option(manager.getResolvedIvyPropertiesInCache(mrid)).toList ::: @@ -87,4 +87,4 @@ private[sbt] object ResolutionCache { // use sbt-specific extra attributes so that resolved xml files do not get overwritten when using different Scala/sbt versions private val ResolvedPattern = "[organisation]/[module]/" + Resolver.PluginPattern + "[revision]/[artifact].[ext]" -} \ No newline at end of file +} diff --git a/ivy/src/main/scala/sbt/StringUtilities.scala b/ivy/src/main/scala/sbt/StringUtilities.scala index fc8327304..40018250e 100644 --- a/ivy/src/main/scala/sbt/StringUtilities.scala +++ b/ivy/src/main/scala/sbt/StringUtilities.scala @@ -8,8 +8,6 @@ import java.util.Locale object StringUtilities { @deprecated("Different use cases require different normalization. Use Project.normalizeModuleID or normalizeProjectID instead.", "0.13.0") def normalize(s: String) = s.toLowerCase(Locale.ENGLISH).replaceAll("""\W+""", "-") - def nonEmpty(s: String, label: String) { - require(s.trim.length > 0, label + " cannot be empty.") - } + def nonEmpty(s: String, label: String): Unit = require(s.trim.length > 0, label + " cannot be empty.") def appendable(s: String) = if (s.isEmpty) "" else "_" + s } diff --git a/ivy/src/main/scala/sbt/ivyint/ErrorMessageAuthenticator.scala b/ivy/src/main/scala/sbt/ivyint/ErrorMessageAuthenticator.scala index bb5996834..5d067d313 100644 --- a/ivy/src/main/scala/sbt/ivyint/ErrorMessageAuthenticator.scala +++ b/ivy/src/main/scala/sbt/ivyint/ErrorMessageAuthenticator.scala @@ -54,7 +54,7 @@ object ErrorMessageAuthenticator { } /** Installs the error message authenticator so we have nicer error messages when using java's URL for downloading. */ - def install() { + def install(): Unit = { // Actually installs the error message authenticator. def doInstall(original: Option[Authenticator]): Unit = try Authenticator.setDefault(new ErrorMessageAuthenticator(original)) @@ -126,4 +126,4 @@ private[sbt] final class ErrorMessageAuthenticator(original: Option[Authenticato private def isProxyAuthentication: Boolean = getRequestorType == Authenticator.RequestorType.PROXY -} \ No newline at end of file +} diff --git a/main/actions/src/main/scala/sbt/DotGraph.scala b/main/actions/src/main/scala/sbt/DotGraph.scala index 90fd9fe25..06c2e1a84 100644 --- a/main/actions/src/main/scala/sbt/DotGraph.scala +++ b/main/actions/src/main/scala/sbt/DotGraph.scala @@ -9,11 +9,11 @@ import inc.Relations object DotGraph { private def fToString(roots: Iterable[File]): (File => String) = (x: File) => sourceToString(roots, x) - def sources(relations: Relations, outputDirectory: File, sourceRoots: Iterable[File]) { + def sources(relations: Relations, outputDirectory: File, sourceRoots: Iterable[File]): Unit = { val toString = fToString(sourceRoots) apply(relations, outputDirectory, toString, toString) } - def packages(relations: Relations, outputDirectory: File, sourceRoots: Iterable[File]) { + def packages(relations: Relations, outputDirectory: File, sourceRoots: Iterable[File]): Unit = { val packageOnly = (path: String) => { val last = path.lastIndexOf(File.separatorChar) @@ -23,7 +23,7 @@ object DotGraph { val toString = packageOnly compose fToString(sourceRoots) apply(relations, outputDirectory, toString, toString) } - def apply(relations: Relations, outputDir: File, sourceToString: File => String, externalToString: File => String) { + def apply(relations: Relations, outputDir: File, sourceToString: File => String, externalToString: File => String): Unit = { def file(name: String) = new File(outputDir, name) IO.createDirectory(outputDir) generateGraph(file("int-source-deps"), "dependencies", relations.internalSrcDep, sourceToString, sourceToString) @@ -60,4 +60,4 @@ object DotGraph { val shortest = (Int.MaxValue /: relativized)(_ min _.length) relativized.find(_.length == shortest).getOrElse(path.getName) } -} \ No newline at end of file +} diff --git a/main/actions/src/main/scala/sbt/Package.scala b/main/actions/src/main/scala/sbt/Package.scala index df9af955d..8acdf93be 100644 --- a/main/actions/src/main/scala/sbt/Package.scala +++ b/main/actions/src/main/scala/sbt/Package.scala @@ -32,7 +32,7 @@ object Package { def mergeAttributes(a1: Attributes, a2: Attributes) = a1 ++= a2 // merges `mergeManifest` into `manifest` (mutating `manifest` in the process) - def mergeManifests(manifest: Manifest, mergeManifest: Manifest) { + def mergeManifests(manifest: Manifest, mergeManifest: Manifest): Unit = { mergeAttributes(manifest.getMainAttributes, mergeManifest.getMainAttributes) val entryMap = mapAsScalaMap(manifest.getEntries) for ((key, value) <- mergeManifest.getEntries) { @@ -44,7 +44,7 @@ object Package { } final class Configuration(val sources: Seq[(File, String)], val jar: File, val options: Seq[PackageOption]) - def apply(conf: Configuration, cacheFile: File, log: Logger) { + def apply(conf: Configuration, cacheFile: File, log: Logger): Unit = { val manifest = new Manifest val main = manifest.getMainAttributes for (option <- conf.options) { @@ -71,7 +71,7 @@ object Package { val inputs = map :+: lastModified(map.keySet) :+: manifest :+: HNil cachedMakeJar(inputs)(() => exists(conf.jar)) } - def setVersion(main: Attributes) { + def setVersion(main: Attributes): Unit = { val version = Attributes.Name.MANIFEST_VERSION if (main.getValue(version) eq null) main.put(version, "1.0") @@ -90,7 +90,7 @@ object Package { val attribVals = Seq(name, version, orgName, org) ManifestAttributes((attribKeys zip attribVals) ++ { homepage map (h => (IMPLEMENTATION_URL, h.toString)) }: _*) } - def makeJar(sources: Seq[(File, String)], jar: File, manifest: Manifest, log: Logger) { + def makeJar(sources: Seq[(File, String)], jar: File, manifest: Manifest, log: Logger): Unit = { log.info("Packaging " + jar.getAbsolutePath + " ...") IO.delete(jar) log.debug(sourcesDebugString(sources)) @@ -104,4 +104,4 @@ object Package { implicit def manifestFormat: Format[Manifest] = streamFormat(_ write _, in => new Manifest(in)) implicit def stringMapEquiv: Equiv[Map[File, String]] = defaultEquiv -} \ No newline at end of file +} diff --git a/main/actions/src/main/scala/sbt/compiler/Eval.scala b/main/actions/src/main/scala/sbt/compiler/Eval.scala index d075bfebc..adeb042bf 100644 --- a/main/actions/src/main/scala/sbt/compiler/Eval.scala +++ b/main/actions/src/main/scala/sbt/compiler/Eval.scala @@ -70,7 +70,7 @@ final class Eval(optionsNoncp: Seq[String], classpath: Seq[File], mkReporter: Se import global._ import definitions._ - private[sbt] def unlinkDeferred() { + private[sbt] def unlinkDeferred(): Unit = { toUnlinkLater foreach unlink toUnlinkLater = Nil } diff --git a/main/command/src/main/scala/sbt/MainLoop.scala b/main/command/src/main/scala/sbt/MainLoop.scala index dac718ef2..6f34813c5 100644 --- a/main/command/src/main/scala/sbt/MainLoop.scala +++ b/main/command/src/main/scala/sbt/MainLoop.scala @@ -14,9 +14,7 @@ object MainLoop { // the jline terminal in finally blocks, but hitting ctrl+c prevents finally blocks from being executed, in that // case the only way to restore the terminal is in a shutdown hook. val shutdownHook = new Thread(new Runnable { - def run() { - TerminalFactory.get().restore() - } + def run(): Unit = TerminalFactory.get().restore() }) try { @@ -71,7 +69,7 @@ object MainLoop { } /** Transfers logging and trace levels from the old global loggers to the new ones. */ - private[this] def transferLevels(state: State, logging: GlobalLogging) { + private[this] def transferLevels(state: State, logging: GlobalLogging): Unit = { val old = state.globalLogging Logger.transferLevels(old.backed, logging.backed) (old.full, logging.full) match { // well, this is a hack @@ -108,4 +106,4 @@ object MainLoop { def handleException(t: Throwable, s: State, log: Logger): State = State.handleException(t, s, log) def logFullException(e: Throwable, log: Logger): Unit = State.logFullException(e, log) -} \ No newline at end of file +} diff --git a/main/command/src/main/scala/sbt/State.scala b/main/command/src/main/scala/sbt/State.scala index 910a056ab..3e88a8db9 100644 --- a/main/command/src/main/scala/sbt/State.scala +++ b/main/command/src/main/scala/sbt/State.scala @@ -246,7 +246,7 @@ object State { } s.fail } - private[sbt] def logFullException(e: Throwable, log: Logger) { + private[sbt] def logFullException(e: Throwable, log: Logger): Unit = { log.trace(e) log.error(ErrorHandling reducedToString e) log.error("Use 'last' for the full log.") diff --git a/main/src/main/scala/sbt/Aggregation.scala b/main/src/main/scala/sbt/Aggregation.scala index 324b3c53b..d251b375f 100644 --- a/main/src/main/scala/sbt/Aggregation.scala +++ b/main/src/main/scala/sbt/Aggregation.scala @@ -39,7 +39,7 @@ final object Aggregation { showRun(complete, show) (complete.state, complete.results) } - def showRun[T](complete: Complete[T], show: ShowConfig)(implicit display: Show[ScopedKey[_]]) { + def showRun[T](complete: Complete[T], show: ShowConfig)(implicit display: Show[ScopedKey[_]]): Unit = { import complete._ val log = state.log val extracted = Project extract state @@ -76,7 +76,7 @@ final object Aggregation { } } - def printSuccess(start: Long, stop: Long, extracted: Extracted, success: Boolean, log: Logger) { + def printSuccess(start: Long, stop: Long, extracted: Extracted, success: Boolean, log: Logger): Unit = { import extracted._ def get(key: SettingKey[Boolean]): Boolean = key in currentRef get structure.data getOrElse true if (get(showSuccess)) { diff --git a/main/src/main/scala/sbt/BuildLoader.scala b/main/src/main/scala/sbt/BuildLoader.scala index a515775e4..f4cd55255 100644 --- a/main/src/main/scala/sbt/BuildLoader.scala +++ b/main/src/main/scala/sbt/BuildLoader.scala @@ -29,7 +29,7 @@ final class MultiHandler[S, T](builtIn: S => Option[T], root: Option[S => Option def applyNonRoots(info: S): List[(URI, T)] = nonRoots flatMap { case (definingURI, loader) => loader(info) map { unit => (definingURI, unit) } } - private[this] def warn(baseMessage: String, log: Logger, matching: Seq[(URI, T)]) { + private[this] def warn(baseMessage: String, log: Logger, matching: Seq[(URI, T)]): Unit = { log.warn(baseMessage) log.debug("Non-root build resolvers defined in:") log.debug(matching.map(_._1).mkString("\n\t")) @@ -139,4 +139,4 @@ final class BuildLoader( val load = full(info) getOrElse fail(uri) load() } -} \ No newline at end of file +} diff --git a/main/src/main/scala/sbt/BuildPaths.scala b/main/src/main/scala/sbt/BuildPaths.scala index 76981febe..eb462f20f 100644 --- a/main/src/main/scala/sbt/BuildPaths.scala +++ b/main/src/main/scala/sbt/BuildPaths.scala @@ -21,7 +21,7 @@ object BuildPaths { def getDefault = { checkTransition(state, default); default } getFileSetting(globalBaseDirectory, GlobalBaseProperty, getDefault)(state) } - private[this] def checkTransition(state: State, versioned: File) { + private[this] def checkTransition(state: State, versioned: File): Unit = { val unversioned = defaultGlobalBase def globalDefined(base: File): Boolean = getGlobalPluginsDirectory(state, base).exists || diff --git a/main/src/main/scala/sbt/BuildUtil.scala b/main/src/main/scala/sbt/BuildUtil.scala index 58ecd14ca..1dcd773f1 100644 --- a/main/src/main/scala/sbt/BuildUtil.scala +++ b/main/src/main/scala/sbt/BuildUtil.scala @@ -58,7 +58,7 @@ object BuildUtil { BuildDependencies(cp.toMap, agg.toMap) } - def checkCycles(units: Map[URI, LoadedBuildUnit]) { + def checkCycles(units: Map[URI, LoadedBuildUnit]): Unit = { def getRef(pref: ProjectRef) = units(pref.build).defined(pref.project) def deps(proj: ResolvedProject)(base: ResolvedProject => Seq[ProjectRef]): Seq[ResolvedProject] = Dag.topologicalSort(proj)(p => base(p) map getRef) // check for cycles diff --git a/main/src/main/scala/sbt/ConsoleProject.scala b/main/src/main/scala/sbt/ConsoleProject.scala index 446169a33..a484d4e8f 100644 --- a/main/src/main/scala/sbt/ConsoleProject.scala +++ b/main/src/main/scala/sbt/ConsoleProject.scala @@ -6,7 +6,7 @@ package sbt import java.io.File object ConsoleProject { - def apply(state: State, extra: String, cleanupCommands: String = "", options: Seq[String] = Nil)(implicit log: Logger) { + def apply(state: State, extra: String, cleanupCommands: String = "", options: Seq[String] = Nil)(implicit log: Logger): Unit = { val extracted = Project extract state val cpImports = new Imports(extracted, state) val bindings = ("currentState" -> state) :: ("extracted" -> extracted) :: ("cpHelpers" -> cpImports) :: Nil diff --git a/main/src/main/scala/sbt/Defaults.scala b/main/src/main/scala/sbt/Defaults.scala index 311d87a28..9904ee22e 100755 --- a/main/src/main/scala/sbt/Defaults.scala +++ b/main/src/main/scala/sbt/Defaults.scala @@ -1253,7 +1253,7 @@ object Classpaths { @deprecated("Split into ivyBaseSettings and jvmBaseSettings.", "0.13.2") val baseSettings: Seq[Setting[_]] = ivyBaseSettings ++ jvmBaseSettings - def warnResolversConflict(ress: Seq[Resolver], log: Logger) { + def warnResolversConflict(ress: Seq[Resolver], log: Logger): Unit = { val resset = ress.toSet for ((name, r) <- resset groupBy (_.name) if r.size > 1) { log.warn("Multiple resolvers having different access mechanism configured with same name '" + name + "'. To avoid conflict, Remove duplicate project resolvers (`resolvers`) or rename publishing resolver (`publishTo`).") @@ -1588,7 +1588,7 @@ object Classpaths { def interSort(projectRef: ProjectRef, conf: Configuration, data: Settings[Scope], deps: BuildDependencies): Seq[(ProjectRef, String)] = { val visited = asScalaSet(new LinkedHashSet[(ProjectRef, String)]) - def visit(p: ProjectRef, c: Configuration) { + def visit(p: ProjectRef, c: Configuration): Unit = { val applicableConfigs = allConfigs(c) for (ac <- applicableConfigs) // add all configurations in this project visited add (p -> ac.name) diff --git a/main/src/main/scala/sbt/EvaluateTask.scala b/main/src/main/scala/sbt/EvaluateTask.scala index 0bb93ec29..db7e32b33 100644 --- a/main/src/main/scala/sbt/EvaluateTask.scala +++ b/main/src/main/scala/sbt/EvaluateTask.scala @@ -280,7 +280,7 @@ object EvaluateTask { } } def logIncResult(result: Result[_], state: State, streams: Streams) = result match { case Inc(i) => logIncomplete(i, state, streams); case _ => () } - def logIncomplete(result: Incomplete, state: State, streams: Streams) { + def logIncomplete(result: Incomplete, state: State, streams: Streams): Unit = { val all = Incomplete linearize result val keyed = for (Incomplete(Some(key: ScopedKey[_]), _, msg, _, ex) <- all) yield (key, msg, ex) val un = all.filter { i => i.node.isEmpty || i.message.isEmpty } diff --git a/main/src/main/scala/sbt/Load.scala b/main/src/main/scala/sbt/Load.scala index 6d12523cd..71a0156ac 100755 --- a/main/src/main/scala/sbt/Load.scala +++ b/main/src/main/scala/sbt/Load.scala @@ -340,12 +340,12 @@ object Load { } case Nil => (references, builds, loaders) } - def checkProjectBase(buildBase: File, projectBase: File) { + def checkProjectBase(buildBase: File, projectBase: File): Unit = { checkDirectory(projectBase) assert(buildBase == projectBase || IO.relativize(buildBase, projectBase).isDefined, "Directory " + projectBase + " is not contained in build root " + buildBase) } def checkBuildBase(base: File) = checkDirectory(base) - def checkDirectory(base: File) { + def checkDirectory(base: File): Unit = { assert(base.isAbsolute, "Not absolute: " + base) if (base.isFile) sys.error("Not a directory: " + base) @@ -360,7 +360,7 @@ object Load { (uri, unit.resolveRefs(ref => Scope.resolveProjectRef(uri, rootProject, ref))) } } - def checkAll(referenced: Map[URI, List[ProjectReference]], builds: Map[URI, sbt.PartBuildUnit]) { + def checkAll(referenced: Map[URI, List[ProjectReference]], builds: Map[URI, sbt.PartBuildUnit]): Unit = { val rootProject = getRootProject(builds) for ((uri, refs) <- referenced; ref <- refs) { val ProjectRef(refURI, refID) = Scope.resolveProjectRef(uri, rootProject, ref) diff --git a/main/src/main/scala/sbt/LogManager.scala b/main/src/main/scala/sbt/LogManager.scala index 59e69bbdc..e5c8befa2 100644 --- a/main/src/main/scala/sbt/LogManager.scala +++ b/main/src/main/scala/sbt/LogManager.scala @@ -73,7 +73,7 @@ object LogManager { else { val logging = s.globalLogging def get[T](key: SettingKey[T]) = key in GlobalScope get data - def transfer(l: AbstractLogger, traceKey: SettingKey[Int], levelKey: SettingKey[Level.Value]) { + def transfer(l: AbstractLogger, traceKey: SettingKey[Int], levelKey: SettingKey[Level.Value]): Unit = { get(traceKey).foreach(l.setTrace) get(levelKey).foreach(l.setLevel) } diff --git a/main/src/main/scala/sbt/Main.scala b/main/src/main/scala/sbt/Main.scala index 8c8c9c024..2686ce1ef 100644 --- a/main/src/main/scala/sbt/Main.scala +++ b/main/src/main/scala/sbt/Main.scala @@ -211,13 +211,13 @@ object BuiltinCommands { if (Project.isProjectLoaded(s)) loadedEval(s, arg) else rawEval(s, arg) s } - private[this] def loadedEval(s: State, arg: String) { + private[this] def loadedEval(s: State, arg: String): Unit = { val extracted = Project extract s import extracted._ val result = session.currentEval().eval(arg, srcName = "", imports = autoImports(extracted)) s.log.info(s"ans: ${result.tpe} = ${result.getValue(currentLoader)}") } - private[this] def rawEval(s: State, arg: String) { + private[this] def rawEval(s: State, arg: String): Unit = { val app = s.configuration.provider val classpath = app.mainClasspath ++ app.scalaProvider.jars val result = Load.mkEval(classpath, s.baseDir, Nil).eval(arg, srcName = "", imports = new EvalImports(Nil, "")) @@ -405,7 +405,7 @@ object BuiltinCommands { case (s, Some(modifyBuilds)) => transformExtraBuilds(s, modifyBuilds) case (s, None) => showProjects(s); s } - def showProjects(s: State) { + def showProjects(s: State): Unit = { val extracted = Project extract s import extracted._ import currentRef.{ build => curi, project => cid } diff --git a/main/src/main/scala/sbt/Plugins.scala b/main/src/main/scala/sbt/Plugins.scala index 115cba10e..543e1b800 100644 --- a/main/src/main/scala/sbt/Plugins.scala +++ b/main/src/main/scala/sbt/Plugins.scala @@ -207,7 +207,7 @@ object Plugins extends PluginsFunctions { private[this] def literalsString(lits: Seq[Literal]): String = lits map { case Atom(l) => l; case Negated(Atom(l)) => l } mkString(", ") - private[this] def duplicateProvidesError(byAtom: Seq[(Atom, AutoPlugin)]) { + private[this] def duplicateProvidesError(byAtom: Seq[(Atom, AutoPlugin)]): Unit = { val dupsByAtom = byAtom.groupBy(_._1).mapValues(_.map(_._2)) val dupStrings = for( (atom, dups) <- dupsByAtom if dups.size > 1 ) yield s"${atom.label} by ${dups.mkString(", ")}" @@ -215,7 +215,7 @@ object Plugins extends PluginsFunctions { val message = s"Plugin$ns provided by multiple AutoPlugins:$nl${dupStrings.mkString(nl)}" throw AutoPluginException(message) } - private[this] def exlusionConflictError(requested: Plugins, selected: Seq[AutoPlugin], conflicting: Seq[AutoPlugin]) { + private[this] def exlusionConflictError(requested: Plugins, selected: Seq[AutoPlugin], conflicting: Seq[AutoPlugin]): Unit = { def listConflicts(ns: Seq[AutoPlugin]) = (ns map { c => val reasons = (if (flatten(requested) contains c) List("requested") else Nil) ++ diff --git a/main/src/main/scala/sbt/Project.scala b/main/src/main/scala/sbt/Project.scala index dba3c0f45..f953eb489 100755 --- a/main/src/main/scala/sbt/Project.scala +++ b/main/src/main/scala/sbt/Project.scala @@ -451,12 +451,12 @@ object Project extends ProjectExtra { } def settingGraph(structure: BuildStructure, basedir: File, scoped: ScopedKey[_])(implicit display: Show[ScopedKey[_]]): SettingGraph = SettingGraph(structure, basedir, scoped, 0) - def graphSettings(structure: BuildStructure, basedir: File)(implicit display: Show[ScopedKey[_]]) { + def graphSettings(structure: BuildStructure, basedir: File)(implicit display: Show[ScopedKey[_]]): Unit = { def graph(actual: Boolean, name: String) = graphSettings(structure, actual, name, new File(basedir, name + ".dot")) graph(true, "actual_dependencies") graph(false, "declared_dependencies") } - def graphSettings(structure: BuildStructure, actual: Boolean, graphName: String, file: File)(implicit display: Show[ScopedKey[_]]) { + def graphSettings(structure: BuildStructure, actual: Boolean, graphName: String, file: File)(implicit display: Show[ScopedKey[_]]): Unit = { val rel = relation(structure, actual) val keyToString = display.apply _ DotGraph.generateGraph(file, graphName, rel, keyToString, keyToString) diff --git a/main/src/main/scala/sbt/Resolvers.scala b/main/src/main/scala/sbt/Resolvers.scala index e3758a687..53e4def50 100644 --- a/main/src/main/scala/sbt/Resolvers.scala +++ b/main/src/main/scala/sbt/Resolvers.scala @@ -58,11 +58,11 @@ object Resolvers { val mercurial: Resolver = new DistributedVCS { override val scheme = "hg" - override def clone(from: String, to: File) { + override def clone(from: String, to: File): Unit = { run("hg", "clone", "-q", from, to.getAbsolutePath) } - override def checkout(branch: String, in: File) { + override def checkout(branch: String, in: File): Unit = { run(Some(in), "hg", "checkout", "-q", branch) } }.toResolver @@ -121,11 +121,10 @@ object Resolvers { isWindows && !isCygwin } - def run(command: String*) { + def run(command: String*): Unit = run(None, command: _*) - } - def run(cwd: Option[File], command: String*) { + def run(cwd: Option[File], command: String*): Unit = { val result = Process( if (onWindows) "cmd" +: "/c" +: command else command, diff --git a/main/src/main/scala/sbt/SessionSettings.scala b/main/src/main/scala/sbt/SessionSettings.scala index 5f59f0974..b1ad2a930 100755 --- a/main/src/main/scala/sbt/SessionSettings.scala +++ b/main/src/main/scala/sbt/SessionSettings.scala @@ -124,7 +124,7 @@ object SessionSettings { def pluralize(size: Int, of: String) = size.toString + (if (size == 1) of else (of + "s")) /** Checks to see if any session settings are being discarded and issues a warning. */ - def checkSession(newSession: SessionSettings, oldState: State) { + def checkSession(newSession: SessionSettings, oldState: State): Unit = { val oldSettings = (oldState get Keys.sessionSettings).toList.flatMap(_.append).flatMap(_._2) if (newSession.append.isEmpty && oldSettings.nonEmpty) oldState.log.warn("Discarding " + pluralize(oldSettings.size, " session setting") + ". Use 'session save' to persist session settings.") diff --git a/main/src/test/scala/sbt/internals/parser/SplitExpressionsBehavior.scala b/main/src/test/scala/sbt/internals/parser/SplitExpressionsBehavior.scala index fd44478a5..ffd535bec 100644 --- a/main/src/test/scala/sbt/internals/parser/SplitExpressionsBehavior.scala +++ b/main/src/test/scala/sbt/internals/parser/SplitExpressionsBehavior.scala @@ -11,7 +11,7 @@ trait SplitExpression { trait SplitExpressionsBehavior extends SplitExpression { this: SpecificationLike => - def oldExpressionsSplitter(implicit splitter: SplitExpressions.SplitExpression) { + def oldExpressionsSplitter(implicit splitter: SplitExpressions.SplitExpression): Unit = { "parse a simple setting" in { val (imports, settingsAndDefs) = split("""version := "1.0"""") @@ -60,7 +60,7 @@ trait SplitExpressionsBehavior extends SplitExpression { } - def newExpressionsSplitter(implicit splitter: SplitExpressions.SplitExpression) { + def newExpressionsSplitter(implicit splitter: SplitExpressions.SplitExpression): Unit = { "parse a two settings without intervening blank line" in { val (imports, settings) = split("""version := "1.0" @@ -90,4 +90,4 @@ lazy val root = (project in file(".")).enablePlugins­(PlayScala)""") } -} \ No newline at end of file +} diff --git a/project/Scripted.scala b/project/Scripted.scala index a6481747a..6202e3992 100644 --- a/project/Scripted.scala +++ b/project/Scripted.scala @@ -65,7 +65,7 @@ object Scripted { launchOpts: Array[String], prescripted: java.util.List[File]): Unit } - def doScripted(launcher: File, scriptedSbtClasspath: Seq[Attributed[File]], scriptedSbtInstance: ScalaInstance, sourcePath: File, args: Seq[String], prescripted: File => Unit) { + def doScripted(launcher: File, scriptedSbtClasspath: Seq[Attributed[File]], scriptedSbtInstance: ScalaInstance, sourcePath: File, args: Seq[String], prescripted: File => Unit): Unit = { System.err.println(s"About to run tests: ${args.mkString("\n * ", "\n * ", "\n")}") val noJLine = new classpath.FilteredLoader(scriptedSbtInstance.loader, "jline." :: Nil) val loader = classpath.ClasspathUtilities.toLoader(scriptedSbtClasspath.files, noJLine) diff --git a/project/SiteMap.scala b/project/SiteMap.scala index 48e663d8a..4084e203d 100644 --- a/project/SiteMap.scala +++ b/project/SiteMap.scala @@ -82,9 +82,9 @@ object SiteMap { private[this] def writeXML(output: File, node: xml.Node): Unit = write(output, new xml.PrettyPrinter(1000, 4).format(node)) - private[this] def write(output: File, xmlString: String) { + private[this] def write(output: File, xmlString: String): Unit = { // use \n as newline because toString uses PrettyPrinter, which hard codes line endings to be \n IO.write(output, s"\n") IO.append(output, xmlString) } -} \ No newline at end of file +} diff --git a/project/Transform.scala b/project/Transform.scala index 86c029fe9..95e65cb74 100644 --- a/project/Transform.scala +++ b/project/Transform.scala @@ -37,7 +37,7 @@ object Transform { file } } - def copyPropertiesFile(source: File, newMain: String, target: File) { + def copyPropertiesFile(source: File, newMain: String, target: File): Unit = { def subMain(line: String): String = if (line.trim.startsWith("class:")) " class: " + newMain else line IO.writeLines(target, IO.readLines(source) map subMain) } diff --git a/run/src/main/scala/sbt/Run.scala b/run/src/main/scala/sbt/Run.scala index e7d55a851..aff41f10f 100644 --- a/run/src/main/scala/sbt/Run.scala +++ b/run/src/main/scala/sbt/Run.scala @@ -54,13 +54,13 @@ class Run(instance: ScalaInstance, trapExit: Boolean, nativeTmp: File) extends S if (trapExit) Run.executeTrapExit(execute(), log) else directExecute() } - private def run0(mainClassName: String, classpath: Seq[File], options: Seq[String], log: Logger) { + private def run0(mainClassName: String, classpath: Seq[File], options: Seq[String], log: Logger): Unit = { log.debug(" Classpath:\n\t" + classpath.mkString("\n\t")) val loader = ClasspathUtilities.makeLoader(classpath, instance, nativeTmp) val main = getMainMethod(mainClassName, loader) invokeMain(loader, main, options) } - private def invokeMain(loader: ClassLoader, main: Method, options: Seq[String]) { + private def invokeMain(loader: ClassLoader, main: Method, options: Seq[String]): Unit = { val currentThread = Thread.currentThread val oldLoader = Thread.currentThread.getContextClassLoader currentThread.setContextClassLoader(loader) diff --git a/run/src/main/scala/sbt/TrapExit.scala b/run/src/main/scala/sbt/TrapExit.scala index a5f981896..8770f7739 100644 --- a/run/src/main/scala/sbt/TrapExit.scala +++ b/run/src/main/scala/sbt/TrapExit.scala @@ -84,14 +84,14 @@ object TrapExit { s"${hex(System.identityHashCode(t))}" /** Waits for the given `thread` to terminate. However, if the thread state is NEW, this method returns immediately. */ - private def waitOnThread(thread: Thread, log: Logger) { + private def waitOnThread(thread: Thread, log: Logger): Unit = { log.debug("Waiting for thread " + thread.getName + " to terminate.") thread.join log.debug("\tThread " + thread.getName + " exited.") } // interrupts the given thread, but first replaces the exception handler so that the InterruptedException is not printed - private def safeInterrupt(thread: Thread, log: Logger) { + private def safeInterrupt(thread: Thread, log: Logger): Unit = { val name = thread.getName log.debug("Interrupting thread " + thread.getName) thread.setUncaughtExceptionHandler(new TrapInterrupt(thread.getUncaughtExceptionHandler)) @@ -100,7 +100,7 @@ object TrapExit { } // an uncaught exception handler that swallows InterruptedExceptions and otherwise defers to originalHandler private final class TrapInterrupt(originalHandler: Thread.UncaughtExceptionHandler) extends Thread.UncaughtExceptionHandler { - def uncaughtException(thread: Thread, e: Throwable) { + def uncaughtException(thread: Thread, e: Throwable): Unit = { withCause[InterruptedException, Unit](e) { interrupted => () } { other => originalHandler.uncaughtException(thread, e) } thread.setUncaughtExceptionHandler(originalHandler) } @@ -187,7 +187,7 @@ private final class TrapExit(delegateManager: SecurityManager) extends SecurityM } // wait for all non-daemon threads to terminate - private[this] def waitForExit(app: App) { + private[this] def waitForExit(app: App): Unit = { var daemonsOnly = true app.processThreads { thread => // check isAlive because calling `join` on a thread that hasn't started returns immediately @@ -244,7 +244,7 @@ private final class TrapExit(delegateManager: SecurityManager) extends SecurityM val exitCode = new ExitCode - def run() { + def run(): Unit = { try execute() catch { case x: Throwable => @@ -282,7 +282,7 @@ private final class TrapExit(delegateManager: SecurityManager) extends SecurityM } /** Registers the logging exception handler on `t`, delegating to the existing handler if it isn't the default. */ - private[this] def setExceptionHandler(t: Thread) { + private[this] def setExceptionHandler(t: Thread): Unit = { val group = t.getThreadGroup val previousHandler = t.getUncaughtExceptionHandler match { case null | `group` | (_: LoggingExceptionHandler) => None @@ -302,7 +302,7 @@ private final class TrapExit(delegateManager: SecurityManager) extends SecurityM cleanup(threads) cleanup(groups) } - private[this] def cleanup(resources: TrieMap[ThreadID, _]) { + private[this] def cleanup(resources: TrieMap[ThreadID, _]): Unit = { val snap = resources.readOnlySnapshot resources.clear() for ((id, _) <- snap) @@ -312,7 +312,7 @@ private final class TrapExit(delegateManager: SecurityManager) extends SecurityM // only want to operate on unterminated threads // want to drop terminated threads, including those that have been gc'd /** Evaluates `f` on each `Thread` started by this [[App]] at single instant shortly after this method is called. */ - def processThreads(f: Thread => Unit) { + def processThreads(f: Thread => Unit): Unit = { // pulls in threads that weren't recorded by checkAccess(Thread) (which is jvm-dependent) // but can be reached via the Threads in the ThreadGroups recorded by checkAccess(ThreadGroup) (not jvm-dependent) addUntrackedThreads() @@ -372,7 +372,7 @@ private final class TrapExit(delegateManager: SecurityManager) extends SecurityM } } - private[this] def stopAllThreads(app: App) { + private[this] def stopAllThreads(app: App): Unit = { // only try to dispose frames if we think the App used AWT // otherwise, we initialize AWT as a side effect of asking for the frames // also, we only assume one AWT application at a time @@ -419,17 +419,17 @@ private final class TrapExit(delegateManager: SecurityManager) extends SecurityM // These are overridden to do nothing because there is a substantial filesystem performance penalty // when there is a SecurityManager defined. The default implementations of these construct a // FilePermission, and its initialization involves canonicalization, which is expensive. - override def checkRead(file: String) {} - override def checkRead(file: String, context: AnyRef) {} - override def checkWrite(file: String) {} - override def checkDelete(file: String) {} - override def checkExec(cmd: String) {} + override def checkRead(file: String): Unit = () + override def checkRead(file: String, context: AnyRef): Unit = () + override def checkWrite(file: String): Unit = () + override def checkDelete(file: String): Unit = () + override def checkExec(cmd: String): Unit = () - override def checkPermission(perm: Permission) { + override def checkPermission(perm: Permission): Unit = { if (delegateManager ne null) delegateManager.checkPermission(perm) } - override def checkPermission(perm: Permission, context: AnyRef) { + override def checkPermission(perm: Permission, context: AnyRef): Unit = { if (delegateManager ne null) delegateManager.checkPermission(perm, context) } @@ -439,7 +439,7 @@ private final class TrapExit(delegateManager: SecurityManager) extends SecurityM * This is not reliably called on different jvm implementations. On openjdk and similar jvms, the Thread constructor * calls setPriority, which triggers this SecurityManager check. For Java 6 on OSX, this is not called, however. */ - override def checkAccess(t: Thread) { + override def checkAccess(t: Thread): Unit = { if (active) { val group = t.getThreadGroup noteAccess(group) { app => @@ -455,7 +455,7 @@ private final class TrapExit(delegateManager: SecurityManager) extends SecurityM * This is specified to be called in every Thread's constructor and every time a ThreadGroup is created. * This allows us to reliably track every ThreadGroup that is created and map it back to the constructing application. */ - override def checkAccess(tg: ThreadGroup) { + override def checkAccess(tg: ThreadGroup): Unit = { if (active && !isSystemGroup(tg)) { noteAccess(tg) { app => app.register(tg) @@ -476,7 +476,7 @@ private final class TrapExit(delegateManager: SecurityManager) extends SecurityM /** `true` if there is at least one application currently being managed. */ private[this] def active = running.get > 0 - private def disposeAllFrames(log: Logger) { + private def disposeAllFrames(log: Logger): Unit = { val allFrames = java.awt.Frame.getFrames if (allFrames.nonEmpty) { log.debug(s"Disposing ${allFrames.length} top-level windows...") @@ -512,7 +512,7 @@ private final class ExitCode { * It logs the thread and the exception. */ private final class LoggingExceptionHandler(log: Logger, delegate: Option[Thread.UncaughtExceptionHandler]) extends Thread.UncaughtExceptionHandler { - def uncaughtException(t: Thread, e: Throwable) { + def uncaughtException(t: Thread, e: Throwable): Unit = { log.error("(" + t.getName + ") " + e.toString) log.trace(e) delegate.foreach(_.uncaughtException(t, e)) diff --git a/run/src/main/scala/sbt/TrapExitSecurityException.scala b/run/src/main/scala/sbt/TrapExitSecurityException.scala index 5934bbf2e..50bdab303 100644 --- a/run/src/main/scala/sbt/TrapExitSecurityException.scala +++ b/run/src/main/scala/sbt/TrapExitSecurityException.scala @@ -7,7 +7,7 @@ package sbt */ private final class TrapExitSecurityException(val exitCode: Int) extends SecurityException { private var accessAllowed = false - def allowAccess() { + def allowAccess(): Unit = { accessAllowed = true } override def printStackTrace = ifAccessAllowed(super.printStackTrace) diff --git a/sbt/src/sbt-test/actions/update-state-fail/project/Build.scala b/sbt/src/sbt-test/actions/update-state-fail/project/Build.scala index 7c61e9a24..cb1845874 100644 --- a/sbt/src/sbt-test/actions/update-state-fail/project/Build.scala +++ b/sbt/src/sbt-test/actions/update-state-fail/project/Build.scala @@ -14,7 +14,7 @@ object TestBuild extends Build lazy val b = Project("b", file("b")).settings(t <<= Def.task("").updateState(updater)) - def checkState(runs: Int, s: State) { + def checkState(runs: Int, s: State): Unit = { val stored = s.get(akey).getOrElse(0) assert(stored == runs, "Expected " + runs + ", got " + stored) } diff --git a/sbt/src/sbt-test/package/manifest/src/main/scala/jartest/Main.scala b/sbt/src/sbt-test/package/manifest/src/main/scala/jartest/Main.scala index be96a910f..b1c446adc 100644 --- a/sbt/src/sbt-test/package/manifest/src/main/scala/jartest/Main.scala +++ b/sbt/src/sbt-test/package/manifest/src/main/scala/jartest/Main.scala @@ -2,5 +2,5 @@ package jartest object Main { - def main(args: Array[String]) {} -} \ No newline at end of file + def main(args: Array[String]): Unit = () +} diff --git a/sbt/src/sbt-test/project/auto-plugins/build.sbt b/sbt/src/sbt-test/project/auto-plugins/build.sbt index d8dc8d0db..8038f2a06 100644 --- a/sbt/src/sbt-test/project/auto-plugins/build.sbt +++ b/sbt/src/sbt-test/project/auto-plugins/build.sbt @@ -47,7 +47,7 @@ check := { val adel = (del in projA).?.value // should be None same(adel, None, "del in projA") val bdel = (del in projB).?.value // should be None - same(bdel, None, "del in projB") + same(bdel, None, "del in projB") val ddel = (del in projD).?.value // should be None same(ddel, None, "del in projD") // @@ -78,6 +78,6 @@ keyTest := "foo" topLevelKeyTest := "bar" -def same[T](actual: T, expected: T, label: String) { +def same[T](actual: T, expected: T, label: String): Unit = { assert(actual == expected, s"Expected '$expected' for `$label`, got '$actual'") } diff --git a/sbt/src/sbt-test/project/derived/build.sbt b/sbt/src/sbt-test/project/derived/build.sbt index defae9b69..21cfc9207 100644 --- a/sbt/src/sbt-test/project/derived/build.sbt +++ b/sbt/src/sbt-test/project/derived/build.sbt @@ -56,7 +56,7 @@ lazy val b = project.settings( // ---------------- Verification -def same[T](x: T, y: T) { +def same[T](x: T, y: T): Unit = { assert(x == y, s"Actual: '$x', Expected: '$y'") } diff --git a/sbt/src/sbt-test/project/flatten/test-src/SimpleTest.scala b/sbt/src/sbt-test/project/flatten/test-src/SimpleTest.scala index 9e8d228cb..7ef0dc97e 100644 --- a/sbt/src/sbt-test/project/flatten/test-src/SimpleTest.scala +++ b/sbt/src/sbt-test/project/flatten/test-src/SimpleTest.scala @@ -5,11 +5,11 @@ class SimpleTest extends Properties("Simple") { property("increment scala") = forAll( (i: Int) => (new a.b.ScalaA).increment(i) == i+1) property("increment java") = forAll( (i: Int) => (new JavaA).inc(i) == i+1) - + property("decrement scala") = forAll( (i: Int) => (new b.ScalaB).decrement(i) == i+1) property("decrement java") = forAll( (i: Int) => (new a.JavaB).dec(i) == i+1) } object MainTest { - def main(args: Array[String]) {} -} \ No newline at end of file + def main(args: Array[String]): Unit = () +} diff --git a/sbt/src/sbt-test/project/global-plugin/changes/Build.scala b/sbt/src/sbt-test/project/global-plugin/changes/Build.scala index 2e1d49e2f..d9c1611d5 100644 --- a/sbt/src/sbt-test/project/global-plugin/changes/Build.scala +++ b/sbt/src/sbt-test/project/global-plugin/changes/Build.scala @@ -12,10 +12,9 @@ object MyBuild extends Build { lazy val check = taskKey[Unit]("Verifies that the junit dependency has the newer version (4.8)") - def checkVersion(report: UpdateReport) { + def checkVersion(report: UpdateReport): Unit = { for(mod <- report.allModules) { if(mod.name == "junit") assert(mod.revision == "4.8", s"JUnit version (${mod.revision}) does not have the correct version") } } } - diff --git a/sbt/src/sbt-test/project/src-scala-binary-version/build.sbt b/sbt/src/sbt-test/project/src-scala-binary-version/build.sbt index 911a1df80..818e3f8e2 100644 --- a/sbt/src/sbt-test/project/src-scala-binary-version/build.sbt +++ b/sbt/src/sbt-test/project/src-scala-binary-version/build.sbt @@ -9,6 +9,6 @@ check := { same(bv, "2.10") } -def same(actual: String, expected: String) { +def same(actual: String, expected: String): Unit = { assert(actual == expected, s"Expected binary version to be $expected, was $actual") } diff --git a/sbt/src/sbt-test/run/awt/A.scala b/sbt/src/sbt-test/run/awt/A.scala index d7eba868b..ad48b8f02 100644 --- a/sbt/src/sbt-test/run/awt/A.scala +++ b/sbt/src/sbt-test/run/awt/A.scala @@ -1,5 +1,5 @@ object O { - def main(argv: Array[String]) { + def main(argv: Array[String]): Unit = { new java.awt.Color(0,0,0) } } diff --git a/sbt/src/sbt-test/run/concurrent/build.sbt b/sbt/src/sbt-test/run/concurrent/build.sbt index c4dd5f78f..415745bff 100644 --- a/sbt/src/sbt-test/run/concurrent/build.sbt +++ b/sbt/src/sbt-test/run/concurrent/build.sbt @@ -27,12 +27,12 @@ concurrentRestrictions in Global := Seq( Tags.limitAll(math.max(EvaluateTask.SystemProcessors, 2) ) ) -def waitForCStart = +def waitForCStart = Def.task { waitFor( (baseDirectory in c).value / "started" ) } -def waitFor(f: File) { +def waitFor(f: File): Unit = { if(!f.exists) { Thread.sleep(300) waitFor(f) diff --git a/sbt/src/sbt-test/run/concurrent/changes/C.scala b/sbt/src/sbt-test/run/concurrent/changes/C.scala index 54af861f6..6154f8303 100644 --- a/sbt/src/sbt-test/run/concurrent/changes/C.scala +++ b/sbt/src/sbt-test/run/concurrent/changes/C.scala @@ -1,7 +1,7 @@ import java.io.File object C { - def main(args: Array[String]) { + def main(args: Array[String]): Unit = { val base = new File(args(0)) create(new File(base, "started")) val bFin = new File(base, "../b/finished") @@ -9,16 +9,16 @@ object C { create(new File(base, "finished")) } - def create(f: File) { + def create(f: File): Unit = { val fabs = f.getAbsoluteFile fabs.getParentFile.mkdirs fabs.createNewFile } - def waitFor(f: File) { + def waitFor(f: File): Unit = { if(!f.exists) { Thread.sleep(300) waitFor(f) } } -} \ No newline at end of file +} diff --git a/sbt/src/sbt-test/run/daemon-exit/src/main/scala/Daemon.scala b/sbt/src/sbt-test/run/daemon-exit/src/main/scala/Daemon.scala index a56d89708..f3cfc310e 100644 --- a/sbt/src/sbt-test/run/daemon-exit/src/main/scala/Daemon.scala +++ b/sbt/src/sbt-test/run/daemon-exit/src/main/scala/Daemon.scala @@ -2,22 +2,19 @@ object DaemonExit { - def main(args: Array[String]) - { + def main(args: Array[String]): Unit = { val t = new Thread { - override def run() { + override def run(): Unit = { Thread.sleep(1000) System.exit(0) } } // t.setDaemon(true) t.start() - + val t2 = new Thread { - override def run() { - synchronized { wait() } - } + override def run(): Unit = synchronized { wait() } } t2.start() } -} \ No newline at end of file +} diff --git a/sbt/src/sbt-test/run/daemon/src/main/scala/Daemon.scala b/sbt/src/sbt-test/run/daemon/src/main/scala/Daemon.scala index a15a0e4cf..5f0563445 100644 --- a/sbt/src/sbt-test/run/daemon/src/main/scala/Daemon.scala +++ b/sbt/src/sbt-test/run/daemon/src/main/scala/Daemon.scala @@ -3,11 +3,9 @@ object Daemon def main(args: Array[String]) { val t = new Thread { - override def run() { - synchronized { wait() } - } + override def run(): Unit = synchronized { wait() } } t.setDaemon(true); t.start } -} \ No newline at end of file +} diff --git a/sbt/src/sbt-test/run/error/changes/RunExplicitFailure.scala b/sbt/src/sbt-test/run/error/changes/RunExplicitFailure.scala index b7e371d60..4e05709d0 100644 --- a/sbt/src/sbt-test/run/error/changes/RunExplicitFailure.scala +++ b/sbt/src/sbt-test/run/error/changes/RunExplicitFailure.scala @@ -1,4 +1,4 @@ object Spawn { - def main(args: Array[String]) { System.exit(1); } -} \ No newline at end of file + def main(args: Array[String]): Unit = System.exit(1) +} diff --git a/sbt/src/sbt-test/run/error/changes/RunExplicitSuccess.scala b/sbt/src/sbt-test/run/error/changes/RunExplicitSuccess.scala index f02b5236c..1765bdfad 100644 --- a/sbt/src/sbt-test/run/error/changes/RunExplicitSuccess.scala +++ b/sbt/src/sbt-test/run/error/changes/RunExplicitSuccess.scala @@ -1,4 +1,4 @@ object Spawn { - def main(args: Array[String]) { System.exit(0); } -} \ No newline at end of file + def main(args: Array[String]): Unit = System.exit(0) +} diff --git a/sbt/src/sbt-test/run/error/changes/RunSuccess.scala b/sbt/src/sbt-test/run/error/changes/RunSuccess.scala index 29ad02cd7..603820b9e 100644 --- a/sbt/src/sbt-test/run/error/changes/RunSuccess.scala +++ b/sbt/src/sbt-test/run/error/changes/RunSuccess.scala @@ -1,4 +1,4 @@ object Spawn { - def main(args: Array[String]) {} -} \ No newline at end of file + def main(args: Array[String]): Unit = () +} diff --git a/sbt/src/sbt-test/run/fork-loader/CheckLoader.scala b/sbt/src/sbt-test/run/fork-loader/CheckLoader.scala index 6bdc95a81..a90d11af2 100644 --- a/sbt/src/sbt-test/run/fork-loader/CheckLoader.scala +++ b/sbt/src/sbt-test/run/fork-loader/CheckLoader.scala @@ -1,8 +1,8 @@ object CheckLoader { - def main(args: Array[String]) { apply() } - def apply() { + def main(args: Array[String]): Unit = apply() + def apply(): Unit = { val loader = getClass.getClassLoader val appLoader = ClassLoader.getSystemClassLoader assert(loader eq appLoader, "Application classes not loaded in the system class loader") } -} \ No newline at end of file +} diff --git a/sbt/src/sbt-test/run/fork/src/main/scala/ForkFail.scala b/sbt/src/sbt-test/run/fork/src/main/scala/ForkFail.scala index 2fc9c2b26..847230c81 100644 --- a/sbt/src/sbt-test/run/fork/src/main/scala/ForkFail.scala +++ b/sbt/src/sbt-test/run/fork/src/main/scala/ForkFail.scala @@ -1,5 +1,5 @@ object ForkTest { - def main(args:Array[String]) { + def main(args:Array[String]): Unit = { val name = Option(System.getenv("flag.name")) getOrElse("flag") println("Name: " + name) val cwd = (new java.io.File(name)).getAbsoluteFile diff --git a/sbt/src/sbt-test/run/spawn/src/main/scala/Spawn.scala b/sbt/src/sbt-test/run/spawn/src/main/scala/Spawn.scala index 4845e572b..26085748e 100644 --- a/sbt/src/sbt-test/run/spawn/src/main/scala/Spawn.scala +++ b/sbt/src/sbt-test/run/spawn/src/main/scala/Spawn.scala @@ -5,31 +5,25 @@ object Spawn { - def main(args: Array[String]) - { + def main(args: Array[String]): Unit = { (new ThreadA).start } - class ThreadA extends Thread - { - override def run() - { + + class ThreadA extends Thread { + override def run(): Unit = { sleep() (new ThreadB).start() } } - class ThreadB extends Thread - { - override def run() { sleep() } + class ThreadB extends Thread { + override def run(): Unit = sleep() } - private def sleep() - { + private def sleep(): Unit = { try { Thread.sleep(1000) } - catch - { - case e: InterruptedException => - val msg = "TrapExit improperly interrupted non-daemon thread" - System.err.println(msg) - error(msg) + catch { case e: InterruptedException => + val msg = "TrapExit improperly interrupted non-daemon thread" + System.err.println(msg) + error(msg) } } -} \ No newline at end of file +} diff --git a/sbt/src/sbt-test/source-dependencies/implicit-search/changes/C.scala b/sbt/src/sbt-test/source-dependencies/implicit-search/changes/C.scala index 77091c18c..bdf19dd1d 100644 --- a/sbt/src/sbt-test/source-dependencies/implicit-search/changes/C.scala +++ b/sbt/src/sbt-test/source-dependencies/implicit-search/changes/C.scala @@ -2,6 +2,5 @@ object C { import A._, B._ implicitly[Ordering[Int]] - def main(args: Array[String]) {} + def main(args: Array[String]): Unit = () } - diff --git a/sbt/src/sbt-test/source-dependencies/inherited-dependencies/B.scala b/sbt/src/sbt-test/source-dependencies/inherited-dependencies/B.scala index 9c6fbe046..48082cf78 100644 --- a/sbt/src/sbt-test/source-dependencies/inherited-dependencies/B.scala +++ b/sbt/src/sbt-test/source-dependencies/inherited-dependencies/B.scala @@ -6,14 +6,14 @@ class B { // not public, so this shouldn't be tracked as an inherited dependency private[this] class X extends D with E[Int] - def x(i: Int) { + def x(i: Int): Unit = { // not public, not an inherited dependency trait Y extends D } - def y(j: Int) { + def y(j: Int): Unit = { // not public val w: D { def length: Int } = ??? () } -} \ No newline at end of file +} diff --git a/sbt/src/sbt-test/source-dependencies/inherited-dependencies/build.sbt b/sbt/src/sbt-test/source-dependencies/inherited-dependencies/build.sbt index 806c88b3c..095a01198 100644 --- a/sbt/src/sbt-test/source-dependencies/inherited-dependencies/build.sbt +++ b/sbt/src/sbt-test/source-dependencies/inherited-dependencies/build.sbt @@ -31,6 +31,6 @@ verifyDeps := { same(inheritedDeps("J"), JDeps) } -def same[T](x: T, y: T) { +def same[T](x: T, y: T): Unit = { assert(x == y, s"\nActual: $x, \nExpected: $y") } diff --git a/sbt/src/sbt-test/source-dependencies/inherited-deps-java/build.sbt b/sbt/src/sbt-test/source-dependencies/inherited-deps-java/build.sbt index c2a35d1ed..c25b54921 100644 --- a/sbt/src/sbt-test/source-dependencies/inherited-deps-java/build.sbt +++ b/sbt/src/sbt-test/source-dependencies/inherited-deps-java/build.sbt @@ -25,6 +25,6 @@ lazy val pairs = lazy val expectedDeps = (Relation.empty[File,File] /: pairs) { case (r, (x,ys)) => r + (x,ys) } def toFile(s: String) = file(s + ".java").getAbsoluteFile -def same[T](x: T, y: T) { +def same[T](x: T, y: T): Unit = { assert(x == y, s"\nActual: $x, \nExpected: $y") } diff --git a/sbt/src/sbt-test/source-dependencies/java-mixed/changes/S1.scala b/sbt/src/sbt-test/source-dependencies/java-mixed/changes/S1.scala index 42beb8cd6..486f40262 100644 --- a/sbt/src/sbt-test/source-dependencies/java-mixed/changes/S1.scala +++ b/sbt/src/sbt-test/source-dependencies/java-mixed/changes/S1.scala @@ -1,3 +1,3 @@ class S { - def foo(s:String) { println("I am foo") } + def foo(s:String): Unit = println("I am foo") } diff --git a/sbt/src/sbt-test/source-dependencies/java-mixed/changes/S2.scala b/sbt/src/sbt-test/source-dependencies/java-mixed/changes/S2.scala index 88fd161b7..63bc37d77 100644 --- a/sbt/src/sbt-test/source-dependencies/java-mixed/changes/S2.scala +++ b/sbt/src/sbt-test/source-dependencies/java-mixed/changes/S2.scala @@ -1,3 +1,3 @@ class S { - def foo2(s:String) { println("I am foo") } + def foo2(s:String): Unit = println("I am foo") } diff --git a/sbt/src/sbt-test/source-dependencies/replace-test-a/changes/first.scala b/sbt/src/sbt-test/source-dependencies/replace-test-a/changes/first.scala index d21cd83e2..9e12604c2 100644 --- a/sbt/src/sbt-test/source-dependencies/replace-test-a/changes/first.scala +++ b/sbt/src/sbt-test/source-dependencies/replace-test-a/changes/first.scala @@ -1,4 +1,4 @@ object First { - def main(args: Array[String]) {} -} \ No newline at end of file + def main(args: Array[String]): Unit = () +} diff --git a/sbt/src/sbt-test/source-dependencies/replace-test-a/changes/second.scala b/sbt/src/sbt-test/source-dependencies/replace-test-a/changes/second.scala index e64067f1e..45ce49a65 100644 --- a/sbt/src/sbt-test/source-dependencies/replace-test-a/changes/second.scala +++ b/sbt/src/sbt-test/source-dependencies/replace-test-a/changes/second.scala @@ -1,4 +1,4 @@ object Second { - def main(args: Array[String]) {} -} \ No newline at end of file + def main(args: Array[String]): Unit = () +} diff --git a/sbt/src/sbt-test/source-dependencies/specialized/B.scala b/sbt/src/sbt-test/source-dependencies/specialized/B.scala index f2aa2cd24..387a85019 100644 --- a/sbt/src/sbt-test/source-dependencies/specialized/B.scala +++ b/sbt/src/sbt-test/source-dependencies/specialized/B.scala @@ -1,7 +1,7 @@ object B { - def main(args: Array[String]) { + def main(args: Array[String]): Unit = { val a = new A a.x(3) } -} \ No newline at end of file +} diff --git a/sbt/src/sbt-test/source-dependencies/trait-super/Main.scala b/sbt/src/sbt-test/source-dependencies/trait-super/Main.scala index aed4916b9..37d821d9d 100644 --- a/sbt/src/sbt-test/source-dependencies/trait-super/Main.scala +++ b/sbt/src/sbt-test/source-dependencies/trait-super/Main.scala @@ -2,7 +2,7 @@ class X extends E with C with B object Main { - def main(args: Array[String]) { + def main(args: Array[String]): Unit = { val x = new X val expected = args(0).toInt assert(x.x == expected, "Expected " + expected + ", got " + x.x) diff --git a/sbt/src/sbt-test/tests/arguments/src/test/scala/ArgumentTest.scala b/sbt/src/sbt-test/tests/arguments/src/test/scala/ArgumentTest.scala index 0144fac3a..62a4ef4a0 100644 --- a/sbt/src/sbt-test/tests/arguments/src/test/scala/ArgumentTest.scala +++ b/sbt/src/sbt-test/tests/arguments/src/test/scala/ArgumentTest.scala @@ -4,11 +4,11 @@ import org.scalatest.Tag class ArgumentTest extends FixtureFunSuite{ type FixtureParam = Map[String,Any] - override def withFixture(test: OneArgTest) { + override def withFixture(test: OneArgTest): Unit = { test(test.configMap) } test("1", Tag("test1")){ conf => sys.error("error #1") } test("2", Tag("test2")){ conf => () } test("3", Tag("test3")){ conf => () } test("4", Tag("test4")){ conf => sys.error("error #4") } -} \ No newline at end of file +} diff --git a/sbt/src/sbt-test/tests/do-not-discover/src/main/scala/custom/CustomReporter.scala b/sbt/src/sbt-test/tests/do-not-discover/src/main/scala/custom/CustomReporter.scala index f21595450..d3f20a21b 100644 --- a/sbt/src/sbt-test/tests/do-not-discover/src/main/scala/custom/CustomReporter.scala +++ b/sbt/src/sbt-test/tests/do-not-discover/src/main/scala/custom/CustomReporter.scala @@ -6,9 +6,9 @@ import events._ class CustomReporter extends Reporter { - private def writeFile(filePath: String, content: String) { + private def writeFile(filePath: String, content: String): Unit = { val file = new File(filePath) - val writer = + val writer = if (!file.exists) new FileWriter(new File(filePath)) else @@ -18,7 +18,7 @@ class CustomReporter extends Reporter { writer.close() } - def apply(event: Event) { + def apply(event: Event): Unit = { event match { case SuiteStarting(_, suiteName, _, _, _, _, _, _, _, _) => writeFile("target/SuiteStarting-" + suiteName, suiteName) case SuiteCompleted(_, suiteName, _, _, _, _, _, _, _, _, _) => writeFile("target/SuiteCompleted-" + suiteName, suiteName) @@ -27,4 +27,4 @@ class CustomReporter extends Reporter { case _ => } } -} \ No newline at end of file +} diff --git a/sbt/src/sbt-test/tests/done/src/main/scala/custom/CustomReporter.scala b/sbt/src/sbt-test/tests/done/src/main/scala/custom/CustomReporter.scala index a4d4b7eb9..8fb6dd9f8 100644 --- a/sbt/src/sbt-test/tests/done/src/main/scala/custom/CustomReporter.scala +++ b/sbt/src/sbt-test/tests/done/src/main/scala/custom/CustomReporter.scala @@ -6,9 +6,9 @@ import events._ class CustomReporter extends ResourcefulReporter { - private def writeFile(filePath: String, content: String) { + private def writeFile(filePath: String, content: String): Unit = { val file = new File(filePath) - val writer = + val writer = if (!file.exists) new FileWriter(new File(filePath)) else @@ -18,20 +18,20 @@ class CustomReporter extends ResourcefulReporter { writer.close() } - def apply(event: Event) { + def apply(event: Event): Unit = { event match { case runCompleted: RunCompleted => writeFile("target/RunCompleted", "RunCompleted") case _ => } } - - def dispose() { + + def dispose(): Unit = { val file = new File("target/dispose") - val filePath = + val filePath = if (file.exists) "target/dispose2" else "target/dispose" writeFile(filePath, "dispose") } -} \ No newline at end of file +} diff --git a/sbt/src/sbt-test/tests/fork-parallel/src/test/scala/tests.scala b/sbt/src/sbt-test/tests/fork-parallel/src/test/scala/tests.scala index 4ebd2ff25..fd52c63c6 100644 --- a/sbt/src/sbt-test/tests/fork-parallel/src/test/scala/tests.scala +++ b/sbt/src/sbt-test/tests/fork-parallel/src/test/scala/tests.scala @@ -19,7 +19,7 @@ object ParallelTest { } @tailrec - def execute(f : => Unit) { + def execute(f : => Unit): Unit = { val nb = nbConcurrentTests.incrementAndGet() val max = maxConcurrentTests.get() if( nb <= max || updateMaxConcurrentTests(max, nb)) { @@ -34,20 +34,20 @@ object ParallelTest { class Test1 { @Test - def slow() { ParallelTest.execute { Thread.sleep(1000) } } + def slow(): Unit = ParallelTest.execute { Thread.sleep(1000) } } class Test2 { @Test - def slow() { ParallelTest.execute { Thread.sleep(1000) } } + def slow(): Unit = ParallelTest.execute { Thread.sleep(1000) } } class Test3 { @Test - def slow() { ParallelTest.execute { Thread.sleep(1000) } } + def slow(): Unit = ParallelTest.execute { Thread.sleep(1000) } } class Test4 { @Test - def slow() { ParallelTest.execute { Thread.sleep(1000) } } -} \ No newline at end of file + def slow(): Unit = ParallelTest.execute { Thread.sleep(1000) } +} diff --git a/sbt/src/sbt-test/tests/junit-xml-report/src/test/scala/tests.scala b/sbt/src/sbt-test/tests/junit-xml-report/src/test/scala/tests.scala index 38c636456..e2843e233 100644 --- a/sbt/src/sbt-test/tests/junit-xml-report/src/test/scala/tests.scala +++ b/sbt/src/sbt-test/tests/junit-xml-report/src/test/scala/tests.scala @@ -3,7 +3,7 @@ import org.junit.Test package a.pkg { class OneSecondTest { @Test - def oneSecond() { + def oneSecond(): Unit = { Thread.sleep(1000) } } @@ -12,13 +12,13 @@ package a.pkg { package another.pkg { class FailingTest { @Test - def failure1_OneSecond() { + def failure1_OneSecond(): Unit = { Thread.sleep(1000) sys.error("fail1") } @Test - def failure2_HalfSecond() { + def failure2_HalfSecond(): Unit = { Thread.sleep(500) sys.error("fail2") } @@ -30,20 +30,19 @@ package console.test.pkg { // until SBT supports that class ConsoleTests { @Test - def sayHello() { + def sayHello(): Unit = { println("Hello") System.out.println("World!") } @Test - def multiThreadedHello() { + def multiThreadedHello(): Unit = { for( i <- 1 to 5 ) { new Thread("t-" + i) { - override def run() { + override def run(): Unit = println("Hello from thread " + i) - } }.start() } } } -} \ No newline at end of file +} diff --git a/sbt/src/sbt-test/tests/junit/changes/Failure.scala b/sbt/src/sbt-test/tests/junit/changes/Failure.scala index 7babb39b6..b6318b16f 100644 --- a/sbt/src/sbt-test/tests/junit/changes/Failure.scala +++ b/sbt/src/sbt-test/tests/junit/changes/Failure.scala @@ -4,5 +4,5 @@ import org.junit._ class Failure { - @Test def fail() { sys.error("Fail!") } + @Test def fail(): Unit = sys.error("Fail!") } diff --git a/sbt/src/sbt-test/tests/junit/changes/Success.scala b/sbt/src/sbt-test/tests/junit/changes/Success.scala index e8a088f92..851dbc9e8 100644 --- a/sbt/src/sbt-test/tests/junit/changes/Success.scala +++ b/sbt/src/sbt-test/tests/junit/changes/Success.scala @@ -4,5 +4,5 @@ import org.junit._ class Success { - @Test def succeed() { } + @Test def succeed(): Unit = () } diff --git a/sbt/src/sbt-test/tests/nested-inproc-par/src/main/scala/custom/CustomReporter.scala b/sbt/src/sbt-test/tests/nested-inproc-par/src/main/scala/custom/CustomReporter.scala index f21595450..d3f20a21b 100644 --- a/sbt/src/sbt-test/tests/nested-inproc-par/src/main/scala/custom/CustomReporter.scala +++ b/sbt/src/sbt-test/tests/nested-inproc-par/src/main/scala/custom/CustomReporter.scala @@ -6,9 +6,9 @@ import events._ class CustomReporter extends Reporter { - private def writeFile(filePath: String, content: String) { + private def writeFile(filePath: String, content: String): Unit = { val file = new File(filePath) - val writer = + val writer = if (!file.exists) new FileWriter(new File(filePath)) else @@ -18,7 +18,7 @@ class CustomReporter extends Reporter { writer.close() } - def apply(event: Event) { + def apply(event: Event): Unit = { event match { case SuiteStarting(_, suiteName, _, _, _, _, _, _, _, _) => writeFile("target/SuiteStarting-" + suiteName, suiteName) case SuiteCompleted(_, suiteName, _, _, _, _, _, _, _, _, _) => writeFile("target/SuiteCompleted-" + suiteName, suiteName) @@ -27,4 +27,4 @@ class CustomReporter extends Reporter { case _ => } } -} \ No newline at end of file +} diff --git a/sbt/src/sbt-test/tests/nested-inproc-seq/src/main/scala/custom/CustomReporter.scala b/sbt/src/sbt-test/tests/nested-inproc-seq/src/main/scala/custom/CustomReporter.scala index f21595450..d3f20a21b 100644 --- a/sbt/src/sbt-test/tests/nested-inproc-seq/src/main/scala/custom/CustomReporter.scala +++ b/sbt/src/sbt-test/tests/nested-inproc-seq/src/main/scala/custom/CustomReporter.scala @@ -6,9 +6,9 @@ import events._ class CustomReporter extends Reporter { - private def writeFile(filePath: String, content: String) { + private def writeFile(filePath: String, content: String): Unit = { val file = new File(filePath) - val writer = + val writer = if (!file.exists) new FileWriter(new File(filePath)) else @@ -18,7 +18,7 @@ class CustomReporter extends Reporter { writer.close() } - def apply(event: Event) { + def apply(event: Event): Unit = { event match { case SuiteStarting(_, suiteName, _, _, _, _, _, _, _, _) => writeFile("target/SuiteStarting-" + suiteName, suiteName) case SuiteCompleted(_, suiteName, _, _, _, _, _, _, _, _, _) => writeFile("target/SuiteCompleted-" + suiteName, suiteName) @@ -27,4 +27,4 @@ class CustomReporter extends Reporter { case _ => } } -} \ No newline at end of file +} diff --git a/sbt/src/sbt-test/tests/nested-subproc/src/main/scala/custom/CustomReporter.scala b/sbt/src/sbt-test/tests/nested-subproc/src/main/scala/custom/CustomReporter.scala index f21595450..d3f20a21b 100644 --- a/sbt/src/sbt-test/tests/nested-subproc/src/main/scala/custom/CustomReporter.scala +++ b/sbt/src/sbt-test/tests/nested-subproc/src/main/scala/custom/CustomReporter.scala @@ -6,9 +6,9 @@ import events._ class CustomReporter extends Reporter { - private def writeFile(filePath: String, content: String) { + private def writeFile(filePath: String, content: String): Unit = { val file = new File(filePath) - val writer = + val writer = if (!file.exists) new FileWriter(new File(filePath)) else @@ -18,7 +18,7 @@ class CustomReporter extends Reporter { writer.close() } - def apply(event: Event) { + def apply(event: Event): Unit = { event match { case SuiteStarting(_, suiteName, _, _, _, _, _, _, _, _) => writeFile("target/SuiteStarting-" + suiteName, suiteName) case SuiteCompleted(_, suiteName, _, _, _, _, _, _, _, _, _) => writeFile("target/SuiteCompleted-" + suiteName, suiteName) @@ -27,4 +27,4 @@ class CustomReporter extends Reporter { case _ => } } -} \ No newline at end of file +} diff --git a/sbt/src/sbt-test/tests/single-runner/src/main/scala/custom/CustomReporter.scala b/sbt/src/sbt-test/tests/single-runner/src/main/scala/custom/CustomReporter.scala index 39c7085ac..986224439 100644 --- a/sbt/src/sbt-test/tests/single-runner/src/main/scala/custom/CustomReporter.scala +++ b/sbt/src/sbt-test/tests/single-runner/src/main/scala/custom/CustomReporter.scala @@ -6,9 +6,9 @@ import events._ class CustomReporter extends Reporter { - private def writeFile(filePath: String, content: String) { + private def writeFile(filePath: String, content: String): Unit = { val file = new File(filePath) - val writer = + val writer = if (!file.exists) new FileWriter(new File(filePath)) else @@ -18,10 +18,10 @@ class CustomReporter extends Reporter { writer.close() } - def apply(event: Event) { + def apply(event: Event): Unit = { event match { case runStarting: RunStarting => writeFile("target/RunStarting", "RunStarting") case _ => } } -} \ No newline at end of file +} diff --git a/sbt/src/sbt-test/tests/t543/project/Ticket543Test.scala b/sbt/src/sbt-test/tests/t543/project/Ticket543Test.scala index 2f5a9ba70..c477d05a6 100755 --- a/sbt/src/sbt-test/tests/t543/project/Ticket543Test.scala +++ b/sbt/src/sbt-test/tests/t543/project/Ticket543Test.scala @@ -13,7 +13,7 @@ object Ticket543Test extends Build { scalaVersion := "2.9.2", fork := true, testListeners += new TestReportListener { - def testEvent(event: TestEvent) { + def testEvent(event: TestEvent): Unit = { for (e <- event.detail.filter(_.status == sbt.testing.Status.Failure)) { if (e.throwable != null && e.throwable.isDefined) { val caw = new CharArrayWriter @@ -23,9 +23,9 @@ object Ticket543Test extends Build { } } } - def startGroup(name: String) {} - def endGroup(name: String, t: Throwable) {} - def endGroup(name: String, result: TestResult.Value) {} + def startGroup(name: String): Unit = () + def endGroup(name: String, t: Throwable): Unit = () + def endGroup(name: String, result: TestResult.Value): Unit = () }, check := { val exists = marker.exists diff --git a/sbt/src/sbt-test/tests/task/src/main/scala/custom/CustomReporter.scala b/sbt/src/sbt-test/tests/task/src/main/scala/custom/CustomReporter.scala index f21595450..d3f20a21b 100644 --- a/sbt/src/sbt-test/tests/task/src/main/scala/custom/CustomReporter.scala +++ b/sbt/src/sbt-test/tests/task/src/main/scala/custom/CustomReporter.scala @@ -6,9 +6,9 @@ import events._ class CustomReporter extends Reporter { - private def writeFile(filePath: String, content: String) { + private def writeFile(filePath: String, content: String): Unit = { val file = new File(filePath) - val writer = + val writer = if (!file.exists) new FileWriter(new File(filePath)) else @@ -18,7 +18,7 @@ class CustomReporter extends Reporter { writer.close() } - def apply(event: Event) { + def apply(event: Event): Unit = { event match { case SuiteStarting(_, suiteName, _, _, _, _, _, _, _, _) => writeFile("target/SuiteStarting-" + suiteName, suiteName) case SuiteCompleted(_, suiteName, _, _, _, _, _, _, _, _, _) => writeFile("target/SuiteCompleted-" + suiteName, suiteName) @@ -27,4 +27,4 @@ class CustomReporter extends Reporter { case _ => } } -} \ No newline at end of file +} diff --git a/sbt/src/sbt-test/tests/test-quick/src/main/scala/B.scala b/sbt/src/sbt-test/tests/test-quick/src/main/scala/B.scala index 4f4c91fcf..d70ab8e3f 100755 --- a/sbt/src/sbt-test/tests/test-quick/src/main/scala/B.scala +++ b/sbt/src/sbt-test/tests/test-quick/src/main/scala/B.scala @@ -1,4 +1,4 @@ class B { def foo = 1 - def bar(a: A) {} + def bar(a: A): Unit = () } diff --git a/scripted/base/src/main/scala/xsbt/test/FileCommands.scala b/scripted/base/src/main/scala/xsbt/test/FileCommands.scala index e3af22cce..693cb9a7e 100644 --- a/scripted/base/src/main/scala/xsbt/test/FileCommands.scala +++ b/scripted/base/src/main/scala/xsbt/test/FileCommands.scala @@ -58,18 +58,18 @@ class FileCommands(baseDirectory: File) extends BasicStatementHandler { scriptError(s"$pathA is not newer than $pathB") } } - def exists(paths: List[String]) { + def exists(paths: List[String]): Unit = { val notPresent = fromStrings(paths).filter(!_.exists) if (notPresent.nonEmpty) scriptError("File(s) did not exist: " + notPresent.mkString("[ ", " , ", " ]")) } - def absent(paths: List[String]) { + def absent(paths: List[String]): Unit = { val present = fromStrings(paths).filter(_.exists) if (present.nonEmpty) scriptError("File(s) existed: " + present.mkString("[ ", " , ", " ]")) } def execute(command: List[String]): Unit = execute0(command.head, command.tail) - def execute0(command: String, args: List[String]) { + def execute0(command: String, args: List[String]): Unit = { if (command.trim.isEmpty) scriptError("Command was empty.") else { diff --git a/scripted/base/src/main/scala/xsbt/test/ScriptRunner.scala b/scripted/base/src/main/scala/xsbt/test/ScriptRunner.scala index fc180773a..f03ffcc44 100644 --- a/scripted/base/src/main/scala/xsbt/test/ScriptRunner.scala +++ b/scripted/base/src/main/scala/xsbt/test/ScriptRunner.scala @@ -8,9 +8,9 @@ final class TestException(statement: Statement, msg: String, exception: Throwabl class ScriptRunner { import scala.collection.mutable.HashMap - def apply(statements: List[(StatementHandler, Statement)]) { + def apply(statements: List[(StatementHandler, Statement)]): Unit = { val states = new HashMap[StatementHandler, Any] - def processStatement(handler: StatementHandler, statement: Statement) { + def processStatement(handler: StatementHandler, statement: Statement): Unit = { val state = states(handler).asInstanceOf[handler.State] val nextState = try { Right(handler(statement.command, statement.arguments, state)) } @@ -43,4 +43,4 @@ class ScriptRunner { } } } -} \ No newline at end of file +} diff --git a/scripted/sbt/src/main/scala/sbt/test/ScriptedTests.scala b/scripted/sbt/src/main/scala/sbt/test/ScriptedTests.scala index de9983068..6e5dc8f38 100644 --- a/scripted/sbt/src/main/scala/sbt/test/ScriptedTests.scala +++ b/scripted/sbt/src/main/scala/sbt/test/ScriptedTests.scala @@ -72,7 +72,7 @@ final class ScriptedTests(resourceBaseDirectory: File, bufferLog: Boolean, launc val parser = createParser() run(parser.parse(file)) } - def testFailed() { + def testFailed(): Unit = { if (pending) buffered.clear() else buffered.stop() buffered.error("x " + label + pendingString) } @@ -98,7 +98,7 @@ final class ScriptedTests(resourceBaseDirectory: File, bufferLog: Boolean, launc object ScriptedTests extends ScriptedRunner { val emptyCallback: File => Unit = { _ => () } - def main(args: Array[String]) { + def main(args: Array[String]): Unit = { val directory = new File(args(0)) val buffer = args(1).toBoolean val sbtVersion = args(2) @@ -145,7 +145,7 @@ class ScriptedRunner { } runAll(allTests) } - def runAll(tests: Seq[() => Option[String]]) { + def runAll(tests: Seq[() => Option[String]]): Unit = { val errors = for (test <- tests; err <- test()) yield err if (errors.nonEmpty) sys.error(errors.mkString("Failed tests:\n\t", "\n\t", "\n")) diff --git a/tasks/src/main/scala/sbt/Execute.scala b/tasks/src/main/scala/sbt/Execute.scala index f8419cf9c..b2799ea8e 100644 --- a/tasks/src/main/scala/sbt/Execute.scala +++ b/tasks/src/main/scala/sbt/Execute.scala @@ -15,7 +15,7 @@ private[sbt] object Execute { def idMap[A, B]: Map[A, B] = JavaConversions.mapAsScalaMap(new java.util.IdentityHashMap[A, B]) def pMap[A[_], B[_]]: PMap[A, B] = new DelegatingPMap[A, B](idMap) private[sbt] def completed(p: => Unit): Completed = new Completed { - def process() { p } + def process(): Unit = p } def noTriggers[A[_]] = new Triggers[A](Map.empty, Map.empty, idFun) @@ -70,8 +70,8 @@ private[sbt] final class Execute[A[_] <: AnyRef](config: Config, triggers: Trigg finalResults } - def processAll()(implicit strategy: Strategy) { - @tailrec def next() { + def processAll()(implicit strategy: Strategy): Unit = { + @tailrec def next(): Unit = { pre { assert(reverse.nonEmpty, "Nothing to process.") if (!state.values.exists(_ == Running)) { @@ -92,7 +92,7 @@ private[sbt] final class Execute[A[_] <: AnyRef](config: Config, triggers: Trigg } def dumpCalling: String = state.filter(_._2 == Calling).mkString("\n\t") - def call[T](node: A[T], target: A[T])(implicit strategy: Strategy) { + def call[T](node: A[T], target: A[T])(implicit strategy: Strategy): Unit = { if (config.checkCycles) cycleCheck(node, target) pre { assert(running(node)) @@ -118,7 +118,7 @@ private[sbt] final class Execute[A[_] <: AnyRef](config: Config, triggers: Trigg } } - def retire[T](node: A[T], result: Result[T])(implicit strategy: Strategy) { + def retire[T](node: A[T], result: Result[T])(implicit strategy: Strategy): Unit = { pre { assert(running(node) | calling(node)) readyInv(node) @@ -146,7 +146,7 @@ private[sbt] final class Execute[A[_] <: AnyRef](config: Config, triggers: Trigg case Inc(i) => Inc(Incomplete(Some(node), tpe = i.tpe, causes = i :: Nil)) } - def notifyDone(node: A[_], dependent: A[_])(implicit strategy: Strategy) { + def notifyDone(node: A[_], dependent: A[_])(implicit strategy: Strategy): Unit = { val f = forward(dependent) f -= node if (f.isEmpty) { @@ -159,7 +159,7 @@ private[sbt] final class Execute[A[_] <: AnyRef](config: Config, triggers: Trigg * Once added, a node is pending until its inputs and dependencies have completed. * Its computation is then evaluated and made available for nodes that have it as an input. */ - def addChecked[T](node: A[T])(implicit strategy: Strategy) { + def addChecked[T](node: A[T])(implicit strategy: Strategy): Unit = { if (!added(node)) addNew(node) post { addedInv(node) } @@ -169,7 +169,7 @@ private[sbt] final class Execute[A[_] <: AnyRef](config: Config, triggers: Trigg * If all of the node's dependencies have finished, the node's computation is scheduled to run. * The node's dependencies will be added (transitively) if they are not already registered. */ - def addNew[T](node: A[T])(implicit strategy: Strategy) { + def addNew[T](node: A[T])(implicit strategy: Strategy): Unit = { pre { newPre(node) } val v = register(node) @@ -195,7 +195,7 @@ private[sbt] final class Execute[A[_] <: AnyRef](config: Config, triggers: Trigg } } /** Called when a pending 'node' becomes runnable. All of its dependencies must be done. This schedules the node's computation with 'strategy'.*/ - def ready[T](node: A[T])(implicit strategy: Strategy) { + def ready[T](node: A[T])(implicit strategy: Strategy): Unit = { pre { assert(pending(node)) readyInv(node) @@ -220,7 +220,7 @@ private[sbt] final class Execute[A[_] <: AnyRef](config: Config, triggers: Trigg viewCache.getOrUpdate(node, view(node)) } /** Send the work for this node to the provided Strategy. */ - def submit[T](node: A[T])(implicit strategy: Strategy) { + def submit[T](node: A[T])(implicit strategy: Strategy): Unit = { val v = viewCache(node) val rs = v.alist.transform(v.in, getResult) strategy.submit(node, () => work(node, v.work(rs))) @@ -267,12 +267,12 @@ private[sbt] final class Execute[A[_] <: AnyRef](config: Config, triggers: Trigg // Contracts def addedInv(node: A[_]): Unit = topologicalSort(node) foreach addedCheck - def addedCheck(node: A[_]) { + def addedCheck(node: A[_]): Unit = { assert(added(node), "Not added: " + node) assert(viewCache contains node, "Not in view cache: " + node) dependencyCheck(node) } - def dependencyCheck(node: A[_]) { + def dependencyCheck(node: A[_]): Unit = { dependencies(node) foreach { dep => def onOpt[T](o: Option[T])(f: T => Boolean) = o match { case None => false; case Some(x) => f(x) } def checkForward = onOpt(forward.get(node)) { _ contains dep } @@ -280,15 +280,15 @@ private[sbt] final class Execute[A[_] <: AnyRef](config: Config, triggers: Trigg assert(done(dep) ^ (checkForward && checkReverse)) } } - def pendingInv(node: A[_]) { + def pendingInv(node: A[_]): Unit = { assert(atState(node, Pending)) assert((dependencies(node) ++ runBefore(node)) exists notDone) } - def runningInv(node: A[_]) { + def runningInv(node: A[_]): Unit = { assert(dependencies(node) forall done) assert(!(forward contains node)) } - def newPre(node: A[_]) { + def newPre(node: A[_]): Unit = { isNew(node) assert(!(reverse contains node)) assert(!(forward contains node)) @@ -308,7 +308,7 @@ private[sbt] final class Execute[A[_] <: AnyRef](config: Config, triggers: Trigg visit(node).reverse } - def readyInv(node: A[_]) { + def readyInv(node: A[_]): Unit = { assert(dependencies(node) forall done) assert(!(forward contains node)) } @@ -319,7 +319,7 @@ private[sbt] final class Execute[A[_] <: AnyRef](config: Config, triggers: Trigg for ((called: A[c], callers) <- callers.toSeq; caller <- callers) cycleCheck(caller.asInstanceOf[A[c]], called) - def cycleCheck[T](node: A[T], target: A[T]) { + def cycleCheck[T](node: A[T], target: A[T]): Unit = { if (node eq target) cyclic(node, target, "Cannot call self") val all = IDSet.create[A[T]] def allCallers(n: A[T]): Unit = (all process n)(()) { callers.get(n).toList.flatten.foreach(allCallers) } diff --git a/tasks/src/main/scala/sbt/Incomplete.scala b/tasks/src/main/scala/sbt/Incomplete.scala index 955b7fac4..ee95ec2e8 100644 --- a/tasks/src/main/scala/sbt/Incomplete.scala +++ b/tasks/src/main/scala/sbt/Incomplete.scala @@ -35,7 +35,7 @@ object Incomplete extends Enumeration { visit(i) } - def visitAll(i: Incomplete)(f: Incomplete => Unit) { + def visitAll(i: Incomplete)(f: Incomplete => Unit): Unit = { val visited = IDSet.create[Incomplete] def visit(inc: Incomplete): Unit = visited.process(inc)(()) { @@ -59,4 +59,4 @@ object Incomplete extends Enumeration { exceptions.all } def show(tpe: Value) = tpe match { case Skipped => "skipped"; case Error => "error" } -} \ No newline at end of file +} diff --git a/tasks/standard/src/main/scala/sbt/std/Streams.scala b/tasks/standard/src/main/scala/sbt/std/Streams.scala index d88564ea7..d3f98ee44 100644 --- a/tasks/standard/src/main/scala/sbt/std/Streams.scala +++ b/tasks/standard/src/main/scala/sbt/std/Streams.scala @@ -133,7 +133,7 @@ object Streams { } def key: Key = a - def open() {} + def open(): Unit = () def isClosed: Boolean = synchronized { closed } def close(): Unit = synchronized { @@ -147,4 +147,4 @@ object Streams { } } } -} \ No newline at end of file +} diff --git a/tasks/standard/src/main/scala/sbt/std/System.scala b/tasks/standard/src/main/scala/sbt/std/System.scala index 0bd6484a6..65d93d30d 100644 --- a/tasks/standard/src/main/scala/sbt/std/System.scala +++ b/tasks/standard/src/main/scala/sbt/std/System.scala @@ -22,7 +22,7 @@ object Transform { def dummyMap(dummyMap: DummyTaskMap): Task ~>| Task = { val pmap = new DelegatingPMap[Task, Task](new collection.mutable.ListMap) - def add[T](dummy: TaskAndValue[T]) { pmap(dummy.task) = fromDummyStrict(dummy.task, dummy.value) } + def add[T](dummy: TaskAndValue[T]): Unit = { pmap(dummy.task) = fromDummyStrict(dummy.task, dummy.value) } dummyMap.mappings.foreach(x => add(x)) pmap } @@ -62,4 +62,4 @@ object Transform { val alist = a def work(results: K[Result]) = f(results) } -} \ No newline at end of file +} diff --git a/tasks/standard/src/test/scala/TaskRunnerFork.scala b/tasks/standard/src/test/scala/TaskRunnerFork.scala index 45b661dc0..0f7ac344a 100644 --- a/tasks/standard/src/test/scala/TaskRunnerFork.scala +++ b/tasks/standard/src/test/scala/TaskRunnerFork.scala @@ -22,7 +22,7 @@ object TaskRunnerForkTest extends Properties("TaskRunner Fork") { runDoubleJoin(abs(a), abs(b), workers) true } - def runDoubleJoin(a: Int, b: Int, workers: Int) { + def runDoubleJoin(a: Int, b: Int, workers: Int): Unit = { def inner(i: Int) = List.range(0, b).map(j => task(j).named(j.toString)).join tryRun(List.range(0, a).map(inner).join, false, workers) } diff --git a/tasks/standard/src/test/scala/Test.scala b/tasks/standard/src/test/scala/Test.scala index 57e15e8b7..b1ace1d56 100644 --- a/tasks/standard/src/test/scala/Test.scala +++ b/tasks/standard/src/test/scala/Test.scala @@ -41,7 +41,7 @@ object Test extends std.TaskExtra { def d4(i: Int): Task[Int] = nop flatMap { _ => val x = math.random; if (x < 0.01) task(i); else d4(i + 1) } - def go() { + def go(): Unit = { def run[T](root: Task[T]) = println("Result : " + TaskGen.run(root, true, 2)) @@ -55,4 +55,4 @@ object Test extends std.TaskExtra { run(h1) run(h2) } -} \ No newline at end of file +} diff --git a/testing/src/main/scala/sbt/JUnitXmlTestsListener.scala b/testing/src/main/scala/sbt/JUnitXmlTestsListener.scala index 2b3d48334..8c5e48ab7 100644 --- a/testing/src/main/scala/sbt/JUnitXmlTestsListener.scala +++ b/testing/src/main/scala/sbt/JUnitXmlTestsListener.scala @@ -110,7 +110,7 @@ class JUnitXmlTestsListener(val outputDir: String) extends TestsListener { /** * Starts a new, initially empty Suite with the given name. */ - override def startGroup(name: String) { testSuite.value_=(new TestSuite(name)) } + override def startGroup(name: String): Unit = testSuite.value_=(new TestSuite(name)) /** * Adds all details for the given even to the current suite. diff --git a/testing/src/main/scala/sbt/TestFramework.scala b/testing/src/main/scala/sbt/TestFramework.scala index e31b22fdd..a3813ab9c 100644 --- a/testing/src/main/scala/sbt/TestFramework.scala +++ b/testing/src/main/scala/sbt/TestFramework.scala @@ -70,7 +70,7 @@ final class TestRunner(delegate: Runner, listeners: Seq[TestReportListener], log { // here we get the results! here is where we'd pass in the event listener val results = new scala.collection.mutable.ListBuffer[Event] - val handler = new EventHandler { def handle(e: Event) { results += e } } + val handler = new EventHandler { def handle(e: Event): Unit = { results += e } } val loggers = listeners.flatMap(_.contentLogger(testDefinition)) val nestedTasks = try testTask.execute(handler, loggers.map(_.log).toArray) @@ -145,7 +145,7 @@ object TestFramework { { import scala.collection.mutable.{ HashMap, HashSet, Set } val map = new HashMap[Framework, Set[TestDefinition]] - def assignTest(test: TestDefinition) { + def assignTest(test: TestDefinition): Unit = { def isTestForFramework(framework: Framework) = getFingerprints(framework).exists { t => matches(t, test.fingerprint) } for (framework <- frameworks.find(isTestForFramework)) map.getOrElseUpdate(framework, new HashSet[TestDefinition]) += test diff --git a/testing/src/main/scala/sbt/TestReportListener.scala b/testing/src/main/scala/sbt/TestReportListener.scala index d0d1d9562..53a015803 100644 --- a/testing/src/main/scala/sbt/TestReportListener.scala +++ b/testing/src/main/scala/sbt/TestReportListener.scala @@ -120,15 +120,15 @@ final class ContentLogger(val log: TLogger, val flush: () => Unit) class TestLogger(val logging: TestLogging) extends TestsListener { import logging.{ global => log, logTest } - def startGroup(name: String) {} - def testEvent(event: TestEvent): Unit = {} - def endGroup(name: String, t: Throwable) { + def startGroup(name: String): Unit = () + def testEvent(event: TestEvent): Unit = () + def endGroup(name: String, t: Throwable): Unit = { log.trace(t) log.error("Could not run test " + name + ": " + t.toString) } - def endGroup(name: String, result: TestResult.Value) {} - def doInit {} + def endGroup(name: String, result: TestResult.Value): Unit = () + def doInit: Unit = () /** called once, at end of test group. */ - def doComplete(finalResult: TestResult.Value): Unit = {} + def doComplete(finalResult: TestResult.Value): Unit = () override def contentLogger(test: TestDefinition): Option[ContentLogger] = Some(logTest(test)) } diff --git a/testing/src/main/scala/sbt/TestStatusReporter.scala b/testing/src/main/scala/sbt/TestStatusReporter.scala index 2e335f97f..e74b69fc9 100644 --- a/testing/src/main/scala/sbt/TestStatusReporter.scala +++ b/testing/src/main/scala/sbt/TestStatusReporter.scala @@ -12,14 +12,14 @@ private[sbt] class TestStatusReporter(f: File) extends TestsListener { private lazy val succeeded = TestStatus.read(f) def doInit {} - def startGroup(name: String) { succeeded remove name } - def testEvent(event: TestEvent) {} - def endGroup(name: String, t: Throwable) {} - def endGroup(name: String, result: TestResult.Value) { + def startGroup(name: String): Unit = { succeeded remove name } + def testEvent(event: TestEvent): Unit = () + def endGroup(name: String, t: Throwable): Unit = () + def endGroup(name: String, result: TestResult.Value): Unit = { if (result == TestResult.Passed) succeeded(name) = System.currentTimeMillis } - def doComplete(finalResult: TestResult.Value) { + def doComplete(finalResult: TestResult.Value): Unit = { TestStatus.write(succeeded, "Successful Tests", f) } } @@ -33,7 +33,7 @@ private[sbt] object TestStatus { IO.load(properties, f) properties map { case (k, v) => (k, v.toLong) } } - def write(map: Map[String, Long], label: String, f: File) { + def write(map: Map[String, Long], label: String, f: File): Unit = { val properties = new Properties for ((test, lastSuccessTime) <- map) properties.setProperty(test, lastSuccessTime.toString) diff --git a/util/appmacro/src/main/scala/sbt/appmacro/ContextUtil.scala b/util/appmacro/src/main/scala/sbt/appmacro/ContextUtil.scala index 29a962de7..a2f1e4e47 100644 --- a/util/appmacro/src/main/scala/sbt/appmacro/ContextUtil.scala +++ b/util/appmacro/src/main/scala/sbt/appmacro/ContextUtil.scala @@ -190,7 +190,7 @@ final class ContextUtil[C <: Context](val ctx: C) { // Workaround copied from scala/async:can be removed once https://github.com/scala/scala/pull/3179 is merged. private[this] class ChangeOwnerAndModuleClassTraverser(oldowner: global.Symbol, newowner: global.Symbol) extends global.ChangeOwnerTraverser(oldowner, newowner) { - override def traverse(tree: global.Tree) { + override def traverse(tree: global.Tree): Unit = { tree match { case _: global.DefTree => change(tree.symbol.moduleClass) case _ => diff --git a/util/classfile/src/main/scala/sbt/classfile/Analyze.scala b/util/classfile/src/main/scala/sbt/classfile/Analyze.scala index 9df04f1f1..52119d37d 100644 --- a/util/classfile/src/main/scala/sbt/classfile/Analyze.scala +++ b/util/classfile/src/main/scala/sbt/classfile/Analyze.scala @@ -43,7 +43,7 @@ private[sbt] object Analyze { for ((source, classFiles) <- sourceToClassFiles) { val publicInherited = readAPI(source, classFiles.toSeq.flatMap(c => load(c.className, Some("Error reading API from class file")))) - def processDependency(tpe: String, context: DependencyContext) { + def processDependency(tpe: String, context: DependencyContext): Unit = { trapAndLog(log) { for (url <- Option(loader.getResource(tpe.replace('.', '/') + ClassExt)); file <- urlAsFile(url, log)) { if (url.getProtocol == "jar") @@ -76,7 +76,7 @@ private[sbt] object Analyze { log.warn("Could not convert URL '" + url.toExternalForm + "' to File: " + e.toString) None } - private def trapAndLog(log: Logger)(execute: => Unit) { + private def trapAndLog(log: Logger)(execute: => Unit): Unit = { try { execute } catch { case e: Throwable => log.trace(e); log.error(e.toString) } } diff --git a/util/classpath/src/main/scala/sbt/classpath/RawURL.scala b/util/classpath/src/main/scala/sbt/classpath/RawURL.scala index 8b051523e..b4094553f 100644 --- a/util/classpath/src/main/scala/sbt/classpath/RawURL.scala +++ b/util/classpath/src/main/scala/sbt/classpath/RawURL.scala @@ -33,7 +33,7 @@ object RawURL { override protected def openConnection(url: URL): URLConnection = new URLConnection(url) { private lazy val in = value - def connect() { in } + def connect(): Unit = in override def getInputStream = in } } @@ -62,4 +62,4 @@ trait FixedResources extends ClassLoader { case None => sup } } -} \ No newline at end of file +} diff --git a/util/collection/src/main/scala/sbt/Dag.scala b/util/collection/src/main/scala/sbt/Dag.scala index 7c0fd6f2c..118cd0dff 100644 --- a/util/collection/src/main/scala/sbt/Dag.scala +++ b/util/collection/src/main/scala/sbt/Dag.scala @@ -21,18 +21,18 @@ object Dag { val finished = (new java.util.LinkedHashSet[T]).asScala def visitAll(nodes: Iterable[T]) = nodes foreach visit - def visit(node: T) { + def visit(node: T): Unit = { if (!discovered(node)) { discovered(node) = true; try { visitAll(dependencies(node)); } catch { case c: Cyclic => throw node :: c } - finished += node; + finished += node } else if (!finished(node)) throw new Cyclic(node) } - visitAll(nodes); + visitAll(nodes) - finished.toList; + finished.toList } // doesn't check for cycles def topologicalSortUnchecked[T](node: T)(dependencies: T => Iterable[T]): List[T] = topologicalSortUnchecked(node :: Nil)(dependencies) @@ -43,11 +43,11 @@ object Dag { var finished: List[T] = Nil def visitAll(nodes: Iterable[T]) = nodes foreach visit - def visit(node: T) { + def visit(node: T): Unit = { if (!discovered(node)) { - discovered(node) = true; + discovered(node) = true visitAll(dependencies(node)) - finished ::= node; + finished ::= node } } diff --git a/util/collection/src/main/scala/sbt/INode.scala b/util/collection/src/main/scala/sbt/INode.scala index 1af592f77..ce39fadad 100644 --- a/util/collection/src/main/scala/sbt/INode.scala +++ b/util/collection/src/main/scala/sbt/INode.scala @@ -111,7 +111,7 @@ abstract class EvaluateSettings[Scope] { final def isNew: Boolean = synchronized { state == New } final def isCalling: Boolean = synchronized { state == Calling } final def registerIfNew(): Unit = synchronized { if (state == New) register() } - private[this] def register() { + private[this] def register(): Unit = { assert(state == New, "Already registered and: " + toString) val deps = dependsOn blockedOn = deps.size - deps.count(_.doneOrBlock(this)) @@ -133,12 +133,12 @@ abstract class EvaluateSettings[Scope] { if (blockedOn == 0) schedule() } final def evaluate(): Unit = synchronized { evaluate0() } - protected final def makeCall(source: BindNode[_, T], target: INode[T]) { + protected final def makeCall(source: BindNode[_, T], target: INode[T]): Unit = { assert(state == Ready, "Invalid state for call to makeCall: " + toString) state = Calling target.call(source) } - protected final def setValue(v: T) { + protected final def setValue(v: T): Unit = { assert(state != Evaluated, "Already evaluated (trying to set value to " + v + "): " + toString) if (v == null) sys.error("Setting value cannot be null: " + keyString) value = v diff --git a/util/collection/src/main/scala/sbt/Param.scala b/util/collection/src/main/scala/sbt/Param.scala index 6f674efdc..19d12798a 100644 --- a/util/collection/src/main/scala/sbt/Param.scala +++ b/util/collection/src/main/scala/sbt/Param.scala @@ -20,11 +20,11 @@ object Param { type T = s def in = a private var r: B[T] = _ - def ret(b: B[T]) { r = b } + def ret(b: B[T]): Unit = { r = b } def ret: B[T] = r } p(v) v.ret } } -} \ No newline at end of file +} diff --git a/util/collection/src/main/scala/sbt/Settings.scala b/util/collection/src/main/scala/sbt/Settings.scala index 03173d6ce..eb4227d09 100644 --- a/util/collection/src/main/scala/sbt/Settings.scala +++ b/util/collection/src/main/scala/sbt/Settings.scala @@ -354,7 +354,7 @@ trait Init[Scope] { // set of defined scoped keys, used to ensure a derived setting is only added if all dependencies are present val defined = new mutable.HashSet[ScopedKey[_]] - def addDefs(ss: Seq[Setting[_]]) { for (s <- ss) defined += s.key } + def addDefs(ss: Seq[Setting[_]]): Unit = { for (s <- ss) defined += s.key } addDefs(defs) // true iff the scoped key is in `defined`, taking delegation into account diff --git a/util/complete/src/main/scala/sbt/complete/JLineCompletion.scala b/util/complete/src/main/scala/sbt/complete/JLineCompletion.scala index 1d876f0ba..fed89541f 100644 --- a/util/complete/src/main/scala/sbt/complete/JLineCompletion.scala +++ b/util/complete/src/main/scala/sbt/complete/JLineCompletion.scala @@ -104,7 +104,7 @@ object JLineCompletion { !(common.isEmpty && display.isEmpty) } - def appendCompletion(common: String, reader: ConsoleReader) { + def appendCompletion(common: String, reader: ConsoleReader): Unit = { reader.getCursorBuffer.write(common) reader.redrawLine() } @@ -113,16 +113,16 @@ object JLineCompletion { * `display` is assumed to be the exact strings requested to be displayed. * In particular, duplicates should have been removed already. */ - def showCompletions(display: Seq[String], reader: ConsoleReader) { + def showCompletions(display: Seq[String], reader: ConsoleReader): Unit = { printCompletions(display, reader) reader.drawLine() } - def printCompletions(cs: Seq[String], reader: ConsoleReader) { + def printCompletions(cs: Seq[String], reader: ConsoleReader): Unit = { val print = shouldPrint(cs, reader) reader.println() if (print) printLinesAndColumns(cs, reader) } - def printLinesAndColumns(cs: Seq[String], reader: ConsoleReader) { + def printLinesAndColumns(cs: Seq[String], reader: ConsoleReader): Unit = { val (lines, columns) = cs partition hasNewline for (line <- lines) { reader.print(line) @@ -153,4 +153,4 @@ object JLineCompletion { @tailrec def loop(i: Int): Int = if (i >= len) len else if (a(i) != b(i)) i else loop(i + 1) a.substring(0, loop(0)) } -} \ No newline at end of file +} diff --git a/util/complete/src/main/scala/sbt/complete/Parser.scala b/util/complete/src/main/scala/sbt/complete/Parser.scala index c52d16b91..892119f6c 100644 --- a/util/complete/src/main/scala/sbt/complete/Parser.scala +++ b/util/complete/src/main/scala/sbt/complete/Parser.scala @@ -185,7 +185,7 @@ object Parser extends ParserMain { def mkFailure(error: => String, definitive: Boolean = false): Failure = new Failure(error :: Nil, definitive) @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]) { + def checkMatches(a: Parser[_], completions: Seq[String]): Unit = { val bad = completions.filter(apply(a)(_).resultEmpty.isFailure) if (bad.nonEmpty) sys.error("Invalid example completions: " + bad.mkString("'", "', '", "'")) } @@ -845,4 +845,4 @@ private final class Repeat[T](partial: Option[Parser[T]], repeated: Parser[T], m for (value <- repeated.resultEmpty) yield makeList(min, value) } override def toString = "repeat(" + min + "," + max + "," + partial + "," + repeated + ")" -} \ No newline at end of file +} diff --git a/util/complete/src/test/scala/ParserTest.scala b/util/complete/src/test/scala/ParserTest.scala index 53d6cb1db..efe2f3493 100644 --- a/util/complete/src/test/scala/ParserTest.scala +++ b/util/complete/src/test/scala/ParserTest.scala @@ -15,7 +15,7 @@ object JLineTest { } val parsers = Map("1" -> one, "2" -> two, "3" -> three, "4" -> four, "5" -> five) - def main(args: Array[String]) { + def main(args: Array[String]): Unit = { import jline.TerminalFactory import jline.console.ConsoleReader val reader = new ConsoleReader() @@ -23,7 +23,7 @@ object JLineTest { val parser = parsers(args(0)) JLineCompletion.installCustomCompletor(reader, parser) - def loop() { + def loop(): Unit = { val line = reader.readLine("> ") if (line ne null) { println("Result: " + apply(parser)(line).resultEmpty) @@ -130,7 +130,7 @@ object ParserExample { println(apply(t)("test w").resultEmpty) println(apply(t)("test was were").resultEmpty) - def run(n: Int) { + def run(n: Int): Unit = { val a = 'a'.id val aq = a.? val aqn = repeat(aq, min = n, max = n) @@ -140,9 +140,9 @@ object ParserExample { def r = apply(ann)("a" * (n * 2)).resultEmpty println(r.isValid) } - def run2(n: Int) { + def run2(n: Int): Unit = { val ab = "ab".?.* val r = apply(ab)("a" * n).resultEmpty println(r) } -} \ No newline at end of file +} diff --git a/util/datatype/src/main/scala/xsbt/datatype/GenerateDatatypes.scala b/util/datatype/src/main/scala/xsbt/datatype/GenerateDatatypes.scala index 23f3bc450..c55ccc4ab 100644 --- a/util/datatype/src/main/scala/xsbt/datatype/GenerateDatatypes.scala +++ b/util/datatype/src/main/scala/xsbt/datatype/GenerateDatatypes.scala @@ -9,7 +9,7 @@ import java.util.Locale /** Generates a datatype hierarchy from a definition file.*/ object GenerateDatatypes { /** Arguments: +*/ - def main(args: Array[String]) { + def main(args: Array[String]): Unit = { if (args.length < 3) { System.err.println("Invalid number of arguments, expected package, base directory, and files to process") System.exit(1) diff --git a/util/datatype/src/main/scala/xsbt/datatype/Generator.scala b/util/datatype/src/main/scala/xsbt/datatype/Generator.scala index 8cb753353..453d43adb 100644 --- a/util/datatype/src/main/scala/xsbt/datatype/Generator.scala +++ b/util/datatype/src/main/scala/xsbt/datatype/Generator.scala @@ -13,7 +13,7 @@ import java.util.Locale abstract class GeneratorBase(val basePkgName: String, val baseDirectory: File) { def writeDefinitions(ds: Iterable[Definition]) = Generator.writeDefinitions(ds)(writeDefinition) def writeDefinition(d: Definition) = d match { case e: EnumDef => writeEnum(e); case c: ClassDef => writeClass(c) } - def writeEnum(e: EnumDef) { + def writeEnum(e: EnumDef): Unit = { val content = "public enum " + e.name + " {" + e.members.mkString("\n\t", ",\n\t", "\n") + @@ -22,7 +22,7 @@ abstract class GeneratorBase(val basePkgName: String, val baseDirectory: File) { } def writeClass(c: ClassDef): Unit - def writeSource(name: String, pkgName: String, content: String) { + def writeSource(name: String, pkgName: String, content: String): Unit = { val file = new File(new File(baseDirectory, packagePath(pkgName)), name + ".java") file.getParentFile.mkdirs() write(file, "package " + pkgName + ";\n\n" + content) @@ -153,7 +153,7 @@ object Generator { method("public", "String", "toString", "", content) } - def writeDefinitions(ds: Iterable[Definition])(writeDefinition: Definition => Unit) { + def writeDefinitions(ds: Iterable[Definition])(writeDefinition: Definition => Unit): Unit = { val (_, duplicates) = ((Set[String](), Set[String]()) /: ds.map(_.name)) { case ((nameSet, duplicates), name) => @@ -165,4 +165,4 @@ object Generator { sys.error("Duplicate names:\n\t" + duplicates.mkString("\n\t")) } def implName(name: String) = name + "0" -} \ No newline at end of file +} diff --git a/util/io/src/main/scala/sbt/IO.scala b/util/io/src/main/scala/sbt/IO.scala index b2d7e7111..348fd0ab3 100644 --- a/util/io/src/main/scala/sbt/IO.scala +++ b/util/io/src/main/scala/sbt/IO.scala @@ -105,8 +105,10 @@ object IO { } } - def assertDirectory(file: File) { assert(file.isDirectory, (if (file.exists) "Not a directory: " else "Directory not found: ") + file) } - def assertDirectories(file: File*) { file.foreach(assertDirectory) } + def assertDirectory(file: File): Unit = + assert(file.isDirectory, (if (file.exists) "Not a directory: " else "Directory not found: ") + file) + + def assertDirectories(file: File*): Unit = file.foreach(assertDirectory) // "base.extension" -> (base, extension) /** @@ -137,7 +139,7 @@ object IO { * Creates a file at the given location if it doesn't exist. * If the file already exists and `setModified` is true, this method sets the last modified time to the current time. */ - def touch(file: File, setModified: Boolean = true) { + def touch(file: File, setModified: Boolean = true): Unit = { val absFile = file.getAbsoluteFile createDirectory(absFile.getParentFile) val created = translate("Could not create file " + absFile) { absFile.createNewFile() } @@ -167,7 +169,7 @@ object IO { } /** Gzips the file 'in' and writes it to 'out'. 'in' cannot be the same file as 'out'. */ - def gzip(in: File, out: File) { + def gzip(in: File, out: File): Unit = { require(in != out, "Input file cannot be the same as the output file.") Using.fileInputStream(in) { inputStream => Using.fileOutputStream()(out) { outputStream => @@ -180,7 +182,7 @@ object IO { gzipOutputStream(output) { gzStream => transfer(input, gzStream) } /** Gunzips the file 'in' and writes it to 'out'. 'in' cannot be the same file as 'out'. */ - def gunzip(in: File, out: File) { + def gunzip(in: File, out: File): Unit = { require(in != out, "Input file cannot be the same as the output file.") Using.fileInputStream(in) { inputStream => Using.fileOutputStream()(out) { outputStream => @@ -204,7 +206,7 @@ object IO { private def extract(from: ZipInputStream, toDirectory: File, filter: NameFilter, preserveLastModified: Boolean) = { val set = new HashSet[File] - def next() { + def next(): Unit = { val entry = from.getNextEntry if (entry == null) () @@ -267,10 +269,10 @@ object IO { * input stream is closed after the method completes. */ def transferAndClose(in: InputStream, out: OutputStream): Unit = transferImpl(in, out, true) - private def transferImpl(in: InputStream, out: OutputStream, close: Boolean) { + private def transferImpl(in: InputStream, out: OutputStream, close: Boolean): Unit = { try { val buffer = new Array[Byte](BufferSize) - def read() { + def read(): Unit = { val byteCount = in.read(buffer) if (byteCount >= 0) { out.write(buffer, 0, byteCount) @@ -343,7 +345,7 @@ object IO { { def isEmptyDirectory(dir: File) = dir.isDirectory && listFiles(dir).isEmpty def parents(fs: Set[File]) = fs flatMap { f => Option(f.getParentFile) } - def deleteEmpty(dirs: Set[File]) { + def deleteEmpty(dirs: Set[File]): Unit = { val empty = dirs filter isEmptyDirectory if (empty.nonEmpty) // looks funny, but this is true if at least one of `dirs` is an empty directory { @@ -357,7 +359,7 @@ object IO { } /** Deletes `file`, recursively if it is a directory. */ - def delete(file: File) { + def delete(file: File): Unit = { translate("Error deleting file " + file + ": ") { val deleted = file.delete() if (!deleted && file.isDirectory) { @@ -399,7 +401,7 @@ object IO { def zip(sources: Traversable[(File, String)], outputZip: File): Unit = archive(sources.toSeq, outputZip, None) - private def archive(sources: Seq[(File, String)], outputFile: File, manifest: Option[Manifest]) { + private def archive(sources: Seq[(File, String)], outputFile: File, manifest: Option[Manifest]): Unit = { if (outputFile.isDirectory) sys.error("Specified output file " + outputFile + " is a directory.") else { @@ -411,14 +413,14 @@ object IO { } } } - private def writeZip(sources: Seq[(File, String)], output: ZipOutputStream)(createEntry: String => ZipEntry) { + private def writeZip(sources: Seq[(File, String)], output: ZipOutputStream)(createEntry: String => ZipEntry): Unit = { val files = sources.flatMap { case (file, name) => if (file.isFile) (file, normalizeName(name)) :: Nil else Nil } val now = System.currentTimeMillis // The CRC32 for an empty value, needed to store directories in zip files val emptyCRC = new CRC32().getValue() - def addDirectoryEntry(name: String) { + def addDirectoryEntry(name: String): Unit = { output putNextEntry makeDirectoryEntry(name) output.closeEntry() } @@ -441,7 +443,7 @@ object IO { e setTime file.lastModified e } - def addFileEntry(file: File, name: String) { + def addFileEntry(file: File, name: String): Unit = { output putNextEntry makeFileEntry(file, name) transfer(file, output) output.closeEntry() @@ -481,7 +483,7 @@ object IO { if (sep == '/') name else name.replace(sep, '/') } - private def withZipOutput(file: File, manifest: Option[Manifest])(f: ZipOutputStream => Unit) { + private def withZipOutput(file: File, manifest: Option[Manifest])(f: ZipOutputStream => Unit): Unit = { fileOutputStream(false)(file) { fileOut => val (zipOut, ext) = manifest match { @@ -577,7 +579,7 @@ object IO { * Copies the contents of `sourceFile` to the location of `targetFile`, overwriting any existing content. * If `preserveLastModified` is `true`, the last modified time is transferred as well. */ - def copyFile(sourceFile: File, targetFile: File, preserveLastModified: Boolean = false) { + def copyFile(sourceFile: File, targetFile: File, preserveLastModified: Boolean = false): Unit = { // NOTE: when modifying this code, test with larger values of CopySpec.MaxFileSizeBits than default require(sourceFile.exists, "Source file '" + sourceFile.getAbsolutePath + "' does not exist.") @@ -863,10 +865,9 @@ object IO { * See also [[https://github.com/sbt/sbt/issues/136 issue 136]]. */ def objectInputStream(wrapped: InputStream, loader: ClassLoader): ObjectInputStream = new ObjectInputStream(wrapped) { - override def resolveClass(osc: ObjectStreamClass): Class[_] = - { - val c = Class.forName(osc.getName, false, loader) - if (c eq null) super.resolveClass(osc) else c - } + override def resolveClass(osc: ObjectStreamClass): Class[_] = { + val c = Class.forName(osc.getName, false, loader) + if (c eq null) super.resolveClass(osc) else c + } } } diff --git a/util/io/src/main/scala/sbt/Pack.scala b/util/io/src/main/scala/sbt/Pack.scala index 97d195273..ba7796627 100644 --- a/util/io/src/main/scala/sbt/Pack.scala +++ b/util/io/src/main/scala/sbt/Pack.scala @@ -9,7 +9,7 @@ import IO._ object Pack { def pack(jarPath: File, out: File): Unit = pack(jarPath, out, defaultPackerOptions) - def pack(jarPath: File, out: File, options: Iterable[(String, String)]) { + def pack(jarPath: File, out: File, options: Iterable[(String, String)]): Unit = { val packer = Pack200.newPacker import collection.JavaConversions._ packer.properties ++= options @@ -20,7 +20,7 @@ object Pack { } } } - def unpack(packedPath: File, toJarPath: File) { + def unpack(packedPath: File, toJarPath: File): Unit = { val unpacker = Pack200.newUnpacker Using.fileOutputStream()(toJarPath) { fileStream => Using.jarOutputStream(fileStream) { jarOut => @@ -53,21 +53,21 @@ object SignJar { private def VerifyOption = "-verify" /** Uses jarsigner to sign the given jar. */ - def sign(jarPath: File, alias: String, options: Seq[SignOption])(fork: (String, List[String]) => Int) { + def sign(jarPath: File, alias: String, options: Seq[SignOption])(fork: (String, List[String]) => Int): Unit = { require(!alias.trim.isEmpty, "Alias cannot be empty") val arguments = options.toList.flatMap(_.toList) ::: jarPath.getAbsolutePath :: alias :: Nil execute("signing", arguments)(fork) } /** Uses jarsigner to verify the given jar.*/ - def verify(jarPath: File, options: Seq[SignOption])(fork: (String, List[String]) => Int) { + def verify(jarPath: File, options: Seq[SignOption])(fork: (String, List[String]) => Int): Unit = { val arguments = options.filter(!_.signOnly).toList.flatMap(_.toList) ::: VerifyOption :: jarPath.getAbsolutePath :: Nil execute("verifying", arguments)(fork) } - private def execute(action: String, arguments: List[String])(fork: (String, List[String]) => Int) { + private def execute(action: String, arguments: List[String])(fork: (String, List[String]) => Int): Unit = { val exitCode = fork(CommandName, arguments) if (exitCode != 0) sys.error("Error " + action + " jar (exit code was " + exitCode + ".)") } private val CommandName = "jarsigner" -} \ No newline at end of file +} diff --git a/util/io/src/test/scala/CopySpec.scala b/util/io/src/test/scala/CopySpec.scala index 20b1c0918..7c75d2ee8 100644 --- a/util/io/src/test/scala/CopySpec.scala +++ b/util/io/src/test/scala/CopySpec.scala @@ -34,11 +34,11 @@ object CopySpec extends Properties("Copy") { } } - def generate(seed: Long, size: Long, file: File) { + def generate(seed: Long, size: Long, file: File): Unit = { val rnd = new java.util.Random(seed) val buffer = new Array[Byte](BufferSize) - def loop(offset: Long) { + def loop(offset: Long): Unit = { val len = math.min(size - offset, BufferSize) if (len > 0) { rnd.nextBytes(buffer) @@ -48,7 +48,7 @@ object CopySpec extends Properties("Copy") { } if (size == 0L) IO.touch(file) else loop(0) } - def checkContentsSame(f1: File, f2: File) { + def checkContentsSame(f1: File, f2: File): Unit = { val len = f1.length assert(len == f2.length, "File lengths differ: " + (len, f2.length).toString + " for " + (f1, f2).toString) Using.fileInputStream(f1) { in1 => @@ -66,4 +66,4 @@ object CopySpec extends Properties("Copy") { } } } -} \ No newline at end of file +} diff --git a/util/log/src/main/scala/sbt/ConsoleLogger.scala b/util/log/src/main/scala/sbt/ConsoleLogger.scala index f86d7f2f5..c1558cc66 100644 --- a/util/log/src/main/scala/sbt/ConsoleLogger.scala +++ b/util/log/src/main/scala/sbt/ConsoleLogger.scala @@ -81,7 +81,7 @@ object ConsoleLogger { nextESC(s, 0, sb) sb.toString } - private[this] def nextESC(s: String, start: Int, sb: java.lang.StringBuilder) { + private[this] def nextESC(s: String, start: Int, sb: java.lang.StringBuilder): Unit = { val escIndex = s.indexOf(ESC, start) if (escIndex < 0) sb.append(s, start, s.length) @@ -167,7 +167,7 @@ class ConsoleLogger private[ConsoleLogger] (val out: ConsoleOut, override val an } def successLabelColor = GREEN def successMessageColor = RESET - override def success(message: => String) { + override def success(message: => String): Unit = { if (successEnabled) log(successLabelColor, Level.SuccessLabel, successMessageColor, message) } @@ -180,13 +180,13 @@ class ConsoleLogger private[ConsoleLogger] (val out: ConsoleOut, override val an for (msg <- suppressedMessage(new SuppressedTraceContext(traceLevel, ansiCodesSupported && useColor))) printLabeledLine(labelColor(Level.Error), "trace", messageColor(Level.Error), msg) } - def log(level: Level.Value, message: => String) { + def log(level: Level.Value, message: => String): Unit = { if (atLevel(level)) log(labelColor(level), level.toString, messageColor(level), message) } private def reset(): Unit = setColor(RESET) - private def setColor(color: String) { + private def setColor(color: String): Unit = { if (ansiCodesSupported && useColor) out.lockObject.synchronized { out.print(color) } } @@ -210,6 +210,6 @@ class ConsoleLogger private[ConsoleLogger] (val out: ConsoleOut, override val an } def logAll(events: Seq[LogEvent]) = out.lockObject.synchronized { events.foreach(log) } - def control(event: ControlEvent.Value, message: => String) { log(labelColor(Level.Info), Level.Info.toString, BLUE, message) } + def control(event: ControlEvent.Value, message: => String): Unit = log(labelColor(Level.Info), Level.Info.toString, BLUE, message) } final class SuppressedTraceContext(val traceLevel: Int, val useColor: Boolean) diff --git a/util/log/src/main/scala/sbt/FilterLogger.scala b/util/log/src/main/scala/sbt/FilterLogger.scala index d3547f34f..5259a6e12 100644 --- a/util/log/src/main/scala/sbt/FilterLogger.scala +++ b/util/log/src/main/scala/sbt/FilterLogger.scala @@ -9,23 +9,23 @@ package sbt */ class FilterLogger(delegate: AbstractLogger) extends BasicLogger { override lazy val ansiCodesSupported = delegate.ansiCodesSupported - def trace(t: => Throwable) { + def trace(t: => Throwable): Unit = { if (traceEnabled) delegate.trace(t) } - override def setSuccessEnabled(flag: Boolean) { delegate.setSuccessEnabled(flag) } + override def setSuccessEnabled(flag: Boolean): Unit = delegate.setSuccessEnabled(flag) override def successEnabled = delegate.successEnabled - override def setTrace(level: Int) { delegate.setTrace(level) } + override def setTrace(level: Int): Unit = delegate.setTrace(level) override def getTrace = delegate.getTrace - def log(level: Level.Value, message: => String) { + def log(level: Level.Value, message: => String): Unit = { if (atLevel(level)) delegate.log(level, message) } - def success(message: => String) { + def success(message: => String): Unit = { if (successEnabled) delegate.success(message) } - def control(event: ControlEvent.Value, message: => String) { + def control(event: ControlEvent.Value, message: => String): Unit = { if (atLevel(Level.Info)) delegate.control(event, message) } diff --git a/util/log/src/main/scala/sbt/FullLogger.scala b/util/log/src/main/scala/sbt/FullLogger.scala index 968712317..32873eff7 100644 --- a/util/log/src/main/scala/sbt/FullLogger.scala +++ b/util/log/src/main/scala/sbt/FullLogger.scala @@ -6,11 +6,11 @@ package sbt /** Promotes the simple Logger interface to the full AbstractLogger interface. */ class FullLogger(delegate: Logger) extends BasicLogger { override val ansiCodesSupported: Boolean = delegate.ansiCodesSupported - def trace(t: => Throwable) { + def trace(t: => Throwable): Unit = { if (traceEnabled) delegate.trace(t) } - def log(level: Level.Value, message: => String) { + def log(level: Level.Value, message: => String): Unit = { if (atLevel(level)) delegate.log(level, message) } @@ -27,4 +27,4 @@ object FullLogger { case d: AbstractLogger => d case _ => new FullLogger(delegate) } -} \ No newline at end of file +} diff --git a/util/log/src/main/scala/sbt/LoggerWriter.scala b/util/log/src/main/scala/sbt/LoggerWriter.scala index bc6062563..9be8af409 100644 --- a/util/log/src/main/scala/sbt/LoggerWriter.scala +++ b/util/log/src/main/scala/sbt/LoggerWriter.scala @@ -34,7 +34,7 @@ class LoggerWriter(delegate: Logger, unbufferedLevel: Option[Level.Value], nl: S process() } - private[this] def process() { + private[this] def process(): Unit = { val i = buffer.indexOf(nl) if (i >= 0) { log(buffer.substring(0, i)) @@ -46,4 +46,4 @@ class LoggerWriter(delegate: Logger, unbufferedLevel: Option[Level.Value], nl: S case None => lines += s case Some(level) => delegate.log(level, s) } -} \ No newline at end of file +} diff --git a/util/log/src/main/scala/sbt/MultiLogger.scala b/util/log/src/main/scala/sbt/MultiLogger.scala index 77c4c11d4..a6de160cd 100644 --- a/util/log/src/main/scala/sbt/MultiLogger.scala +++ b/util/log/src/main/scala/sbt/MultiLogger.scala @@ -11,24 +11,24 @@ class MultiLogger(delegates: List[AbstractLogger]) extends BasicLogger { private[this] lazy val allSupportCodes = delegates forall supported private[this] def supported = (_: AbstractLogger).ansiCodesSupported - override def setLevel(newLevel: Level.Value) { + override def setLevel(newLevel: Level.Value): Unit = { super.setLevel(newLevel) dispatch(new SetLevel(newLevel)) } - override def setTrace(level: Int) { + override def setTrace(level: Int): Unit = { super.setTrace(level) dispatch(new SetTrace(level)) } - override def setSuccessEnabled(flag: Boolean) { + override def setSuccessEnabled(flag: Boolean): Unit = { super.setSuccessEnabled(flag) dispatch(new SetSuccess(flag)) } - def trace(t: => Throwable) { dispatch(new Trace(t)) } - def log(level: Level.Value, message: => String) { dispatch(new Log(level, message)) } - def success(message: => String) { dispatch(new Success(message)) } - def logAll(events: Seq[LogEvent]) { delegates.foreach(_.logAll(events)) } - def control(event: ControlEvent.Value, message: => String) { delegates.foreach(_.control(event, message)) } - private[this] def dispatch(event: LogEvent) { + def trace(t: => Throwable): Unit = dispatch(new Trace(t)) + def log(level: Level.Value, message: => String): Unit = dispatch(new Log(level, message)) + def success(message: => String): Unit = dispatch(new Success(message)) + def logAll(events: Seq[LogEvent]): Unit = delegates.foreach(_.logAll(events)) + def control(event: ControlEvent.Value, message: => String): Unit = delegates.foreach(_.control(event, message)) + private[this] def dispatch(event: LogEvent): Unit = { val plainEvent = if (allSupportCodes) event else removeEscapes(event) for (d <- delegates) if (d.ansiCodesSupported) @@ -47,4 +47,4 @@ class MultiLogger(delegates: List[AbstractLogger]) extends BasicLogger { case _: Trace | _: SetLevel | _: SetTrace | _: SetSuccess => event } } -} \ No newline at end of file +} diff --git a/util/log/src/test/scala/LogWriterTest.scala b/util/log/src/test/scala/LogWriterTest.scala index db8250139..ce96e9bc9 100644 --- a/util/log/src/test/scala/LogWriterTest.scala +++ b/util/log/src/test/scala/LogWriterTest.scala @@ -40,7 +40,7 @@ object LogWriterTest extends Properties("Log Writer") { * represented as separately written segments (ToLog instances). ToLog.`byCharacter` * indicates whether to write the segment by character (true) or all at once (false) */ - def logLines(writer: Writer, lines: List[List[ToLog]], newLine: String) { + def logLines(writer: Writer, lines: List[List[ToLog]], newLine: String): Unit = { for (line <- lines; section <- line) { val content = section.content val normalized = Escape.newline(content, newLine) @@ -141,10 +141,10 @@ final class RecordingLogger extends BasicLogger { def getEvents = events.reverse override def ansiCodesSupported = true - def trace(t: => Throwable) { events ::= new Trace(t) } - def log(level: Level.Value, message: => String) { events ::= new Log(level, message) } - def success(message: => String) { events ::= new Success(message) } - def logAll(es: Seq[LogEvent]) { events :::= es.toList } - def control(event: ControlEvent.Value, message: => String) { events ::= new ControlEvent(event, message) } + def trace(t: => Throwable): Unit = { events ::= new Trace(t) } + def log(level: Level.Value, message: => String): Unit = { events ::= new Log(level, message) } + def success(message: => String): Unit = { events ::= new Success(message) } + def logAll(es: Seq[LogEvent]): Unit = { events :::= es.toList } + def control(event: ControlEvent.Value, message: => String): Unit = { events ::= new ControlEvent(event, message) } -} \ No newline at end of file +} diff --git a/util/process/src/main/scala/sbt/ProcessImpl.scala b/util/process/src/main/scala/sbt/ProcessImpl.scala index 0800e8b49..abef81b33 100644 --- a/util/process/src/main/scala/sbt/ProcessImpl.scala +++ b/util/process/src/main/scala/sbt/ProcessImpl.scala @@ -58,8 +58,8 @@ object BasicIO { processLinesFully(processLine)(reader.readLine) reader.close() } - def processLinesFully(processLine: String => Unit)(readLine: () => String) { - def readFully() { + def processLinesFully(processLine: String => Unit)(readLine: () => String): Unit = { + def readFully(): Unit = { val line = readLine() if (line != null) { processLine(line) @@ -68,7 +68,7 @@ object BasicIO { } readFully() } - def connectToIn(o: OutputStream) { transferFully(Uncloseable protect System.in, o) } + def connectToIn(o: OutputStream): Unit = transferFully(Uncloseable protect System.in, o) def input(connect: Boolean): OutputStream => Unit = if (connect) connectToIn else closeOut def standard(connectInput: Boolean): ProcessIO = standard(input(connectInput), inheritInput(connectInput)) def standard(in: OutputStream => Unit, inheritIn: JProcessBuilder => Boolean): ProcessIO = new ProcessIO(in, toStdOut, toStdErr, inheritIn) @@ -87,10 +87,10 @@ object BasicIO { buffer.append(Newline) } - private[this] def transferFullyImpl(in: InputStream, out: OutputStream) { + private[this] def transferFullyImpl(in: InputStream, out: OutputStream): Unit = { val continueCount = 1 //if(in.isInstanceOf[PipedInputStream]) 1 else 0 val buffer = new Array[Byte](BufferSize) - def read() { + def read(): Unit = { val byteCount = in.read(buffer) if (byteCount >= continueCount) { out.write(buffer, 0, byteCount) @@ -189,7 +189,7 @@ private abstract class BasicProcess extends Process { } private abstract class CompoundProcess extends BasicProcess { - def destroy() { destroyer() } + def destroy(): Unit = destroyer() def exitValue() = getExitValue().getOrElse(sys.error("No exit code: process destroyed.")) def start() = getExitValue @@ -294,7 +294,7 @@ private class PipedProcesses(a: ProcessBuilder, b: ProcessBuilder, defaultIO: Pr } } private class PipeSource(currentSource: SyncVar[Option[InputStream]], pipe: PipedOutputStream, label: => String) extends Thread { - final override def run() { + final override def run(): Unit = { currentSource.get match { case Some(source) => try { BasicIO.transferFully(source, pipe) } @@ -311,7 +311,7 @@ private class PipeSource(currentSource: SyncVar[Option[InputStream]], pipe: Pipe } } private class PipeSink(pipe: PipedInputStream, currentSink: SyncVar[Option[OutputStream]], label: => String) extends Thread { - final override def run() { + final override def run(): Unit = { currentSink.get match { case Some(sink) => try { BasicIO.transferFully(pipe, sink) } @@ -338,7 +338,7 @@ private[sbt] class DummyProcessBuilder(override val toString: String, exitValue: private class DummyProcess(action: => Int) extends Process { private[this] val exitCode = Future(action) override def exitValue() = exitCode() - override def destroy() {} + override def destroy(): Unit = () } /** Represents a simple command without any redirection or combination. */ private[sbt] class SimpleProcessBuilder(p: JProcessBuilder) extends AbstractProcessBuilder { @@ -410,12 +410,12 @@ private final class ThreadProcess(thread: Thread, success: SyncVar[Boolean]) ext thread.join() if (success.get) 0 else 1 } - override def destroy() { thread.interrupt() } + override def destroy(): Unit = thread.interrupt() } object Uncloseable { - def apply(in: InputStream): InputStream = new FilterInputStream(in) { override def close() {} } - def apply(out: OutputStream): OutputStream = new FilterOutputStream(out) { override def close() {} } + def apply(in: InputStream): InputStream = new FilterInputStream(in) { override def close(): Unit = () } + def apply(out: OutputStream): OutputStream = new FilterOutputStream(out) { override def close(): Unit = () } def protect(in: InputStream): InputStream = if (in eq System.in) Uncloseable(in) else in def protect(out: OutputStream): OutputStream = if ((out eq System.out) || (out eq System.err)) Uncloseable(out) else out } diff --git a/util/process/src/test/scala/TestedProcess.scala b/util/process/src/test/scala/TestedProcess.scala index f83207a07..8dabcf381 100644 --- a/util/process/src/test/scala/TestedProcess.scala +++ b/util/process/src/test/scala/TestedProcess.scala @@ -3,12 +3,12 @@ package sbt import java.io.{ File, FileNotFoundException, IOException } object exit { - def main(args: Array[String]) { + def main(args: Array[String]): Unit = { System.exit(java.lang.Integer.parseInt(args(0))) } } object cat { - def main(args: Array[String]) { + def main(args: Array[String]): Unit = { try { if (args.length == 0) IO.transfer(System.in, System.out) @@ -41,7 +41,6 @@ object cat { } } object echo { - def main(args: Array[String]) { + def main(args: Array[String]): Unit = System.out.println(args.mkString(" ")) - } -} \ No newline at end of file +}