Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Project Scala version updated to 1.12.8; all the IDE & compiler warnings fixed #607

Merged
merged 1 commit into from
Jan 7, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ ThisBuild / git.baseVersion := "1.3.0"
ThisBuild / organization := "com.typesafe"
ThisBuild / Compile / scalacOptions := List("-unchecked", "-deprecation", "-feature")
ThisBuild / Test / scalacOptions := List("-unchecked", "-deprecation", "-feature")
ThisBuild / scalaVersion := "2.10.6"
ThisBuild / scalaVersion := "2.12.8"

ThisBuild / scmInfo := Option(
ScmInfo(url("https://github.com/lightbend/config"), "scm:[email protected]:lightbend/config.git")
Expand Down Expand Up @@ -63,7 +63,7 @@ lazy val configLib = Project("config", file("config"))
.settings(nocomma {
autoScalaLibrary := false
crossPaths := false
libraryDependencies += "net.liftweb" %% "lift-json" % "2.5" % Test
libraryDependencies += "net.liftweb" %% "lift-json" % "3.3.0" % Test
libraryDependencies += "com.novocode" % "junit-interface" % "0.11" % Test

Compile / compile / javacOptions ++= Seq("-source", "1.8", "-target", "1.8",
Expand Down
2 changes: 1 addition & 1 deletion config/src/test/scala/ApiExamples.scala
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class ApiExamples {
class EnhancedConfig(c: Config) {
def getAny(path: String): Any = c.getAnyRef(path)
}
implicit def config2enhanced(c: Config) = new EnhancedConfig(c)
implicit def config2enhanced(c: Config): EnhancedConfig = new EnhancedConfig(c)

// somewhat nicer now
val e: Int = conf.getAny("ints.fortyTwo") match {
Expand Down
26 changes: 13 additions & 13 deletions config/src/test/scala/Profiling.scala
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ object Util {
}

def time(body: () => Unit, iterations: Int): Double = {
timeHelper(body, iterations, false)
timeHelper(body, iterations, retried = false)
}

def loop(args: Seq[String], body: () => Unit) {
Expand All @@ -57,10 +57,10 @@ object FileLoad extends App {
}
}

val ms = Util.time(task, 4000)
val ms = Util.time(() => task(), 4000)
println("file load: " + ms + "ms")

Util.loop(args, task)
Util.loop(args, () => task())
}

object Resolve extends App {
Expand All @@ -73,10 +73,10 @@ object Resolve extends App {
}
}

val ms = Util.time(task, 3000000)
val ms = Util.time(() => task(), 3000000)
println("resolve: " + ms + "ms")

Util.loop(args, task)
Util.loop(args, () => task())
}

object GetExistingPath extends App {
Expand All @@ -88,10 +88,10 @@ object GetExistingPath extends App {
}
}

val ms = Util.time(task, 2000000)
val ms = Util.time(() => task(), 2000000)
println("GetExistingPath: " + ms + "ms")

Util.loop(args, task)
Util.loop(args, () => task())
}

object GetSeveralExistingPaths extends App {
Expand All @@ -105,10 +105,10 @@ object GetSeveralExistingPaths extends App {
}
}

val ms = Util.time(task, 5000000)
val ms = Util.time(() => task(), 5000000)
println("GetSeveralExistingPaths: " + ms + "ms")

Util.loop(args, task)
Util.loop(args, () => task())
}

object HasPathOnMissing extends App {
Expand All @@ -120,10 +120,10 @@ object HasPathOnMissing extends App {
}
}

val ms = Util.time(task, 20000000)
val ms = Util.time(() => task(), 20000000)
println("HasPathOnMissing: " + ms + "ms")

Util.loop(args, task)
Util.loop(args, () => task())
}

object CatchExceptionOnMissing extends App {
Expand All @@ -146,9 +146,9 @@ object CatchExceptionOnMissing extends App {
}

anotherStackFrame(40) { () =>
val ms = Util.time(task, 300000)
val ms = Util.time(() => task(), 300000)
println("CatchExceptionOnMissing: " + ms + "ms")

Util.loop(args, task)
Util.loop(args, () => task())
}
}
2 changes: 1 addition & 1 deletion config/src/test/scala/Rendering.scala
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ object RenderOptions extends App {

val rendered =
allBooleanLists(4).foldLeft(0) { (count, values) =>
val formatted = values(0)
val formatted = values.head
val originComments = values(1)
val comments = values(2)
val json = values(3)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@ import java.util.Properties

class ConfParserTest extends TestUtils {

def parseWithoutResolving(s: String) = {
def parseWithoutResolving(s: String): AbstractConfigValue = {
val options = ConfigParseOptions.defaults().
setOriginDescription("test conf string").
setSyntax(ConfigSyntax.CONF)
Parseable.newString(s, options).parseValue().asInstanceOf[AbstractConfigValue]
Parseable.newString(s, options).parseValue()
}

def parse(s: String) = {
def parse(s: String): AbstractConfigValue = {
val tree = parseWithoutResolving(s)

// resolve substitutions so we can test problems with that, like cycles or
Expand All @@ -38,7 +38,7 @@ class ConfParserTest extends TestUtils {
@Test
def invalidConfThrows(): Unit = {
// be sure we throw
for (invalid <- whitespaceVariations(invalidConf, false)) {
for (invalid <- whitespaceVariations(invalidConf, validInLift = false)) {
addOffendingJsonToException("config", invalid.test) {
intercept[ConfigException] {
parse(invalid.test)
Expand Down Expand Up @@ -152,7 +152,7 @@ class ConfParserTest extends TestUtils {
}
} catch {
case e: Throwable =>
System.err.println("failed on: '" + invalid + "'");
System.err.println("failed on: '" + invalid + "'")
throw e;
}
}
Expand Down Expand Up @@ -267,9 +267,9 @@ class ConfParserTest extends TestUtils {
{ s: String => s.replace(",\n", " \n \n , \n \n ") },
{ s: String => dropCurlies(s) })

var tested = 0;
var tested = 0
for (v <- valids; change <- changes) {
tested += 1;
tested += 1
val obj = parseConfig(change(v))
assertEquals(3, obj.root.size())
assertEquals("y", obj.getString("a"))
Expand Down Expand Up @@ -351,7 +351,7 @@ class ConfParserTest extends TestUtils {
}

@Test
def toStringForParseables() {
def toStringForParseablesWorks() {
// just be sure the toString don't throw, to get test coverage
val options = ConfigParseOptions.defaults()
Parseable.newFile(new File("foo"), options).toString
Expand All @@ -366,7 +366,7 @@ class ConfParserTest extends TestUtils {
}

private def assertComments(comments: Seq[String], conf: Config, path: String) {
assertEquals(comments, conf.getValue(path).origin().comments().asScala.toSeq)
assertEquals(comments, conf.getValue(path).origin().comments().asScala)
}

private def assertComments(comments: Seq[String], conf: Config, path: String, index: Int) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import beanconfig.EnumsConfig.{ Solution, Problem }
import com.typesafe.config._

import java.io.{ InputStream, InputStreamReader }
import java.time.Duration;
import java.time.Duration

import beanconfig._
import org.junit.Assert._
Expand All @@ -19,7 +19,7 @@ import scala.collection.mutable.ArrayBuffer
class ConfigBeanFactoryTest extends TestUtils {

@Test
def toCamelCase() {
def testToCamelCase() {
assertEquals("configProp", ConfigImplUtil.toCamelCase("config-prop"))
assertEquals("configProp", ConfigImplUtil.toCamelCase("configProp"))
assertEquals("fooBar", ConfigImplUtil.toCamelCase("foo-----bar"))
Expand Down Expand Up @@ -122,10 +122,10 @@ class ConfigBeanFactoryTest extends TestUtils {
ConfigMemorySize.ofBytes(1073741824)),
beanConfig.getOfMemorySize.asScala)

val stringsConfigOne = new StringsConfig();
val stringsConfigOne = new StringsConfig()
stringsConfigOne.setAbcd("testAbcdOne")
stringsConfigOne.setYes("testYesOne")
val stringsConfigTwo = new StringsConfig();
val stringsConfigTwo = new StringsConfig()
stringsConfigTwo.setAbcd("testAbcdTwo")
stringsConfigTwo.setYes("testYesTwo")

Expand Down Expand Up @@ -155,10 +155,10 @@ class ConfigBeanFactoryTest extends TestUtils {
ConfigMemorySize.ofBytes(1073741824)),
beanConfig.getOfMemorySize.asScala)

val stringsConfigOne = new StringsConfig();
val stringsConfigOne = new StringsConfig()
stringsConfigOne.setAbcd("testAbcdOne")
stringsConfigOne.setYes("testYesOne")
val stringsConfigTwo = new StringsConfig();
val stringsConfigTwo = new StringsConfig()
stringsConfigTwo.setAbcd("testAbcdTwo")
stringsConfigTwo.setYes("testYesTwo")

Expand Down Expand Up @@ -200,7 +200,7 @@ class ConfigBeanFactoryTest extends TestUtils {
assertEquals("abcd", beanConfig.getConfig.getString("abcd"))
assertEquals(3, beanConfig.getConfigObj.toConfig.getInt("intVal"))
assertEquals(stringValue("hello world"), beanConfig.getConfigValue)
assertEquals(List(1, 2, 3).map(intValue(_)), beanConfig.getList.asScala)
assertEquals(List(1, 2, 3).map(intValue), beanConfig.getList.asScala)
assertEquals(true, beanConfig.getUnwrappedMap.get("shouldBeInt"))
assertEquals(42, beanConfig.getUnwrappedMap.get("should-be-boolean"))
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.typesafe.config.impl

import com.typesafe.config.{ ConfigException, ConfigSyntax, ConfigParseOptions }
import com.typesafe.config.ConfigSyntax.JSON
import com.typesafe.config.{ ConfigException, ConfigParseOptions, ConfigSyntax }
import org.junit.Assert._
import org.junit.Test

Expand All @@ -14,7 +15,7 @@ class ConfigDocumentParserTest extends TestUtils {
private def parseJSONFailuresTest(origText: String, containsMessage: String) {
var exceptionThrown = false
val e = intercept[ConfigException] {
ConfigDocumentParser.parse(tokenize(origText), fakeOrigin(), ConfigParseOptions.defaults().setSyntax(ConfigSyntax.JSON))
ConfigDocumentParser.parse(tokenize(origText), fakeOrigin(), ConfigParseOptions.defaults().setSyntax(JSON))
}
assertTrue(e.getMessage.contains(containsMessage))
}
Expand All @@ -25,7 +26,7 @@ class ConfigDocumentParserTest extends TestUtils {
assertEquals(expectedRenderedText, node.render())
assertTrue(node.isInstanceOf[ConfigNodeSimpleValue])

val nodeJSON = ConfigDocumentParser.parseValue(tokenize(origText), fakeOrigin(), ConfigParseOptions.defaults().setSyntax(ConfigSyntax.JSON))
val nodeJSON = ConfigDocumentParser.parseValue(tokenize(origText), fakeOrigin(), ConfigParseOptions.defaults().setSyntax(JSON))
assertEquals(expectedRenderedText, nodeJSON.render())
assertTrue(nodeJSON.isInstanceOf[ConfigNodeSimpleValue])
}
Expand All @@ -35,7 +36,7 @@ class ConfigDocumentParserTest extends TestUtils {
assertEquals(origText, node.render())
assertTrue(node.isInstanceOf[ConfigNodeComplexValue])

val nodeJSON = ConfigDocumentParser.parseValue(tokenize(origText), fakeOrigin(), ConfigParseOptions.defaults().setSyntax(ConfigSyntax.JSON))
val nodeJSON = ConfigDocumentParser.parseValue(tokenize(origText), fakeOrigin(), ConfigParseOptions.defaults().setSyntax(JSON))
assertEquals(origText, nodeJSON.render())
assertTrue(nodeJSON.isInstanceOf[ConfigNodeComplexValue])
}
Expand All @@ -45,7 +46,7 @@ class ConfigDocumentParserTest extends TestUtils {
assertEquals(origText, node.render())

val e = intercept[ConfigException] {
ConfigDocumentParser.parseValue(tokenize(origText), fakeOrigin(), ConfigParseOptions.defaults().setSyntax(ConfigSyntax.JSON))
ConfigDocumentParser.parseValue(tokenize(origText), fakeOrigin(), ConfigParseOptions.defaults().setSyntax(JSON))
}
assertTrue(e.getMessage.contains(containsMessage))
}
Expand All @@ -58,7 +59,7 @@ class ConfigDocumentParserTest extends TestUtils {
}

@Test
def parseSuccess {
def parseSuccess() {
parseTest("foo:bar")
parseTest(" foo : bar ")
parseTest("""include "foo.conf" """)
Expand Down Expand Up @@ -185,7 +186,7 @@ class ConfigDocumentParserTest extends TestUtils {
]
}
"""
val node = ConfigDocumentParser.parse(tokenize(origText), fakeOrigin(), ConfigParseOptions.defaults().setSyntax(ConfigSyntax.JSON))
val node = ConfigDocumentParser.parse(tokenize(origText), fakeOrigin(), ConfigParseOptions.defaults().setSyntax(JSON))
assertEquals(origText, node.render())
}

Expand Down Expand Up @@ -249,7 +250,7 @@ class ConfigDocumentParserTest extends TestUtils {
}

@Test
def parseSingleValuesFailures {
def parseSingleValuesFailures() {
// Parse Simple Value throws on leading and trailing whitespace, comments, or newlines
parseLeadingTrailingFailure(" 123")
parseLeadingTrailingFailure("123 ")
Expand All @@ -267,17 +268,17 @@ class ConfigDocumentParserTest extends TestUtils {

// Check that concatenations in JSON will throw an error
var origText = "123 456 \"abc\""
var e = intercept[ConfigException] { ConfigDocumentParser.parseValue(tokenize(origText), fakeOrigin(), ConfigParseOptions.defaults().setSyntax(ConfigSyntax.JSON)) }
var e = intercept[ConfigException] { ConfigDocumentParser.parseValue(tokenize(origText), fakeOrigin(), ConfigParseOptions.defaults().setSyntax(JSON)) }
assertTrue("expected message for parsing concat as json", e.getMessage.contains("Parsing JSON and the value set in withValueText was either a concatenation or had trailing whitespace, newlines, or comments"))

// Check that keys with no separators and object values in JSON will throw an error
origText = """{"foo" { "bar" : 12 } }"""
e = intercept[ConfigException] { ConfigDocumentParser.parseValue(tokenize(origText), fakeOrigin(), ConfigParseOptions.defaults().setSyntax((ConfigSyntax.JSON))) }
e = intercept[ConfigException] { ConfigDocumentParser.parseValue(tokenize(origText), fakeOrigin(), ConfigParseOptions.defaults().setSyntax(JSON)) }
assertTrue("expected failure for key foo followed by token", e.getMessage.contains("""Key '"foo"' may not be followed by token: '{'"""))
}

@Test
def parseEmptyDocument {
def parseEmptyDocument() {
val node = ConfigDocumentParser.parse(tokenize(""), fakeOrigin(), ConfigParseOptions.defaults())
assertTrue(node.value().isInstanceOf[ConfigNodeObject])
assertTrue(node.value().children().isEmpty())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class ConfigDocumentTest extends TestUtils {
}

@Test
def configDocumentReplace {
def configDocumentReplace() {
// Can handle parsing/replacement with a very simple map
configDocumentReplaceConfTest("""{"a":1}""", """{"a":2}""", "2", "a")
configDocumentReplaceJsonTest("""{"a":1}""", """{"a":2}""", "2", "a")
Expand All @@ -37,7 +37,7 @@ class ConfigDocumentTest extends TestUtils {
configDocumentReplaceConfTest("a: b\nc = d", "a: b\nc = 12", "12", "c")

// Can handle parsing/replacement with a complicated map
var origText =
val origText =
"""{
"a":123,
"b": 123.456,
Expand Down
Loading