From 00434ccd74271de32fc411d0a17a22cc50a3a11f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Viktor=20L=C3=B6vgren?= Date: Tue, 16 May 2017 08:24:32 +0100 Subject: [PATCH] Change to use non-unicode arrows --- build.sbt | 20 ++-- .../js/src/test/scala/ciris/CirisJsSpec.scala | 8 +- .../ciris/readers/JavaTimeConfigReaders.scala | 22 ++-- .../readers/JavaIoConfigReadersSpec.scala | 2 +- .../readers/JavaNetConfigReadersSpec.scala | 6 +- .../JavaNioCharsetConfigReadersJvmSpec.scala | 2 +- .../JavaNioFileConfigReadersSpec.scala | 4 +- .../readers/JavaTimeConfigReadersSpec.scala | 108 +++++++++--------- .../src/main/scala/ciris/ConfigError.scala | 2 +- .../src/main/scala/ciris/ConfigReader.scala | 64 +++++------ .../src/main/scala/ciris/ConfigSource.scala | 34 +++--- .../src/main/scala/ciris/ConfigValue.scala | 8 +- .../src/main/scala/ciris/LoadConfigs.scala | 6 +- .../ciris/readers/DerivedConfigReaders.scala | 2 +- .../ciris/readers/DurationConfigReaders.scala | 4 +- .../ciris/readers/MathConfigReaders.scala | 4 +- .../readers/PrimitiveConfigReaders.scala | 12 +- .../src/test/scala/ciris/CirisSpec.scala | 4 +- .../test/scala/ciris/ConfigKeyTypeSpec.scala | 2 +- .../test/scala/ciris/ConfigSourceSpec.scala | 16 +-- .../test/scala/ciris/LoadConfigsSpec.scala | 2 +- .../src/test/scala/ciris/PropertySpec.scala | 14 +-- .../ciris/generators/JavaTimeGenerators.scala | 6 +- .../readers/DerivedConfigReadersSpec.scala | 2 +- .../readers/DurationConfigReadersSpec.scala | 10 +- .../JavaNioCharsetConfigReadersSpec.scala | 2 +- .../readers/JavaUtilConfigReadersSpec.scala | 8 +- .../ciris/readers/MathConfigReadersSpec.scala | 8 +- .../readers/PrimitiveConfigReadersSpec.scala | 40 +++---- .../readers/EnumeratumConfigReaders.scala | 10 +- .../readers/EnumeratumConfigReadersSpec.scala | 52 ++++----- .../readers/GenericConfigReaders.scala | 12 +- .../readers/GenericConfigReadersSpec.scala | 20 ++-- .../readers/RefinedConfigReadersSpec.scala | 6 +- .../generators/SquantsGenerators.scala | 8 +- .../readers/SquantsConfigReadersSpec.scala | 14 +-- project/LatestVersion.scala | 2 +- project/SourceGenerators.scala | 24 ++-- 38 files changed, 285 insertions(+), 285 deletions(-) diff --git a/build.sbt b/build.sbt index 151e7209..65581794 100644 --- a/build.sbt +++ b/build.sbt @@ -104,11 +104,11 @@ lazy val docs = project organization, latestVersion in ThisBuild, crossScalaVersions, - BuildInfoKey.map(moduleName in coreJVM) { case (k, v) ⇒ "core" + k.capitalize -> v }, - BuildInfoKey.map(moduleName in enumeratumJVM) { case (k, v) ⇒ "enumeratum" + k.capitalize -> v }, - BuildInfoKey.map(moduleName in genericJVM) { case (k, v) ⇒ "generic" + k.capitalize -> v }, - BuildInfoKey.map(moduleName in refinedJVM) { case (k, v) ⇒ "refined" + k.capitalize -> v }, - BuildInfoKey.map(moduleName in squantsJVM) { case (k, v) ⇒ "squants" + k.capitalize -> v } + BuildInfoKey.map(moduleName in coreJVM) { case (k, v) => "core" + k.capitalize -> v }, + BuildInfoKey.map(moduleName in enumeratumJVM) { case (k, v) => "enumeratum" + k.capitalize -> v }, + BuildInfoKey.map(moduleName in genericJVM) { case (k, v) => "generic" + k.capitalize -> v }, + BuildInfoKey.map(moduleName in refinedJVM) { case (k, v) => "refined" + k.capitalize -> v }, + BuildInfoKey.map(moduleName in squantsJVM) { case (k, v) => "squants" + k.capitalize -> v } ) ) .dependsOn(coreJVM, enumeratumJVM, genericJVM, refinedJVM, squantsJVM) @@ -141,9 +141,9 @@ lazy val scalaSettings = Seq( "-Ywarn-unused-import", "-Ywarn-unused" ).filter { - case "-Ywarn-unused-import" if scalaVersion.value == scala210 ⇒ false - case "-Ywarn-unused" if scalaVersion.value != scala212 ⇒ false - case _ ⇒ true + case "-Ywarn-unused-import" if scalaVersion.value == scala210 => false + case "-Ywarn-unused" if scalaVersion.value != scala212 => false + case _ => true }, scalacOptions in (Compile, console) -= "-Ywarn-unused-import", scalacOptions in (Test, console) := (scalacOptions in (Compile, console)).value @@ -252,7 +252,7 @@ generateReadme in ThisBuild := { val updateReadme = taskKey[Unit]("Generates and commits the readme") updateReadme in ThisBuild := { (generateReadme in ThisBuild).value - sbtrelease.Vcs.detect((baseDirectory in ciris).value).foreach { vcs ⇒ + sbtrelease.Vcs.detect((baseDirectory in ciris).value).foreach { vcs => vcs.add("readme.md").! vcs.commit("Update readme to latest version", sign = true).! } @@ -292,7 +292,7 @@ generateScripts in ThisBuild := { val updateScripts = taskKey[Unit]("Generates and commits scripts") updateScripts in ThisBuild := { (generateScripts in ThisBuild).value - sbtrelease.Vcs.detect((baseDirectory in ciris).value).foreach { vcs ⇒ + sbtrelease.Vcs.detect((baseDirectory in ciris).value).foreach { vcs => vcs.add(scriptsDirectory).! vcs.commit("Update scripts to latest version", sign = true).! } diff --git a/modules/core/js/src/test/scala/ciris/CirisJsSpec.scala b/modules/core/js/src/test/scala/ciris/CirisJsSpec.scala index d7b513ec..53dc5fea 100644 --- a/modules/core/js/src/test/scala/ciris/CirisJsSpec.scala +++ b/modules/core/js/src/test/scala/ciris/CirisJsSpec.scala @@ -5,16 +5,16 @@ final class CirisJsSpec extends PropertySpec { "being used in a JavaScript environment" should { "successfully be able to load a configuration" in { withValue(env[Option[String]]("APP_ENV")) { - case None ⇒ - loadConfig(prop[Option[Int]]("http.port")) { port ⇒ + case None => + loadConfig(prop[Option[Int]]("http.port")) { port => ("changeme", port getOrElse 4000, "local") } - case Some(appEnv) ⇒ + case Some(appEnv) => loadConfig( env[String]("API_KEY"), prop[Int]("http.port") - ) { (apiKey, httpPort) ⇒ + ) { (apiKey, httpPort) => (apiKey, httpPort, appEnv) } } shouldBe a[Right[_, _]] diff --git a/modules/core/jvm/src/main/scala/ciris/readers/JavaTimeConfigReaders.scala b/modules/core/jvm/src/main/scala/ciris/readers/JavaTimeConfigReaders.scala index 96344fa4..54df4def 100644 --- a/modules/core/jvm/src/main/scala/ciris/readers/JavaTimeConfigReaders.scala +++ b/modules/core/jvm/src/main/scala/ciris/readers/JavaTimeConfigReaders.scala @@ -7,7 +7,7 @@ trait JavaTimeConfigReaders { import java.time._ implicit val dayOfWeekConfigReader: ConfigReader[DayOfWeek] = - fromOption("DayOfWeek")(value ⇒ DayOfWeek.values.find(_.name equalsIgnoreCase value)) + fromOption("DayOfWeek")(value => DayOfWeek.values.find(_.name equalsIgnoreCase value)) implicit val javaTimeDurationConfigReader: ConfigReader[Duration] = catchNonFatal("Duration")(Duration.parse) @@ -25,7 +25,7 @@ trait JavaTimeConfigReaders { catchNonFatal("LocalTime")(LocalTime.parse) implicit val monthConfigReader: ConfigReader[Month] = - fromOption("Month")(value ⇒ Month.values.find(_.name equalsIgnoreCase value)) + fromOption("Month")(value => Month.values.find(_.name equalsIgnoreCase value)) implicit val monthDayConfigReader: ConfigReader[MonthDay] = catchNonFatal("MonthDay")(MonthDay.parse) @@ -60,19 +60,19 @@ trait JavaTimeConfigReaders { catchNonFatal("Chronology")(Chronology.of) implicit val hijrahEraConfigReader: ConfigReader[HijrahEra] = - fromOption("HijrahEra")(value ⇒ HijrahEra.values.find(_.name equalsIgnoreCase value)) + fromOption("HijrahEra")(value => HijrahEra.values.find(_.name equalsIgnoreCase value)) implicit val isoEraConfigReader: ConfigReader[IsoEra] = - fromOption("IsoEra")(value ⇒ IsoEra.values.find(_.name equalsIgnoreCase value)) + fromOption("IsoEra")(value => IsoEra.values.find(_.name equalsIgnoreCase value)) implicit val japaneseEraConfigReader: ConfigReader[JapaneseEra] = - fromOption("JapaneseEra")(value ⇒ JapaneseEra.values.find(_.toString equalsIgnoreCase value)) + fromOption("JapaneseEra")(value => JapaneseEra.values.find(_.toString equalsIgnoreCase value)) implicit val minguoEraConfigReader: ConfigReader[MinguoEra] = - fromOption("MinguoEra")(value ⇒ MinguoEra.values.find(_.name equalsIgnoreCase value)) + fromOption("MinguoEra")(value => MinguoEra.values.find(_.name equalsIgnoreCase value)) implicit val thaiBuddhistEraConfigReader: ConfigReader[ThaiBuddhistEra] = - fromOption("ThaiBuddhistEra")(value ⇒ ThaiBuddhistEra.values.find(_.name equalsIgnoreCase value)) + fromOption("ThaiBuddhistEra")(value => ThaiBuddhistEra.values.find(_.name equalsIgnoreCase value)) import java.time.format._ @@ -80,14 +80,14 @@ trait JavaTimeConfigReaders { catchNonFatal("DateTimeFormatter")(DateTimeFormatter.ofPattern) implicit val formatStyleConfigReader: ConfigReader[FormatStyle] = - fromOption("FormatStyle")(value ⇒ FormatStyle.values.find(_.name equalsIgnoreCase value)) + fromOption("FormatStyle")(value => FormatStyle.values.find(_.name equalsIgnoreCase value)) implicit val resolverStyleConfigReader: ConfigReader[ResolverStyle] = - fromOption("ResolverStyle")(value ⇒ ResolverStyle.values.find(_.name equalsIgnoreCase value)) + fromOption("ResolverStyle")(value => ResolverStyle.values.find(_.name equalsIgnoreCase value)) implicit val signStyleConfigReader: ConfigReader[SignStyle] = - fromOption("SignStyle")(value ⇒ SignStyle.values.find(_.name equalsIgnoreCase value)) + fromOption("SignStyle")(value => SignStyle.values.find(_.name equalsIgnoreCase value)) implicit val textStyleConfigReader: ConfigReader[TextStyle] = - fromOption("TextStyle")(value ⇒ TextStyle.values.find(_.name equalsIgnoreCase value)) + fromOption("TextStyle")(value => TextStyle.values.find(_.name equalsIgnoreCase value)) } diff --git a/modules/core/jvm/src/test/scala/ciris/readers/JavaIoConfigReadersSpec.scala b/modules/core/jvm/src/test/scala/ciris/readers/JavaIoConfigReadersSpec.scala index 09e97dcf..9093f00f 100644 --- a/modules/core/jvm/src/test/scala/ciris/readers/JavaIoConfigReadersSpec.scala +++ b/modules/core/jvm/src/test/scala/ciris/readers/JavaIoConfigReadersSpec.scala @@ -8,7 +8,7 @@ final class JavaIoConfigReadersSpec extends PropertySpec { "JavaIoConfigReaders" when { "reading a File" should { "successfully read File values" in { - forAll { string: String ⇒ + forAll { string: String => readValue[File](string) shouldBe a[Right[_, _]] } } diff --git a/modules/core/jvm/src/test/scala/ciris/readers/JavaNetConfigReadersSpec.scala b/modules/core/jvm/src/test/scala/ciris/readers/JavaNetConfigReadersSpec.scala index e9d1dc10..2c811529 100644 --- a/modules/core/jvm/src/test/scala/ciris/readers/JavaNetConfigReadersSpec.scala +++ b/modules/core/jvm/src/test/scala/ciris/readers/JavaNetConfigReadersSpec.scala @@ -10,7 +10,7 @@ final class JavaNetConfigReadersSpec extends PropertySpec { "reading an InetAddress" should { "successfully read InetAddress values" in { val exampleAddresses = Gen.oneOf("localhost", "127.0.0.1") - forAll(exampleAddresses) { exampleAddress ⇒ + forAll(exampleAddresses) { exampleAddress => readValue[InetAddress](exampleAddress) shouldBe a[Right[_, _]] } } @@ -19,7 +19,7 @@ final class JavaNetConfigReadersSpec extends PropertySpec { "reading an URI" should { "successfully read URI values" in { val exampleUris = Gen.oneOf("http://localhost", "ftp://localhost") - forAll(exampleUris) { exampleUri: String ⇒ + forAll(exampleUris) { exampleUri: String => readValue[URI](exampleUri) shouldBe a[Right[_, _]] } } @@ -28,7 +28,7 @@ final class JavaNetConfigReadersSpec extends PropertySpec { "reading an URL" should { "successfully read URL values" in { val exampleUrls = Gen.oneOf("http://localhost", "ftp://localhost") - forAll(exampleUrls) { exampleUrl: String ⇒ + forAll(exampleUrls) { exampleUrl: String => readValue[URL](exampleUrl) shouldBe a[Right[_, _]] } } diff --git a/modules/core/jvm/src/test/scala/ciris/readers/JavaNioCharsetConfigReadersJvmSpec.scala b/modules/core/jvm/src/test/scala/ciris/readers/JavaNioCharsetConfigReadersJvmSpec.scala index 8ddbfb41..3c053bf7 100644 --- a/modules/core/jvm/src/test/scala/ciris/readers/JavaNioCharsetConfigReadersJvmSpec.scala +++ b/modules/core/jvm/src/test/scala/ciris/readers/JavaNioCharsetConfigReadersJvmSpec.scala @@ -14,7 +14,7 @@ final class JavaNioCharsetConfigReadersJvmSpec extends PropertySpec { val availableCharsets = Charset.availableCharsets().keySet().asScala.toSeq val genAvailableCharset = Gen.oneOf(availableCharsets).flatMap(mixedCase) - forAll(genAvailableCharset) { charset ⇒ + forAll(genAvailableCharset) { charset => readValue[Charset](charset) shouldBe a[Right[_, _]] } } diff --git a/modules/core/jvm/src/test/scala/ciris/readers/JavaNioFileConfigReadersSpec.scala b/modules/core/jvm/src/test/scala/ciris/readers/JavaNioFileConfigReadersSpec.scala index c9cd2ba1..92e7948f 100644 --- a/modules/core/jvm/src/test/scala/ciris/readers/JavaNioFileConfigReadersSpec.scala +++ b/modules/core/jvm/src/test/scala/ciris/readers/JavaNioFileConfigReadersSpec.scala @@ -9,7 +9,7 @@ final class JavaNioFileConfigReadersSpec extends PropertySpec { "JavaNioFileConfigReaders" when { "reading a Path" should { "successfully read Path values" in { - forAll { string: String ⇒ + forAll { string: String => whenever(!fails(Paths.get(string))) { readValue[Path](string) shouldBe Right(Paths.get(string)) } @@ -18,7 +18,7 @@ final class JavaNioFileConfigReadersSpec extends PropertySpec { "return a failure for invalid values" in { val invalidPaths = List[String](null, "\u0000") - forAll(Gen.oneOf(invalidPaths)) { invalidPath ⇒ + forAll(Gen.oneOf(invalidPaths)) { invalidPath => readValue[Path](invalidPath) shouldBe a[Left[_, _]] } } diff --git a/modules/core/jvm/src/test/scala/ciris/readers/JavaTimeConfigReadersSpec.scala b/modules/core/jvm/src/test/scala/ciris/readers/JavaTimeConfigReadersSpec.scala index aae63162..c655ed3d 100644 --- a/modules/core/jvm/src/test/scala/ciris/readers/JavaTimeConfigReadersSpec.scala +++ b/modules/core/jvm/src/test/scala/ciris/readers/JavaTimeConfigReadersSpec.scala @@ -13,13 +13,13 @@ final class JavaTimeConfigReadersSpec extends PropertySpec with JavaTimeGenerato "reading a DayOfWeek" should { "successfully read DayOfWeek values" in { forAll(mixedCaseEnum(DayOfWeek.values)(_.name)) { - case (dayOfWeek, string) ⇒ + case (dayOfWeek, string) => readValue[DayOfWeek](string) shouldBe Right(dayOfWeek) } } "return a failure for other values" in { - forAll { string: String ⇒ + forAll { string: String => whenever(!DayOfWeek.values.exists(_.name equalsIgnoreCase string)) { readValue[DayOfWeek](string) shouldBe a[Left[_, _]] } @@ -29,13 +29,13 @@ final class JavaTimeConfigReadersSpec extends PropertySpec with JavaTimeGenerato "reading a Duration" should { "successfully read Duration values" in { - forAll { duration: Duration ⇒ + forAll { duration: Duration => readValue[Duration](duration.toString) shouldBe Right(duration) } } "return a failure for other values" in { - forAll { string: String ⇒ + forAll { string: String => whenever(fails(Duration.parse(string))) { readValue[Duration](string) shouldBe a[Left[_, _]] } @@ -45,13 +45,13 @@ final class JavaTimeConfigReadersSpec extends PropertySpec with JavaTimeGenerato "reading a Instant" should { "successfully read Instant values" in { - forAll { instant: Instant ⇒ + forAll { instant: Instant => readValue[Instant](instant.toString) shouldBe Right(instant) } } "return a failure for other values" in { - forAll { string: String ⇒ + forAll { string: String => whenever(fails(Instant.parse(string))) { readValue[Instant](string) shouldBe a[Left[_, _]] } @@ -61,13 +61,13 @@ final class JavaTimeConfigReadersSpec extends PropertySpec with JavaTimeGenerato "reading a LocalDate" should { "successfully read LocalDate values" in { - forAll { localDate: LocalDate ⇒ + forAll { localDate: LocalDate => readValue[LocalDate](localDate.toString) shouldBe Right(localDate) } } "return a failure for other values" in { - forAll { string: String ⇒ + forAll { string: String => whenever(fails(LocalDate.parse(string))) { readValue[LocalDate](string) shouldBe a[Left[_, _]] } @@ -77,13 +77,13 @@ final class JavaTimeConfigReadersSpec extends PropertySpec with JavaTimeGenerato "reading a LocalDateTime" should { "successfully read LocalDateTime values" in { - forAll { localDateTime: LocalDateTime ⇒ + forAll { localDateTime: LocalDateTime => readValue[LocalDateTime](localDateTime.toString) shouldBe Right(localDateTime) } } "return a failure for other values" in { - forAll { string: String ⇒ + forAll { string: String => whenever(fails(LocalDateTime.parse(string))) { readValue[LocalDateTime](string) shouldBe a[Left[_, _]] } @@ -93,13 +93,13 @@ final class JavaTimeConfigReadersSpec extends PropertySpec with JavaTimeGenerato "reading a LocalTime" should { "successfully read LocalTime values" in { - forAll { localTime: LocalTime ⇒ + forAll { localTime: LocalTime => readValue[LocalTime](localTime.toString) shouldBe Right(localTime) } } "return a failure for other values" in { - forAll { string: String ⇒ + forAll { string: String => whenever(fails(LocalTime.parse(string))) { readValue[LocalTime](string) shouldBe a[Left[_, _]] } @@ -110,13 +110,13 @@ final class JavaTimeConfigReadersSpec extends PropertySpec with JavaTimeGenerato "reading a Month" should { "successfully read Month values" in { forAll(mixedCaseEnum(Month.values)(_.name)) { - case (month, string) ⇒ + case (month, string) => readValue[Month](string) shouldBe Right(month) } } "return a failure for other values" in { - forAll { string: String ⇒ + forAll { string: String => whenever(!Month.values.exists(_.name equalsIgnoreCase string)) { readValue[Month](string) shouldBe a[Left[_, _]] } @@ -126,13 +126,13 @@ final class JavaTimeConfigReadersSpec extends PropertySpec with JavaTimeGenerato "reading a MonthDay" should { "successfully read MonthDay values" in { - forAll { monthDay: MonthDay ⇒ + forAll { monthDay: MonthDay => readValue[MonthDay](monthDay.toString) shouldBe Right(monthDay) } } "return a failure for other values" in { - forAll { string: String ⇒ + forAll { string: String => whenever(fails(MonthDay.parse(string))) { readValue[MonthDay](string) shouldBe a[Left[_, _]] } @@ -142,13 +142,13 @@ final class JavaTimeConfigReadersSpec extends PropertySpec with JavaTimeGenerato "reading a OffsetDateTime" should { "successfully read OffsetDateTime values" in { - forAll { offsetDateTime: OffsetDateTime ⇒ + forAll { offsetDateTime: OffsetDateTime => readValue[OffsetDateTime](offsetDateTime.toString) shouldBe Right(offsetDateTime) } } "return a failure for other values" in { - forAll { string: String ⇒ + forAll { string: String => whenever(fails(OffsetDateTime.parse(string))) { readValue[OffsetDateTime](string) shouldBe a[Left[_, _]] } @@ -158,13 +158,13 @@ final class JavaTimeConfigReadersSpec extends PropertySpec with JavaTimeGenerato "reading a OffsetTime" should { "successfully read OffsetTime values" in { - forAll { offsetTime: OffsetTime ⇒ + forAll { offsetTime: OffsetTime => readValue[OffsetTime](offsetTime.toString) shouldBe Right(offsetTime) } } "return a failure for other values" in { - forAll { string: String ⇒ + forAll { string: String => whenever(fails(OffsetTime.parse(string))) { readValue[OffsetTime](string) shouldBe a[Left[_, _]] } @@ -174,13 +174,13 @@ final class JavaTimeConfigReadersSpec extends PropertySpec with JavaTimeGenerato "reading a Period" should { "successfully read Period values" in { - forAll { period: Period ⇒ + forAll { period: Period => readValue[Period](period.toString) shouldBe Right(period) } } "return a failure for other values" in { - forAll { string: String ⇒ + forAll { string: String => whenever(fails(Period.parse(string))) { readValue[Period](string) shouldBe a[Left[_, _]] } @@ -190,7 +190,7 @@ final class JavaTimeConfigReadersSpec extends PropertySpec with JavaTimeGenerato "reading a Year" should { "successfully read Year values" in { - forAll { year: Year ⇒ + forAll { year: Year => val yearString = if (year.getValue > 9999) s"+${year.toString}" else year.toString @@ -200,7 +200,7 @@ final class JavaTimeConfigReadersSpec extends PropertySpec with JavaTimeGenerato } "return a failure for other values" in { - forAll { string: String ⇒ + forAll { string: String => whenever(fails(Year.parse(string))) { readValue[Year](string) shouldBe a[Left[_, _]] } @@ -210,7 +210,7 @@ final class JavaTimeConfigReadersSpec extends PropertySpec with JavaTimeGenerato "reading a YearMonth" should { "successfully read YearMonth values" in { - forAll { yearMonth: YearMonth ⇒ + forAll { yearMonth: YearMonth => val yearMonthString = if (yearMonth.getYear > 9999) s"+${yearMonth.toString}" else yearMonth.toString @@ -220,7 +220,7 @@ final class JavaTimeConfigReadersSpec extends PropertySpec with JavaTimeGenerato } "return a failure for other values" in { - forAll { string: String ⇒ + forAll { string: String => whenever(fails(YearMonth.parse(string))) { readValue[YearMonth](string) shouldBe a[Left[_, _]] } @@ -230,13 +230,13 @@ final class JavaTimeConfigReadersSpec extends PropertySpec with JavaTimeGenerato "reading a ZonedDateTime" should { "successfully read ZonedDateTime values" in { - forAll { zonedDateTime: ZonedDateTime ⇒ + forAll { zonedDateTime: ZonedDateTime => readValue[ZonedDateTime](zonedDateTime.toString) shouldBe Right(zonedDateTime) } } "return a failure for other values" in { - forAll { string: String ⇒ + forAll { string: String => whenever(fails(ZonedDateTime.parse(string))) { readValue[ZonedDateTime](string) shouldBe a[Left[_, _]] } @@ -246,13 +246,13 @@ final class JavaTimeConfigReadersSpec extends PropertySpec with JavaTimeGenerato "reading a ZoneId" should { "successfully read ZoneId values" in { - forAll { zoneId: ZoneId ⇒ + forAll { zoneId: ZoneId => readValue[ZoneId](zoneId.toString) shouldBe Right(zoneId) } } "return a failure for other values" in { - forAll { string: String ⇒ + forAll { string: String => whenever(fails(ZoneId.of(string))) { readValue[ZoneId](string) shouldBe a[Left[_, _]] } @@ -262,13 +262,13 @@ final class JavaTimeConfigReadersSpec extends PropertySpec with JavaTimeGenerato "reading a ZoneOffset" should { "successfully read ZoneOffset values" in { - forAll { zoneOffset: ZoneOffset ⇒ + forAll { zoneOffset: ZoneOffset => readValue[ZoneOffset](zoneOffset.toString) shouldBe Right(zoneOffset) } } "return a failure for other values" in { - forAll { string: String ⇒ + forAll { string: String => whenever(fails(ZoneOffset.of(string))) { readValue[ZoneOffset](string) shouldBe a[Left[_, _]] } @@ -278,13 +278,13 @@ final class JavaTimeConfigReadersSpec extends PropertySpec with JavaTimeGenerato "reading a Chronology" should { "successfully read Chronology values" in { - forAll { chronology: Chronology ⇒ + forAll { chronology: Chronology => readValue[Chronology](chronology.toString) shouldBe Right(chronology) } } "return a failure for other values" in { - forAll { string: String ⇒ + forAll { string: String => whenever(fails(Chronology.of(string))) { readValue[Chronology](string) shouldBe a[Left[_, _]] } @@ -295,13 +295,13 @@ final class JavaTimeConfigReadersSpec extends PropertySpec with JavaTimeGenerato "reading a HijrahEra" should { "successfully read HijrahEra values" in { forAll(mixedCaseEnum(HijrahEra.values)(_.name)) { - case (hijrahEra, string) ⇒ + case (hijrahEra, string) => readValue[HijrahEra](string) shouldBe Right(hijrahEra) } } "return a failure for other values" in { - forAll { string: String ⇒ + forAll { string: String => whenever(!HijrahEra.values.exists(_.name equalsIgnoreCase string)) { readValue[HijrahEra](string) shouldBe a[Left[_, _]] } @@ -312,13 +312,13 @@ final class JavaTimeConfigReadersSpec extends PropertySpec with JavaTimeGenerato "reading a IsoEra" should { "successfully read IsoEra values" in { forAll(mixedCaseEnum(IsoEra.values)(_.name)) { - case (isoEra, string) ⇒ + case (isoEra, string) => readValue[IsoEra](string) shouldBe Right(isoEra) } } "return a failure for other values" in { - forAll { string: String ⇒ + forAll { string: String => whenever(!IsoEra.values.exists(_.name equalsIgnoreCase string)) { readValue[IsoEra](string) shouldBe a[Left[_, _]] } @@ -329,13 +329,13 @@ final class JavaTimeConfigReadersSpec extends PropertySpec with JavaTimeGenerato "reading a JapaneseEra" should { "successfully read JapaneseEra values" in { forAll(mixedCaseEnum(JapaneseEra.values)(_.toString)) { - case (japaneseEra, string) ⇒ + case (japaneseEra, string) => readValue[JapaneseEra](string) shouldBe Right(japaneseEra) } } "return a failure for other values" in { - forAll { string: String ⇒ + forAll { string: String => whenever(!JapaneseEra.values.exists(_.toString equalsIgnoreCase string)) { readValue[JapaneseEra](string) shouldBe a[Left[_, _]] } @@ -346,13 +346,13 @@ final class JavaTimeConfigReadersSpec extends PropertySpec with JavaTimeGenerato "reading a MinguoEra" should { "successfully read MinguoEra values" in { forAll(mixedCaseEnum(MinguoEra.values)(_.name)) { - case (minguoEra, string) ⇒ + case (minguoEra, string) => readValue[MinguoEra](string) shouldBe Right(minguoEra) } } "return a failure for other values" in { - forAll { string: String ⇒ + forAll { string: String => whenever(!MinguoEra.values.exists(_.name equalsIgnoreCase string)) { readValue[MinguoEra](string) shouldBe a[Left[_, _]] } @@ -363,13 +363,13 @@ final class JavaTimeConfigReadersSpec extends PropertySpec with JavaTimeGenerato "reading a ThaiBuddhistEra" should { "successfully read ThaiBuddhistEra values" in { forAll(mixedCaseEnum(ThaiBuddhistEra.values)(_.name)) { - case (thaiBuddhistEra, string) ⇒ + case (thaiBuddhistEra, string) => readValue[ThaiBuddhistEra](string) shouldBe Right(thaiBuddhistEra) } } "return a failure for other values" in { - forAll { string: String ⇒ + forAll { string: String => whenever(!ThaiBuddhistEra.values.exists(_.name equalsIgnoreCase string)) { readValue[ThaiBuddhistEra](string) shouldBe a[Left[_, _]] } @@ -380,14 +380,14 @@ final class JavaTimeConfigReadersSpec extends PropertySpec with JavaTimeGenerato "reading a DateTimeFormatter" should { "successfully read DateTimeFormatter patterns" in { val examplePatterns = Gen.oneOf("uuuu-MMM-dd", "yyyy MM dd") - forAll(examplePatterns) { examplePattern: String ⇒ + forAll(examplePatterns) { examplePattern: String => readValue[DateTimeFormatter](examplePattern) shouldBe a[Right[_, _]] } } "return a failure for other values" in { val badExamplePatterns = Gen.oneOf("mmm", "ddd") - forAll(badExamplePatterns) { badExamplePattern: String ⇒ + forAll(badExamplePatterns) { badExamplePattern: String => readValue[DateTimeFormatter](badExamplePattern) shouldBe a[Left[_, _]] } } @@ -396,13 +396,13 @@ final class JavaTimeConfigReadersSpec extends PropertySpec with JavaTimeGenerato "reading a FormatStyle" should { "successfully read FormatStyle values" in { forAll(mixedCaseEnum(FormatStyle.values)(_.name)) { - case (formatStyle, string) ⇒ + case (formatStyle, string) => readValue[FormatStyle](string) shouldBe Right(formatStyle) } } "return a failure for other values" in { - forAll { string: String ⇒ + forAll { string: String => whenever(!FormatStyle.values.exists(_.name equalsIgnoreCase string)) { readValue[FormatStyle](string) shouldBe a[Left[_, _]] } @@ -413,13 +413,13 @@ final class JavaTimeConfigReadersSpec extends PropertySpec with JavaTimeGenerato "reading a ResolverStyle" should { "successfully read ResolverStyle values" in { forAll(mixedCaseEnum(ResolverStyle.values)(_.name)) { - case (resolverStyle, string) ⇒ + case (resolverStyle, string) => readValue[ResolverStyle](string) shouldBe Right(resolverStyle) } } "return a failure for other values" in { - forAll { string: String ⇒ + forAll { string: String => whenever(!ResolverStyle.values.exists(_.name equalsIgnoreCase string)) { readValue[ResolverStyle](string) shouldBe a[Left[_, _]] } @@ -430,13 +430,13 @@ final class JavaTimeConfigReadersSpec extends PropertySpec with JavaTimeGenerato "reading a SignStyle" should { "successfully read SignStyle values" in { forAll(mixedCaseEnum(SignStyle.values)(_.name)) { - case (signStyle, string) ⇒ + case (signStyle, string) => readValue[SignStyle](string) shouldBe Right(signStyle) } } "return a failure for other values" in { - forAll { string: String ⇒ + forAll { string: String => whenever(!SignStyle.values.exists(_.name equalsIgnoreCase string)) { readValue[SignStyle](string) shouldBe a[Left[_, _]] } @@ -447,13 +447,13 @@ final class JavaTimeConfigReadersSpec extends PropertySpec with JavaTimeGenerato "reading a TextStyle" should { "successfully read TextStyle values" in { forAll(mixedCaseEnum(TextStyle.values)(_.name)) { - case (textStyle, string) ⇒ + case (textStyle, string) => readValue[TextStyle](string) shouldBe Right(textStyle) } } "return a failure for other values" in { - forAll { string: String ⇒ + forAll { string: String => whenever(!TextStyle.values.exists(_.name equalsIgnoreCase string)) { readValue[TextStyle](string) shouldBe a[Left[_, _]] } diff --git a/modules/core/shared/src/main/scala/ciris/ConfigError.scala b/modules/core/shared/src/main/scala/ciris/ConfigError.scala index f93c6785..6e11cc81 100644 --- a/modules/core/shared/src/main/scala/ciris/ConfigError.scala +++ b/modules/core/shared/src/main/scala/ciris/ConfigError.scala @@ -44,7 +44,7 @@ object ConfigError { cause: Option[B] = None ) extends ConfigError { override def message: String = { - val causeMessage = cause.map(cause ⇒ s": $cause").getOrElse("") + val causeMessage = cause.map(cause => s": $cause").getOrElse("") s"${keyType.value.capitalize} [$key] with value [$value] cannot be converted to type [$typeName]$causeMessage" } } diff --git a/modules/core/shared/src/main/scala/ciris/ConfigReader.scala b/modules/core/shared/src/main/scala/ciris/ConfigReader.scala index b6e37068..be71c7c5 100644 --- a/modules/core/shared/src/main/scala/ciris/ConfigReader.scala +++ b/modules/core/shared/src/main/scala/ciris/ConfigReader.scala @@ -5,34 +5,34 @@ import ciris.readers.ConfigReaders import scala.util.{Failure, Success, Try} -sealed abstract class ConfigReader[A] { self ⇒ +sealed abstract class ConfigReader[A] { self => def read(key: String)(implicit source: ConfigSource): Either[ConfigError, A] - final def map[B](f: A ⇒ B): ConfigReader[B] = - ConfigReader.pure { (key, source) ⇒ - self.read(key)(source).fold(Left.apply, value ⇒ Right(f(value))) + final def map[B](f: A => B): ConfigReader[B] = + ConfigReader.pure { (key, source) => + self.read(key)(source).fold(Left.apply, value => Right(f(value))) } - final def mapOption[B](typeName: String)(f: A ⇒ Option[B]): ConfigReader[B] = - ConfigReader.pure { (key, source) ⇒ + final def mapOption[B](typeName: String)(f: A => Option[B]): ConfigReader[B] = + ConfigReader.pure { (key, source) => self .read(key)(source) - .fold(Left.apply, value ⇒ { + .fold(Left.apply, value => { f(value) match { - case Some(b) ⇒ Right(b) - case None ⇒ Left(WrongType(key, value, typeName, source.keyType)) + case Some(b) => Right(b) + case None => Left(WrongType(key, value, typeName, source.keyType)) } }) } - final def mapEither[L, R](typeName: String)(f: A ⇒ Either[L, R]): ConfigReader[R] = - ConfigReader.pure { (key, source) ⇒ + final def mapEither[L, R](typeName: String)(f: A => Either[L, R]): ConfigReader[R] = + ConfigReader.pure { (key, source) => self .read(key)(source) - .fold(Left.apply, value ⇒ { + .fold(Left.apply, value => { f(value) match { - case Right(r) ⇒ Right(r) - case Left(cause) ⇒ Left(WrongType(key, value, typeName, source.keyType, Some(cause))) + case Right(r) => Right(r) + case Left(cause) => Left(WrongType(key, value, typeName, source.keyType, Some(cause))) } }) } @@ -41,43 +41,43 @@ sealed abstract class ConfigReader[A] { self ⇒ object ConfigReader extends ConfigReaders { def apply[A](implicit reader: ConfigReader[A]): ConfigReader[A] = reader - def pure[A](f: (String, ConfigSource) ⇒ Either[ConfigError, A]): ConfigReader[A] = + def pure[A](f: (String, ConfigSource) => Either[ConfigError, A]): ConfigReader[A] = new ConfigReader[A] { override def read(key: String)(implicit source: ConfigSource): Either[ConfigError, A] = f(key, source) } def fold[A]( - onMissingKey: ConfigError ⇒ Either[ConfigError, A], - onValue: (String, String, ConfigSource) ⇒ Either[ConfigError, A] - ): ConfigReader[A] = pure { (key, source) ⇒ - source.read(key).fold(onMissingKey, value ⇒ onValue(key, value, source)) + onMissingKey: ConfigError => Either[ConfigError, A], + onValue: (String, String, ConfigSource) => Either[ConfigError, A] + ): ConfigReader[A] = pure { (key, source) => + source.read(key).fold(onMissingKey, value => onValue(key, value, source)) } - def withValue[A](f: (String, String, ConfigSource) ⇒ Either[ConfigError, A]): ConfigReader[A] = + def withValue[A](f: (String, String, ConfigSource) => Either[ConfigError, A]): ConfigReader[A] = fold(Left.apply, f) - def fromOption[A](typeName: String)(f: String ⇒ Option[A]): ConfigReader[A] = - withValue { (key, value, source) ⇒ + def fromOption[A](typeName: String)(f: String => Option[A]): ConfigReader[A] = + withValue { (key, value, source) => f(value) match { - case Some(t) ⇒ Right(t) - case None ⇒ Left(WrongType(key, value, typeName, source.keyType)) + case Some(t) => Right(t) + case None => Left(WrongType(key, value, typeName, source.keyType)) } } - def fromTry[A](typeName: String)(f: String ⇒ Try[A]): ConfigReader[A] = - withValue { (key, value, source) ⇒ + def fromTry[A](typeName: String)(f: String => Try[A]): ConfigReader[A] = + withValue { (key, value, source) => f(value) match { - case Success(a) ⇒ Right(a) - case Failure(cause) ⇒ Left(WrongType(key, value, typeName, source.keyType, Some(cause))) + case Success(a) => Right(a) + case Failure(cause) => Left(WrongType(key, value, typeName, source.keyType, Some(cause))) } } - def catchNonFatal[A](typeName: String)(f: String ⇒ A): ConfigReader[A] = - withValue { (key, value, source) ⇒ + def catchNonFatal[A](typeName: String)(f: String => A): ConfigReader[A] = + withValue { (key, value, source) => Try(f(value)) match { - case Success(t) ⇒ Right(t) - case Failure(cause) ⇒ Left(WrongType(key, value, typeName, source.keyType, Some(cause))) + case Success(t) => Right(t) + case Failure(cause) => Left(WrongType(key, value, typeName, source.keyType, Some(cause))) } } } diff --git a/modules/core/shared/src/main/scala/ciris/ConfigSource.scala b/modules/core/shared/src/main/scala/ciris/ConfigSource.scala index 9669ce78..01ae25e7 100644 --- a/modules/core/shared/src/main/scala/ciris/ConfigSource.scala +++ b/modules/core/shared/src/main/scala/ciris/ConfigSource.scala @@ -9,7 +9,7 @@ sealed abstract class ConfigSource(val keyType: ConfigKeyType) { } object ConfigSource { - def apply(keyType: ConfigKeyType)(read: String ⇒ Either[ConfigError, String]): ConfigSource = { + def apply(keyType: ConfigKeyType)(read: String => Either[ConfigError, String]): ConfigSource = { val readValue = read new ConfigSource(keyType) { override def read(key: String): Either[ConfigError, String] = readValue(key) @@ -17,33 +17,33 @@ object ConfigSource { } } - def fromOption(keyType: ConfigKeyType)(read: String ⇒ Option[String]): ConfigSource = - ConfigSource(keyType)(key ⇒ + def fromOption(keyType: ConfigKeyType)(read: String => Option[String]): ConfigSource = + ConfigSource(keyType)(key => read(key) match { - case Some(value) ⇒ Right(value) - case None ⇒ Left(MissingKey(key, keyType)) + case Some(value) => Right(value) + case None => Left(MissingKey(key, keyType)) }) def fromMap(keyType: ConfigKeyType)(map: Map[String, String]): ConfigSource = ConfigSource.fromOption(keyType)(map.get) - def fromTry(keyType: ConfigKeyType)(read: String ⇒ Try[String]): ConfigSource = - ConfigSource(keyType)(key ⇒ + def fromTry(keyType: ConfigKeyType)(read: String => Try[String]): ConfigSource = + ConfigSource(keyType)(key => read(key) match { - case Success(value) ⇒ Right(value) - case Failure(cause) ⇒ Left(ReadException(key, keyType, cause)) + case Success(value) => Right(value) + case Failure(cause) => Left(ReadException(key, keyType, cause)) }) - def fromTryOption(keyType: ConfigKeyType)(read: String ⇒ Try[Option[String]]): ConfigSource = - ConfigSource(keyType)(key ⇒ + def fromTryOption(keyType: ConfigKeyType)(read: String => Try[Option[String]]): ConfigSource = + ConfigSource(keyType)(key => read(key) match { - case Success(Some(value)) ⇒ Right(value) - case Success(None) ⇒ Left(MissingKey(key, keyType)) - case Failure(cause) ⇒ Left(ReadException(key, keyType, cause)) + case Success(Some(value)) => Right(value) + case Success(None) => Left(MissingKey(key, keyType)) + case Failure(cause) => Left(ReadException(key, keyType, cause)) }) - def catchNonFatal(keyType: ConfigKeyType)(read: String ⇒ String): ConfigSource = - ConfigSource.fromTry(keyType)(key ⇒ Try(read(key))) + def catchNonFatal(keyType: ConfigKeyType)(read: String => String): ConfigSource = + ConfigSource.fromTry(keyType)(key => Try(read(key))) case object Environment extends ConfigSource(ConfigKeyType.Environment) { override def read(key: String): Either[ConfigError, String] = @@ -52,6 +52,6 @@ object ConfigSource { case object Properties extends ConfigSource(ConfigKeyType.Properties) { override def read(key: String): Either[ConfigError, String] = - ConfigSource.fromTryOption(keyType)(key ⇒ Try(sys.props.get(key))).read(key) + ConfigSource.fromTryOption(keyType)(key => Try(sys.props.get(key))).read(key) } } diff --git a/modules/core/shared/src/main/scala/ciris/ConfigValue.scala b/modules/core/shared/src/main/scala/ciris/ConfigValue.scala index e3eeedca..d98f604e 100644 --- a/modules/core/shared/src/main/scala/ciris/ConfigValue.scala +++ b/modules/core/shared/src/main/scala/ciris/ConfigValue.scala @@ -5,10 +5,10 @@ sealed abstract class ConfigValue[A] { private[ciris] def append[B](next: ConfigValue[B]): ConfigValue2[A, B] = { (value, next.value) match { - case (Right(a), Right(b)) ⇒ new ConfigValue2(Right((a, b))) - case (Left(error1), Right(_)) ⇒ new ConfigValue2(Left(ConfigErrors(error1))) - case (Right(_), Left(error2)) ⇒ new ConfigValue2(Left(ConfigErrors(error2))) - case (Left(error1), Left(error2)) ⇒ new ConfigValue2(Left(error1 append error2)) + case (Right(a), Right(b)) => new ConfigValue2(Right((a, b))) + case (Left(error1), Right(_)) => new ConfigValue2(Left(ConfigErrors(error1))) + case (Right(_), Left(error2)) => new ConfigValue2(Left(ConfigErrors(error2))) + case (Left(error1), Left(error2)) => new ConfigValue2(Left(error1 append error2)) } } } diff --git a/modules/core/shared/src/main/scala/ciris/LoadConfigs.scala b/modules/core/shared/src/main/scala/ciris/LoadConfigs.scala index 608c6822..91581df3 100644 --- a/modules/core/shared/src/main/scala/ciris/LoadConfigs.scala +++ b/modules/core/shared/src/main/scala/ciris/LoadConfigs.scala @@ -11,14 +11,14 @@ private [ciris] trait LoadConfigs { def loadConfig[Z](z: Z): Either[ConfigErrors, Z] = Right(z) - def loadConfig[A1, Z](a1: ConfigValue[A1])(f: A1 ⇒ Z): Either[ConfigErrors, Z] = - a1.value.fold(error ⇒ Left(ConfigErrors(error)), a1 ⇒ Right(f(a1))) + def loadConfig[A1, Z](a1: ConfigValue[A1])(f: A1 => Z): Either[ConfigErrors, Z] = + a1.value.fold(error => Left(ConfigErrors(error)), a1 => Right(f(a1))) def withValue[A1, Z](a1: ConfigValue[A1])(f: A1 => Either[ConfigErrors, Z]): Either[ConfigErrors, Z] = withValues(a1)(f) def withValues[A1, Z](a1: ConfigValue[A1])(f: A1 => Either[ConfigErrors, Z]): Either[ConfigErrors, Z] = - a1.value.fold(error ⇒ Left(ConfigErrors(error)), f) + a1.value.fold(error => Left(ConfigErrors(error)), f) def loadConfig[A1, A2, Z](a1: ConfigValue[A1], a2: ConfigValue[A2])(f: (A1, A2) => Z): Either[ConfigErrors, Z] = (a1 append a2).value.right.map(f.tupled) diff --git a/modules/core/shared/src/main/scala/ciris/readers/DerivedConfigReaders.scala b/modules/core/shared/src/main/scala/ciris/readers/DerivedConfigReaders.scala index 3b5bb764..24900c3d 100644 --- a/modules/core/shared/src/main/scala/ciris/readers/DerivedConfigReaders.scala +++ b/modules/core/shared/src/main/scala/ciris/readers/DerivedConfigReaders.scala @@ -5,5 +5,5 @@ import ciris.ConfigReader.fold trait DerivedConfigReaders { implicit def optionConfigReader[T](implicit reader: ConfigReader[T]): ConfigReader[Option[T]] = - fold(_ ⇒ Right(None), (key, _, source) ⇒ reader.read(key)(source).right.map(Some(_))) + fold(_ => Right(None), (key, _, source) => reader.read(key)(source).right.map(Some(_))) } diff --git a/modules/core/shared/src/main/scala/ciris/readers/DurationConfigReaders.scala b/modules/core/shared/src/main/scala/ciris/readers/DurationConfigReaders.scala index 341708ed..03e4c5b8 100644 --- a/modules/core/shared/src/main/scala/ciris/readers/DurationConfigReaders.scala +++ b/modules/core/shared/src/main/scala/ciris/readers/DurationConfigReaders.scala @@ -10,7 +10,7 @@ trait DurationConfigReaders { catchNonFatal("Duration")(Duration.apply) implicit val finiteDurationConfigReader: ConfigReader[FiniteDuration] = - durationConfigReader.mapOption("FiniteDuration") { duration ⇒ - Some(duration).collect { case finite: FiniteDuration ⇒ finite } + durationConfigReader.mapOption("FiniteDuration") { duration => + Some(duration).collect { case finite: FiniteDuration => finite } } } diff --git a/modules/core/shared/src/main/scala/ciris/readers/MathConfigReaders.scala b/modules/core/shared/src/main/scala/ciris/readers/MathConfigReaders.scala index 8d3dde7a..7f4a1c0e 100644 --- a/modules/core/shared/src/main/scala/ciris/readers/MathConfigReaders.scala +++ b/modules/core/shared/src/main/scala/ciris/readers/MathConfigReaders.scala @@ -6,8 +6,8 @@ import scala.util.Try trait MathConfigReaders { implicit val bigIntConfigReader: ConfigReader[BigInt] = - ConfigReader.fromTry("BigInt")(value ⇒ Try(BigInt(value))) + ConfigReader.fromTry("BigInt")(value => Try(BigInt(value))) implicit val bigDecimalConfigReader: ConfigReader[BigDecimal] = - ConfigReader.fromTry("BigDecimal")(value ⇒ Try(BigDecimal(value))) + ConfigReader.fromTry("BigDecimal")(value => Try(BigDecimal(value))) } diff --git a/modules/core/shared/src/main/scala/ciris/readers/PrimitiveConfigReaders.scala b/modules/core/shared/src/main/scala/ciris/readers/PrimitiveConfigReaders.scala index bf489d62..032c9aa5 100644 --- a/modules/core/shared/src/main/scala/ciris/readers/PrimitiveConfigReaders.scala +++ b/modules/core/shared/src/main/scala/ciris/readers/PrimitiveConfigReaders.scala @@ -11,20 +11,20 @@ trait PrimitiveConfigReaders { catchNonFatal("Byte")(_.toByte) implicit val charConfigReader: ConfigReader[Char] = - fromOption("Char") { value ⇒ + fromOption("Char") { value => if (value.length == 1) Some(value.head) else None } implicit val doubleConfigReader: ConfigReader[Double] = catchNonFatal("Double") { - case s if s.lastOption.exists(_ == '%') ⇒ s.init.toDouble / 100d - case s ⇒ s.toDouble + case s if s.lastOption.exists(_ == '%') => s.init.toDouble / 100d + case s => s.toDouble } implicit val floatConfigReader: ConfigReader[Float] = catchNonFatal("Float") { - case s if s.lastOption.exists(_ == '%') ⇒ s.init.toFloat / 100f - case s ⇒ s.toFloat + case s if s.lastOption.exists(_ == '%') => s.init.toFloat / 100f + case s => s.toFloat } implicit val intConfigReader: ConfigReader[Int] = @@ -37,5 +37,5 @@ trait PrimitiveConfigReaders { catchNonFatal("Short")(_.toShort) implicit val stringConfigReader: ConfigReader[String] = - withValue((_, value, _) ⇒ Right(value)) + withValue((_, value, _) => Right(value)) } diff --git a/modules/core/shared/src/test/scala/ciris/CirisSpec.scala b/modules/core/shared/src/test/scala/ciris/CirisSpec.scala index 3e7628ba..76dfa7ad 100644 --- a/modules/core/shared/src/test/scala/ciris/CirisSpec.scala +++ b/modules/core/shared/src/test/scala/ciris/CirisSpec.scala @@ -14,7 +14,7 @@ final class CirisSpec extends PropertySpec { } "return a failure for non-existing variables" in { - forAll { key: String ⇒ + forAll { key: String => whenever(!sys.env.contains(key)) { env[String](key).value shouldBe a[Left[_, _]] } @@ -36,7 +36,7 @@ final class CirisSpec extends PropertySpec { } "return a failure for non-existing properties" in { - forAll { key: String ⇒ + forAll { key: String => whenever(key.nonEmpty && !sys.props.contains(key)) { prop[String](key).value shouldBe a[Left[_, _]] } diff --git a/modules/core/shared/src/test/scala/ciris/ConfigKeyTypeSpec.scala b/modules/core/shared/src/test/scala/ciris/ConfigKeyTypeSpec.scala index 3715b3b1..5f4724b2 100644 --- a/modules/core/shared/src/test/scala/ciris/ConfigKeyTypeSpec.scala +++ b/modules/core/shared/src/test/scala/ciris/ConfigKeyTypeSpec.scala @@ -4,7 +4,7 @@ final class ConfigKeyTypeSpec extends PropertySpec { "ConfigKeyType" when { "converting to String" should { "include the value" in { - forAll { value: String ⇒ + forAll { value: String => ConfigKeyType(value).toString shouldBe s"ConfigKeyType($value)" } } diff --git a/modules/core/shared/src/test/scala/ciris/ConfigSourceSpec.scala b/modules/core/shared/src/test/scala/ciris/ConfigSourceSpec.scala index 83c7f0ff..b261cb48 100644 --- a/modules/core/shared/src/test/scala/ciris/ConfigSourceSpec.scala +++ b/modules/core/shared/src/test/scala/ciris/ConfigSourceSpec.scala @@ -6,7 +6,7 @@ final class ConfigSourceSpec extends PropertySpec { "ConfigSource" when { "converting to String" should { "include the key type" in { - forAll { keyType: String ⇒ + forAll { keyType: String => val configKey = ConfigKeyType(keyType) ConfigSource(configKey)(Right.apply).toString shouldBe s"ConfigSource($configKey)" } @@ -15,15 +15,15 @@ final class ConfigSourceSpec extends PropertySpec { "created from a Try" should { "succeed if the Try succeeds" in { - forAll { (keyType: String, key: String) ⇒ - val source = ConfigSource.fromTry(ConfigKeyType(keyType))(key ⇒ Try(key)) + forAll { (keyType: String, key: String) => + val source = ConfigSource.fromTry(ConfigKeyType(keyType))(key => Try(key)) source.read(key) shouldBe Right(key) } } "fail if the Try fails" in { - forAll { (keyType: String, key: String) ⇒ - val source = ConfigSource.fromTry(ConfigKeyType(keyType))(_ ⇒ Try(throw new Error)) + forAll { (keyType: String, key: String) => + val source = ConfigSource.fromTry(ConfigKeyType(keyType))(_ => Try(throw new Error)) source.read(key) shouldBe a[Left[_, _]] } } @@ -31,15 +31,15 @@ final class ConfigSourceSpec extends PropertySpec { "catching non-fatal exceptions" should { "succeed if an exception is not thrown" in { - forAll { (keyType: String, key: String) ⇒ + forAll { (keyType: String, key: String) => val source = ConfigSource.catchNonFatal(ConfigKeyType(keyType))(identity) source.read(key) shouldBe Right(key) } } "fail if a non-fatal exception is thrown" in { - forAll { (keyType: String, key: String) ⇒ - val source = ConfigSource.catchNonFatal(ConfigKeyType(keyType))(_ ⇒ throw new Error) + forAll { (keyType: String, key: String) => + val source = ConfigSource.catchNonFatal(ConfigKeyType(keyType))(_ => throw new Error) source.read(key) shouldBe a[Left[_, _]] } } diff --git a/modules/core/shared/src/test/scala/ciris/LoadConfigsSpec.scala b/modules/core/shared/src/test/scala/ciris/LoadConfigsSpec.scala index 7e0af2ee..629b7a0a 100644 --- a/modules/core/shared/src/test/scala/ciris/LoadConfigsSpec.scala +++ b/modules/core/shared/src/test/scala/ciris/LoadConfigsSpec.scala @@ -10,7 +10,7 @@ package ciris final class LoadConfigsSpec extends PropertySpec { "LoadConfigs" when { "loading configurations" when { - implicit val source: ConfigSource = sourceWith("key1" → "value1", "key2" → "value2", "key3" → "value3", "key4" → "value4", "key5" → "value5", "key6" → "value6", "key7" → "value7", "key8" → "value8", "key9" → "value9", "key10" → "value10", "key11" → "value11", "key12" → "value12", "key13" → "value13", "key14" → "value14", "key15" → "value15", "key16" → "value16", "key17" → "value17", "key18" → "value18", "key19" → "value19", "key20" → "value20", "key21" → "value21", "key22" → "value22") + implicit val source: ConfigSource = sourceWith("key1" -> "value1", "key2" -> "value2", "key3" -> "value3", "key4" -> "value4", "key5" -> "value5", "key6" -> "value6", "key7" -> "value7", "key8" -> "value8", "key9" -> "value9", "key10" -> "value10", "key11" -> "value11", "key12" -> "value12", "key13" -> "value13", "key14" -> "value14", "key15" -> "value15", "key16" -> "value16", "key17" -> "value17", "key18" -> "value18", "key19" -> "value19", "key20" -> "value20", "key21" -> "value21", "key22" -> "value22") "loading 0 keys" should { "always be able to load" in { diff --git a/modules/core/shared/src/test/scala/ciris/PropertySpec.scala b/modules/core/shared/src/test/scala/ciris/PropertySpec.scala index 6d573fa8..4940f2b6 100644 --- a/modules/core/shared/src/test/scala/ciris/PropertySpec.scala +++ b/modules/core/shared/src/test/scala/ciris/PropertySpec.scala @@ -12,21 +12,21 @@ class PropertySpec extends WordSpec with Matchers with PropertyChecks { def mixedCase(string: String): Gen[String] = { (for { - lowers ← Gen.listOfN(string.length, Gen.oneOf(true, false)) - (lower, char) ← lowers zip string + lowers <- Gen.listOfN(string.length, Gen.oneOf(true, false)) + (lower, char) <- lowers zip string } yield if (lower) char.toLower else char.toUpper).map(_.mkString) } - def mixedCaseEnum[T](values: Array[T])(f: T ⇒ String): Gen[(T, String)] = + def mixedCaseEnum[T](values: Array[T])(f: T => String): Gen[(T, String)] = for { - value ← Gen.oneOf(values) - valueString ← mixedCase(f(value)) + value <- Gen.oneOf(values) + valueString <- mixedCase(f(value)) } yield (value, valueString) - def fails[A](f: ⇒ A): Boolean = Try(f).isFailure + def fails[A](f: => A): Boolean = Try(f).isFailure def readValue[A](value: String)(implicit reader: ConfigReader[A]): Either[ConfigError, A] = - reader.read("key")(sourceWith("key" → value)) + reader.read("key")(sourceWith("key" -> value)) def readNonExistingValue[A](implicit reader: ConfigReader[A]): Either[ConfigError, A] = reader.read("key")(sourceWith()) diff --git a/modules/core/shared/src/test/scala/ciris/generators/JavaTimeGenerators.scala b/modules/core/shared/src/test/scala/ciris/generators/JavaTimeGenerators.scala index 005e29db..4cd1243a 100644 --- a/modules/core/shared/src/test/scala/ciris/generators/JavaTimeGenerators.scala +++ b/modules/core/shared/src/test/scala/ciris/generators/JavaTimeGenerators.scala @@ -53,7 +53,7 @@ trait JavaTimeGenerators { Arbitrary(genZonedDateTime.map(_.toLocalTime)) implicit val arbMonthDay: Arbitrary[MonthDay] = - Arbitrary(genZonedDateTime.map(date ⇒ MonthDay.of(date.getMonth, date.getDayOfMonth))) + Arbitrary(genZonedDateTime.map(date => MonthDay.of(date.getMonth, date.getDayOfMonth))) implicit val arbOffsetDateTime: Arbitrary[OffsetDateTime] = Arbitrary(genZonedDateTime.map(_.toOffsetDateTime)) @@ -65,10 +65,10 @@ trait JavaTimeGenerators { Arbitrary(Gen.choose(0, Int.MaxValue).map(Period.ofDays)) implicit val arbYear: Arbitrary[Year] = - Arbitrary(genZonedDateTime.map(date ⇒ Year.of(date.getYear))) + Arbitrary(genZonedDateTime.map(date => Year.of(date.getYear))) implicit val arbYearMonth: Arbitrary[YearMonth] = - Arbitrary(genZonedDateTime.map(date ⇒ YearMonth.of(date.getYear, date.getMonth))) + Arbitrary(genZonedDateTime.map(date => YearMonth.of(date.getYear, date.getMonth))) implicit val arbZoneId: Arbitrary[ZoneId] = Arbitrary(Gen.oneOf(ZoneId.getAvailableZoneIds.asScala.toList).map(ZoneId.of)) diff --git a/modules/core/shared/src/test/scala/ciris/readers/DerivedConfigReadersSpec.scala b/modules/core/shared/src/test/scala/ciris/readers/DerivedConfigReadersSpec.scala index b00f21f7..d235ed02 100644 --- a/modules/core/shared/src/test/scala/ciris/readers/DerivedConfigReadersSpec.scala +++ b/modules/core/shared/src/test/scala/ciris/readers/DerivedConfigReadersSpec.scala @@ -6,7 +6,7 @@ final class DerivedConfigReadersSpec extends PropertySpec { "DerivedConfigReaders" when { "reading an Option" should { "successfully read existing values" in { - forAll { string: String ⇒ + forAll { string: String => readValue[Option[String]](string) shouldBe Right(Some(string)) } } diff --git a/modules/core/shared/src/test/scala/ciris/readers/DurationConfigReadersSpec.scala b/modules/core/shared/src/test/scala/ciris/readers/DurationConfigReadersSpec.scala index 3be8274b..eaf2b8cb 100644 --- a/modules/core/shared/src/test/scala/ciris/readers/DurationConfigReadersSpec.scala +++ b/modules/core/shared/src/test/scala/ciris/readers/DurationConfigReadersSpec.scala @@ -10,7 +10,7 @@ final class DurationConfigReadersSpec extends PropertySpec with DurationGenerato "DurationConfigReaders" when { "reading a Duration" should { "successfully read Duration values" in { - forAll { duration: Duration ⇒ + forAll { duration: Duration => val durationString = if (duration.toString startsWith "Duration.") duration.toString.drop(9) @@ -25,7 +25,7 @@ final class DurationConfigReadersSpec extends PropertySpec with DurationGenerato } "return a failure for other values" in { - forAll { string: String ⇒ + forAll { string: String => whenever(fails(Duration(string))) { readValue[Duration](string) shouldBe a[Left[_, _]] } @@ -35,7 +35,7 @@ final class DurationConfigReadersSpec extends PropertySpec with DurationGenerato "reading a FiniteDuration" should { "successfully read FiniteDuration values" in { - forAll { finiteDuration: FiniteDuration ⇒ + forAll { finiteDuration: FiniteDuration => val value = readValue[FiniteDuration](finiteDuration.toString) value.right.map(_.toNanos) shouldBe Right(finiteDuration.toNanos) } @@ -43,13 +43,13 @@ final class DurationConfigReadersSpec extends PropertySpec with DurationGenerato "return a failure for infinite durations" in { val infiniteDurations = List("Inf", "PlusInf", "+Inf", "MinusInf", "-Inf") - forAll(Gen.oneOf(infiniteDurations)){ infiniteDuration ⇒ + forAll(Gen.oneOf(infiniteDurations)){ infiniteDuration => readValue[FiniteDuration](infiniteDuration) shouldBe a[Left[_, _]] } } "return a failure for other values" in { - forAll { string: String ⇒ + forAll { string: String => whenever(fails(Duration(string)) || !Duration(string).isFinite()) { readValue[FiniteDuration](string) shouldBe a[Left[_, _]] } diff --git a/modules/core/shared/src/test/scala/ciris/readers/JavaNioCharsetConfigReadersSpec.scala b/modules/core/shared/src/test/scala/ciris/readers/JavaNioCharsetConfigReadersSpec.scala index 744e002e..606f0993 100644 --- a/modules/core/shared/src/test/scala/ciris/readers/JavaNioCharsetConfigReadersSpec.scala +++ b/modules/core/shared/src/test/scala/ciris/readers/JavaNioCharsetConfigReadersSpec.scala @@ -8,7 +8,7 @@ final class JavaNioCharsetConfigReadersSpec extends PropertySpec { "JavaNioCharsetConfigReaders" when { "reading a Charset" should { "return a failure for unrecognized values" in { - forAll { string: String ⇒ + forAll { string: String => whenever(fails(Charset.forName(string))) { readValue[Charset](string) shouldBe a[Left[_, _]] } diff --git a/modules/core/shared/src/test/scala/ciris/readers/JavaUtilConfigReadersSpec.scala b/modules/core/shared/src/test/scala/ciris/readers/JavaUtilConfigReadersSpec.scala index 3ab0b742..f68c2e44 100644 --- a/modules/core/shared/src/test/scala/ciris/readers/JavaUtilConfigReadersSpec.scala +++ b/modules/core/shared/src/test/scala/ciris/readers/JavaUtilConfigReadersSpec.scala @@ -11,14 +11,14 @@ final class JavaUtilConfigReadersSpec extends PropertySpec { "reading a regex Pattern" should { "successfully read Pattern values" in { val examplePatterns = List("[a-z&&[def]]", "(\\D)") - forAll(Gen.oneOf(examplePatterns)) { examplePattern ⇒ + forAll(Gen.oneOf(examplePatterns)) { examplePattern => readValue[Pattern](examplePattern) shouldBe a[Right[_, _]] } } "return a failure for other values" in { val exampleInvalidPatterns = List("[AB", "(CD[E]") - forAll(Gen.oneOf(exampleInvalidPatterns)) { exampleInvalidPattern ⇒ + forAll(Gen.oneOf(exampleInvalidPatterns)) { exampleInvalidPattern => readValue[Pattern](exampleInvalidPattern) shouldBe a[Left[_, _]] } } @@ -26,13 +26,13 @@ final class JavaUtilConfigReadersSpec extends PropertySpec { "reading an UUID" should { "successfully read UUID values" in { - forAll(Gen.uuid) { uuid ⇒ + forAll(Gen.uuid) { uuid => readValue[UUID](uuid.toString) shouldBe Right(uuid) } } "return a failure for other values" in { - forAll { string: String ⇒ + forAll { string: String => whenever(fails(UUID.fromString(string))) { readValue[UUID](string) shouldBe a[Left[_, _]] } diff --git a/modules/core/shared/src/test/scala/ciris/readers/MathConfigReadersSpec.scala b/modules/core/shared/src/test/scala/ciris/readers/MathConfigReadersSpec.scala index 6452506d..dd34f92c 100644 --- a/modules/core/shared/src/test/scala/ciris/readers/MathConfigReadersSpec.scala +++ b/modules/core/shared/src/test/scala/ciris/readers/MathConfigReadersSpec.scala @@ -6,13 +6,13 @@ final class MathConfigReadersSpec extends PropertySpec { "MathConfigReaders" when { "reading a BigInt" should { "successfully read BigInt values" in { - forAll { bigInt: BigInt ⇒ + forAll { bigInt: BigInt => readValue[BigInt](bigInt.toString) shouldBe Right(bigInt) } } "return a failure for other values" in { - forAll { string: String ⇒ + forAll { string: String => whenever(fails(BigInt(string))) { readValue[BigInt](string) shouldBe a[Left[_, _]] } @@ -22,14 +22,14 @@ final class MathConfigReadersSpec extends PropertySpec { "reading a BigDecimal" should { "successfully read BigDecimal values" in { - forAll { double: Double ⇒ + forAll { double: Double => val doubleString = double.toString readValue[BigDecimal](doubleString) shouldBe Right(BigDecimal(doubleString)) } } "return a failure for other values" in { - forAll { string: String ⇒ + forAll { string: String => whenever(fails(BigDecimal(string))) { readValue[BigDecimal](string) shouldBe a[Left[_, _]] } diff --git a/modules/core/shared/src/test/scala/ciris/readers/PrimitiveConfigReadersSpec.scala b/modules/core/shared/src/test/scala/ciris/readers/PrimitiveConfigReadersSpec.scala index d873e112..74f93605 100644 --- a/modules/core/shared/src/test/scala/ciris/readers/PrimitiveConfigReadersSpec.scala +++ b/modules/core/shared/src/test/scala/ciris/readers/PrimitiveConfigReadersSpec.scala @@ -6,19 +6,19 @@ final class PrimitiveConfigReadersSpec extends PropertySpec { "PrimitiveConfigReaders" when { "reading a Boolean" should { "successfully read true values" in { - forAll(mixedCase("true")) { string ⇒ + forAll(mixedCase("true")) { string => readValue[Boolean](string) shouldBe Right(true) } } "successfully read false values" in { - forAll(mixedCase("false")) { string ⇒ + forAll(mixedCase("false")) { string => readValue[Boolean](string) shouldBe Right(false) } } "return a failure for other values" in { - forAll { string: String ⇒ + forAll { string: String => whenever(fails(string.toBoolean)) { readValue[Boolean](string) shouldBe a[Left[_, _]] } @@ -28,13 +28,13 @@ final class PrimitiveConfigReadersSpec extends PropertySpec { "reading a Byte" should { "successfully read Byte values" in { - forAll { byte: Byte ⇒ + forAll { byte: Byte => readValue[Byte](byte.toString) shouldBe Right(byte) } } "return a failure for other values" in { - forAll { string: String ⇒ + forAll { string: String => whenever(fails(string.toByte)) { readValue[Byte](string) shouldBe a[Left[_, _]] } @@ -44,13 +44,13 @@ final class PrimitiveConfigReadersSpec extends PropertySpec { "reading a Char" should { "successfully read Char values" in { - forAll { char: Char ⇒ + forAll { char: Char => readValue[Char](char.toString) shouldBe Right(char) } } "return a failure for other values" in { - forAll { string: String ⇒ + forAll { string: String => whenever(string.length != 1) { readValue[Char](string.toString) shouldBe a[Left[_, _]] } @@ -60,19 +60,19 @@ final class PrimitiveConfigReadersSpec extends PropertySpec { "reading a Double" should { "successfully read Double values" in { - forAll { double: Double ⇒ + forAll { double: Double => readValue[Double](double.toString) shouldBe Right(double) } } "successfully read Double percentage values" in { - forAll { double: Double ⇒ + forAll { double: Double => readValue[Double](double.toString + "%") shouldBe Right(double / 100d) } } "return a failure for other values" in { - forAll { string: String ⇒ + forAll { string: String => whenever(fails(string.toDouble)) { readValue[Double](string.toString) shouldBe a[Left[_, _]] } @@ -82,19 +82,19 @@ final class PrimitiveConfigReadersSpec extends PropertySpec { "reading a Float" should { "successfully read Float values" in { - forAll { float: Float ⇒ + forAll { float: Float => readValue[Float](float.toString) shouldBe Right(float) } } "successfully read Float percentage values" in { - forAll { float: Float ⇒ + forAll { float: Float => readValue[Float](float.toString + "%") shouldBe Right(float / 100f) } } "return a failure for other values" in { - forAll { string: String ⇒ + forAll { string: String => whenever(fails(string.toFloat)) { readValue[Float](string) shouldBe a[Left[_, _]] } @@ -104,13 +104,13 @@ final class PrimitiveConfigReadersSpec extends PropertySpec { "reading an Int" should { "successfully read Int values" in { - forAll { int: Int ⇒ + forAll { int: Int => readValue[Int](int.toString) shouldBe Right(int) } } "return a failure for other values" in { - forAll { string: String ⇒ + forAll { string: String => whenever(fails(string.toInt)) { readValue[Int](string) shouldBe a[Left[_, _]] } @@ -120,13 +120,13 @@ final class PrimitiveConfigReadersSpec extends PropertySpec { "reading a Long" should { "successfully read Long values" in { - forAll { long: Long ⇒ + forAll { long: Long => readValue[Long](long.toString) shouldBe Right(long) } } "return a failure for other values" in { - forAll { string: String ⇒ + forAll { string: String => whenever(fails(string.toLong)) { readValue[Int](string) shouldBe a[Left[_, _]] } @@ -136,13 +136,13 @@ final class PrimitiveConfigReadersSpec extends PropertySpec { "reading a Short" should { "successfully read Short values" in { - forAll { short: Short ⇒ + forAll { short: Short => readValue[Short](short.toString) shouldBe Right(short) } } "return a failure for other values" in { - forAll { string: String ⇒ + forAll { string: String => whenever(fails(string.toShort)) { readValue[Short](string) shouldBe a[Left[_, _]] } @@ -152,7 +152,7 @@ final class PrimitiveConfigReadersSpec extends PropertySpec { "reading a String" should { "successfully read String values" in { - forAll { string: String ⇒ + forAll { string: String => readValue[String](string) shouldBe Right(string) } } diff --git a/modules/enumeratum/shared/src/main/scala/ciris/enumeratum/readers/EnumeratumConfigReaders.scala b/modules/enumeratum/shared/src/main/scala/ciris/enumeratum/readers/EnumeratumConfigReaders.scala index 27c8aa29..78e683a9 100644 --- a/modules/enumeratum/shared/src/main/scala/ciris/enumeratum/readers/EnumeratumConfigReaders.scala +++ b/modules/enumeratum/shared/src/main/scala/ciris/enumeratum/readers/EnumeratumConfigReaders.scala @@ -11,16 +11,16 @@ trait EnumeratumConfigReaders { private def fromOption[ From: ConfigReader, To: ClassTag - ](f: From ⇒ Option[To]): ConfigReader[To] = - ConfigReader.pure { (key, source) ⇒ + ](f: From => Option[To]): ConfigReader[To] = + ConfigReader.pure { (key, source) => ConfigReader[From] .read(key)(source) .fold( Left.apply, - value ⇒ { + value => { f(value) match { - case Some(to) ⇒ Right(to) - case None ⇒ + case Some(to) => Right(to) + case None => val typeName = implicitly[ClassTag[To]].runtimeClass.getName Left(WrongType(key, value, typeName, source.keyType)) } diff --git a/modules/enumeratum/shared/src/test/scala/ciris/enumeratum/readers/EnumeratumConfigReadersSpec.scala b/modules/enumeratum/shared/src/test/scala/ciris/enumeratum/readers/EnumeratumConfigReadersSpec.scala index ef512344..21e97d07 100644 --- a/modules/enumeratum/shared/src/test/scala/ciris/enumeratum/readers/EnumeratumConfigReadersSpec.scala +++ b/modules/enumeratum/shared/src/test/scala/ciris/enumeratum/readers/EnumeratumConfigReadersSpec.scala @@ -75,19 +75,19 @@ final class EnumeratumConfigReadersSpec extends PropertySpec { "EnumeratumConfigReaders" when { "reading a ByteEnum" should { "successfully read ByteEnum values" in { - forAll(Gen.oneOf(ByteEnumItem.values)) { enum ⇒ + forAll(Gen.oneOf(ByteEnumItem.values)) { enum => readValue[ByteEnumItem](enum.value.toString) shouldBe Right(enum) } } "successfully read optional ByteEnum values" in { - forAll(Gen.oneOf(ByteEnumItem.values)) { enum ⇒ + forAll(Gen.oneOf(ByteEnumItem.values)) { enum => readValue[Option[ByteEnumItem]](enum.value.toString) shouldBe Right(Some(enum)) } } "return a failure for other values" in { - forAll { byte: Byte ⇒ + forAll { byte: Byte => whenever(ByteEnumItem.withValueOpt(byte).isEmpty) { readValue[ByteEnumItem](byte.toString) shouldBe a[Left[_, _]] } @@ -95,7 +95,7 @@ final class EnumeratumConfigReadersSpec extends PropertySpec { } "return a failure for wrong type values" in { - forAll { string: String ⇒ + forAll { string: String => whenever(fails(string.toByte)) { readValue[ByteEnumItem](string) shouldBe a[Left[_, _]] } @@ -105,19 +105,19 @@ final class EnumeratumConfigReadersSpec extends PropertySpec { "reading a CharEnum" should { "successfully read CharEnum values" in { - forAll(Gen.oneOf(CharEnumItem.values)) { enum ⇒ + forAll(Gen.oneOf(CharEnumItem.values)) { enum => readValue[CharEnumItem](enum.value.toString) shouldBe Right(enum) } } "successfully read optional CharEnum values" in { - forAll(Gen.oneOf(CharEnumItem.values)) { enum ⇒ + forAll(Gen.oneOf(CharEnumItem.values)) { enum => readValue[Option[CharEnumItem]](enum.value.toString) shouldBe Right(Some(enum)) } } "return a failure for other values" in { - forAll { char: Char ⇒ + forAll { char: Char => whenever(CharEnumItem.withValueOpt(char).isEmpty) { readValue[CharEnumItem](char.toString) shouldBe a[Left[_, _]] } @@ -125,7 +125,7 @@ final class EnumeratumConfigReadersSpec extends PropertySpec { } "return a failure for wrong type values" in { - forAll { string: String ⇒ + forAll { string: String => whenever(string.length != 1) { readValue[CharEnumItem](string) shouldBe a[Left[_, _]] } @@ -135,19 +135,19 @@ final class EnumeratumConfigReadersSpec extends PropertySpec { "reading an EnumEntry" should { "successfully read EnumEntry names" in { - forAll(Gen.oneOf(EnumEntryItem.values)) { enum ⇒ + forAll(Gen.oneOf(EnumEntryItem.values)) { enum => readValue[EnumEntryItem](enum.entryName) shouldBe Right(enum) } } "successfully read optional EnumEntry names" in { - forAll(Gen.oneOf(EnumEntryItem.values)) { enum ⇒ + forAll(Gen.oneOf(EnumEntryItem.values)) { enum => readValue[Option[EnumEntryItem]](enum.entryName) shouldBe Right(Some(enum)) } } "return a failure for other values" in { - forAll { string: String ⇒ + forAll { string: String => whenever(EnumEntryItem.withNameOption(string).isEmpty) { readValue[EnumEntryItem](string) shouldBe a[Left[_, _]] } @@ -157,19 +157,19 @@ final class EnumeratumConfigReadersSpec extends PropertySpec { "reading an IntEnum" should { "successfully read IntEnum values" in { - forAll(Gen.oneOf(IntEnumItem.values)) { enum ⇒ + forAll(Gen.oneOf(IntEnumItem.values)) { enum => readValue[IntEnumItem](enum.value.toString) shouldBe Right(enum) } } "successfully read optional IntEnum values" in { - forAll(Gen.oneOf(IntEnumItem.values)) { enum ⇒ + forAll(Gen.oneOf(IntEnumItem.values)) { enum => readValue[Option[IntEnumItem]](enum.value.toString) shouldBe Right(Some(enum)) } } "return a failure for other values" in { - forAll { int: Int ⇒ + forAll { int: Int => whenever(IntEnumItem.withValueOpt(int).isEmpty) { readValue[IntEnumItem](int.toString) shouldBe a[Left[_, _]] } @@ -177,7 +177,7 @@ final class EnumeratumConfigReadersSpec extends PropertySpec { } "return a failure for wrong type values" in { - forAll { string: String ⇒ + forAll { string: String => whenever(fails(string.toInt)) { readValue[IntEnumItem](string) shouldBe a[Left[_, _]] } @@ -187,19 +187,19 @@ final class EnumeratumConfigReadersSpec extends PropertySpec { "reading a LongEnum" should { "successfully read LongEnum values" in { - forAll(Gen.oneOf(LongEnumItem.values)) { enum ⇒ + forAll(Gen.oneOf(LongEnumItem.values)) { enum => readValue[LongEnumItem](enum.value.toString) shouldBe Right(enum) } } "successfully read optional LongEnum values" in { - forAll(Gen.oneOf(LongEnumItem.values)) { enum ⇒ + forAll(Gen.oneOf(LongEnumItem.values)) { enum => readValue[Option[LongEnumItem]](enum.value.toString) shouldBe Right(Some(enum)) } } "return a failure for other values" in { - forAll { long: Long ⇒ + forAll { long: Long => whenever(LongEnumItem.withValueOpt(long).isEmpty) { readValue[LongEnumItem](long.toString) shouldBe a[Left[_, _]] } @@ -207,7 +207,7 @@ final class EnumeratumConfigReadersSpec extends PropertySpec { } "return a failure for wrong type values" in { - forAll { string: String ⇒ + forAll { string: String => whenever(fails(string.toLong)) { readValue[LongEnumItem](string) shouldBe a[Left[_, _]] } @@ -217,19 +217,19 @@ final class EnumeratumConfigReadersSpec extends PropertySpec { "reading a ShortEnum" should { "successfully read ShortEnum values" in { - forAll(Gen.oneOf(ShortEnumItem.values)) { enum ⇒ + forAll(Gen.oneOf(ShortEnumItem.values)) { enum => readValue[ShortEnumItem](enum.value.toString) shouldBe Right(enum) } } "successfully read optional ShortEnum values" in { - forAll(Gen.oneOf(ShortEnumItem.values)) { enum ⇒ + forAll(Gen.oneOf(ShortEnumItem.values)) { enum => readValue[Option[ShortEnumItem]](enum.value.toString) shouldBe Right(Some(enum)) } } "return a failure for other values" in { - forAll { short: Short ⇒ + forAll { short: Short => whenever(ShortEnumItem.withValueOpt(short).isEmpty) { readValue[ShortEnumItem](short.toString) shouldBe a[Left[_, _]] } @@ -237,7 +237,7 @@ final class EnumeratumConfigReadersSpec extends PropertySpec { } "return a failure for wrong type values" in { - forAll { string: String ⇒ + forAll { string: String => whenever(fails(string.toShort)) { readValue[ShortEnumItem](string) shouldBe a[Left[_, _]] } @@ -247,19 +247,19 @@ final class EnumeratumConfigReadersSpec extends PropertySpec { "reading a StringEnum" should { "successfully read StringEnum values" in { - forAll(Gen.oneOf(StringEnumItem.values)) { enum ⇒ + forAll(Gen.oneOf(StringEnumItem.values)) { enum => readValue[StringEnumItem](enum.value.toString) shouldBe Right(enum) } } "successfully read optional StringEnum values" in { - forAll(Gen.oneOf(StringEnumItem.values)) { enum ⇒ + forAll(Gen.oneOf(StringEnumItem.values)) { enum => readValue[Option[StringEnumItem]](enum.value.toString) shouldBe Right(Some(enum)) } } "return a failure for other values" in { - forAll { string: String ⇒ + forAll { string: String => whenever(StringEnumItem.withValueOpt(string).isEmpty) { readValue[StringEnumItem](string) shouldBe a[Left[_, _]] } diff --git a/modules/generic/jvm/src/main/scala/ciris/generic/readers/GenericConfigReaders.scala b/modules/generic/jvm/src/main/scala/ciris/generic/readers/GenericConfigReaders.scala index 253d9e30..ede2eb08 100644 --- a/modules/generic/jvm/src/main/scala/ciris/generic/readers/GenericConfigReaders.scala +++ b/modules/generic/jvm/src/main/scala/ciris/generic/readers/GenericConfigReaders.scala @@ -5,7 +5,7 @@ import shapeless.{:+:, ::, CNil, Coproduct, Generic, HNil, Inl, Inr, Lazy} trait GenericConfigReaders { implicit val cNilConfigReader: ConfigReader[CNil] = - ConfigReader.pure { (key, source) ⇒ + ConfigReader.pure { (key, source) => Left(ConfigError( s"Could not find any valid coproduct choice while reading ${source.keyType.value} [$key]")) } @@ -14,13 +14,13 @@ trait GenericConfigReaders { implicit readA: Lazy[ConfigReader[A]], readB: ConfigReader[B] ): ConfigReader[A :+: B] = { - ConfigReader.pure { (key, source) ⇒ + ConfigReader.pure { (key, source) => readA.value.read(key)(source) match { - case Right(a) ⇒ Right(Inl(a)) - case Left(aError) ⇒ + case Right(a) => Right(Inl(a)) + case Left(aError) => readB.read(key)(source) match { - case Right(b) ⇒ Right(Inr(b)) - case Left(bError) ⇒ Left(aError combine bError) + case Right(b) => Right(Inr(b)) + case Left(bError) => Left(aError combine bError) } } } diff --git a/modules/generic/jvm/src/test/scala/ciris/generic/readers/GenericConfigReadersSpec.scala b/modules/generic/jvm/src/test/scala/ciris/generic/readers/GenericConfigReadersSpec.scala index a7c89664..526caf4c 100644 --- a/modules/generic/jvm/src/test/scala/ciris/generic/readers/GenericConfigReadersSpec.scala +++ b/modules/generic/jvm/src/test/scala/ciris/generic/readers/GenericConfigReadersSpec.scala @@ -16,13 +16,13 @@ final class GenericConfigReadersSpec extends PropertySpec { "ShapelessConfigReaders" when { "reading value classes" should { "successfully read value classes" in { - forAll { value: Int ⇒ + forAll { value: Int => readValue[Port](value.toString) shouldBe Right(Port(value)) } } "return a failure for the wrong type" in { - forAll { value: String ⇒ + forAll { value: String => whenever(fails(value.toInt)) { readValue[Port](value) shouldBe a[Left[_, _]] } @@ -34,19 +34,19 @@ final class GenericConfigReadersSpec extends PropertySpec { type DoubleOrBooleanCoproduct = DoubleValue :+: BooleanValue :+: CNil "successfully read coproduct values" in { - forAll { double: Double ⇒ + forAll { double: Double => readValue[DoubleOrBooleanCoproduct](double.toString) shouldBe Right(Coproduct[DoubleOrBooleanCoproduct](DoubleValue(double))) } - forAll { boolean: Boolean ⇒ + forAll { boolean: Boolean => readValue[DoubleOrBooleanCoproduct](boolean.toString) shouldBe Right(Coproduct[DoubleOrBooleanCoproduct](BooleanValue(boolean))) } } "return a failure for wrong coproduct values" in { - forAll { string: String ⇒ + forAll { string: String => whenever(fails(string.toDouble)) { whenever(fails(string.toBoolean)) { readValue[DoubleOrBooleanCoproduct](string) shouldBe a[Left[_, _]] @@ -56,19 +56,19 @@ final class GenericConfigReadersSpec extends PropertySpec { } "successfully read generic coproduct values" in { - forAll { double: Double ⇒ + forAll { double: Double => readValue[DoubleOrBoolean](double.toString) shouldBe Right(DoubleValue(double)) } - forAll { boolean: Boolean ⇒ + forAll { boolean: Boolean => readValue[DoubleOrBoolean](boolean.toString) shouldBe Right(BooleanValue(boolean)) } } "return a failure for wrong generic coproduct values" in { - forAll { string: String ⇒ + forAll { string: String => whenever(fails(string.toDouble)) { whenever(fails(string.toBoolean)) { readValue[DoubleOrBoolean](string) shouldBe a[Left[_, _]] @@ -80,13 +80,13 @@ final class GenericConfigReadersSpec extends PropertySpec { "reading products with arity one" should { "successfully read product values" in { - forAll { int: Int ⇒ + forAll { int: Int => readValue[IntValue](int.toString) shouldBe Right(IntValue(int)) } } "return a failure for wrong product values" in { - forAll { string: String ⇒ + forAll { string: String => whenever(fails(string.toInt)) { readValue[IntValue](string) shouldBe a[Left[_, _]] } diff --git a/modules/refined/shared/src/test/scala/ciris/refined/readers/RefinedConfigReadersSpec.scala b/modules/refined/shared/src/test/scala/ciris/refined/readers/RefinedConfigReadersSpec.scala index ef2a2716..b79a6df9 100644 --- a/modules/refined/shared/src/test/scala/ciris/refined/readers/RefinedConfigReadersSpec.scala +++ b/modules/refined/shared/src/test/scala/ciris/refined/readers/RefinedConfigReadersSpec.scala @@ -9,19 +9,19 @@ final class RefinedConfigReadersSpec extends PropertySpec { "RefinedConfigReaders" when { "reading a RefType" should { "successfully read RefType values" in { - forAll(Gen.posNum[Int]) { posInt ⇒ + forAll(Gen.posNum[Int]) { posInt => readValue[PosInt](posInt.toString).right.map(_.value) shouldBe Right(posInt) } } "successfully read optional RefType values" in { - forAll(Gen.posNum[Int]) { posInt ⇒ + forAll(Gen.posNum[Int]) { posInt => readValue[Option[PosInt]](posInt.toString).right.map(_.map(_.value)) shouldBe Right(Some(posInt)) } } "return a failure for wrong type" in { - forAll(Gen.choose(Int.MinValue, 0)) { nonPosInt ⇒ + forAll(Gen.choose(Int.MinValue, 0)) { nonPosInt => readValue[PosInt](nonPosInt.toString) shouldBe a[Left[_, _]] } } diff --git a/modules/squants/shared/src/test/scala/ciris/squants/generators/SquantsGenerators.scala b/modules/squants/shared/src/test/scala/ciris/squants/generators/SquantsGenerators.scala index 5b79a44e..d55520a6 100644 --- a/modules/squants/shared/src/test/scala/ciris/squants/generators/SquantsGenerators.scala +++ b/modules/squants/shared/src/test/scala/ciris/squants/generators/SquantsGenerators.scala @@ -8,8 +8,8 @@ import squants.{Dimension, Quantity} trait SquantsGenerators { def genQuantity[A <: Quantity[A]](dimension: Dimension[A]): Gen[A] = for { - value ← arbitrary[Double] - unit ← Gen.oneOf(dimension.units.toList) + value <- arbitrary[Double] + unit <- Gen.oneOf(dimension.units.toList) } yield unit(value) val genCurrency: Gen[Currency] = @@ -43,8 +43,8 @@ trait SquantsGenerators { val genMoney: Gen[Money] = for { - value ← arbitrary[Double] - currency ← genCurrency + value <- arbitrary[Double] + currency <- genCurrency } yield { val moneyValue = BigDecimal(value) diff --git a/modules/squants/shared/src/test/scala/ciris/squants/readers/SquantsConfigReadersSpec.scala b/modules/squants/shared/src/test/scala/ciris/squants/readers/SquantsConfigReadersSpec.scala index 7f6fda01..69828c47 100644 --- a/modules/squants/shared/src/test/scala/ciris/squants/readers/SquantsConfigReadersSpec.scala +++ b/modules/squants/shared/src/test/scala/ciris/squants/readers/SquantsConfigReadersSpec.scala @@ -101,25 +101,25 @@ final class SquantsConfigReadersSpec extends PropertySpec with SquantsGenerators def testDimension[A <: Quantity[A]: ConfigReader: ClassTag]( dimension: Dimension[A], - apply: String ⇒ Try[A] + apply: String => Try[A] ): Unit = { val typeName: String = implicitly[ClassTag[A]].runtimeClass.getSimpleName s"reading a $typeName" should { s"successfully read $typeName values" in { - forAll(genQuantity(dimension)) { quantity ⇒ + forAll(genQuantity(dimension)) { quantity => readValue[A](quantity.toString) shouldBe Right(quantity) } } s"successfully read optional $typeName values" in { - forAll(genQuantity(dimension)) { quantity ⇒ + forAll(genQuantity(dimension)) { quantity => readValue[Option[A]](quantity.toString) shouldBe Right(Some(quantity)) } } "return a failure for other values" in { - forAll { string: String ⇒ + forAll { string: String => whenever(apply(string).isFailure) { readValue[A](string) shouldBe a[Left[_, _]] } @@ -131,19 +131,19 @@ final class SquantsConfigReadersSpec extends PropertySpec with SquantsGenerators def testMoney(): Unit = { "reading a Money" should { "successfully read Money values" in { - forAll(genMoney) { money ⇒ + forAll(genMoney) { money => readValue[Money](money.toString) shouldBe Right(money) } } "successfully read optional Money values" in { - forAll(genMoney) { money ⇒ + forAll(genMoney) { money => readValue[Option[Money]](money.toString) shouldBe Right(Some(money)) } } "return a failure for other values" in { - forAll { string: String ⇒ + forAll { string: String => whenever(market.Money(string).isFailure) { readValue[Money](string) shouldBe a[Left[_, _]] } diff --git a/project/LatestVersion.scala b/project/LatestVersion.scala index 7112702d..625e8804 100644 --- a/project/LatestVersion.scala +++ b/project/LatestVersion.scala @@ -17,7 +17,7 @@ object LatestVersion extends AutoPlugin { val latestVersionFileContents = s"""latestVersion in ThisBuild := "$newLatestVersion"""" + "\n" IO.write(latestVersionFile, latestVersionFileContents) - Vcs.detect(file(".")).foreach { vcs ⇒ + Vcs.detect(file(".")).foreach { vcs => vcs.add(latestVersionFile.getPath) !! state.log vcs.commit(s"Set latest version to $newLatestVersion", sign = true) !! state.log } diff --git a/project/SourceGenerators.scala b/project/SourceGenerators.scala index 3f69c8df..047e826f 100644 --- a/project/SourceGenerators.scala +++ b/project/SourceGenerators.scala @@ -38,7 +38,7 @@ object SourceGenerators extends AutoPlugin { * Generates: {{{ $prefix1${sep}$prefix2$sep...$prefix$n$sep }}} */ def valueParams(n: Int, sep: String = ", ", prefix: String = "a"): String = - (1 to n).map(i ⇒ valueParam(i, prefix)).mkString(sep) + (1 to n).map(i => valueParam(i, prefix)).mkString(sep) /** * Generates: {{{ $prefix$n }}} @@ -48,15 +48,15 @@ object SourceGenerators extends AutoPlugin { /** * Generates: {{{ a1: ${typeName(1)}, a2: ${typeName(2)},..., a$n: ${typeName(n)} }}} */ - def args(n: Int, typeName: Int ⇒ String): String = - (1 to n).map(i ⇒ s"${valueParam(i)}: ${typeName(i)}").mkString(", ") + def args(n: Int, typeName: Int => String): String = + (1 to n).map(i => s"${valueParam(i)}: ${typeName(i)}").mkString(", ") def generateLoadConfigs(sourcesRoot: File, rootPackage: String): Seq[File] = { val defs = (2 until maximumNumberOfParams) - .map { current ⇒ + .map { current => val params = typeParams(current) - val firstArgs = args(current, arg ⇒ s"ConfigValue[${typeParam(arg)}]") + val firstArgs = args(current, arg => s"ConfigValue[${typeParam(arg)}]") val loadConfigSecondArgs = s"f: (${typeParams(current)}) => Z" val withValuesSecondArgs = s"f: (${typeParams(current)}) => Either[ConfigErrors, Z]" @@ -83,14 +83,14 @@ object SourceGenerators extends AutoPlugin { | def loadConfig[Z](z: Z): Either[ConfigErrors, Z] = | Right(z) | - | def loadConfig[A1, Z](a1: ConfigValue[A1])(f: A1 ⇒ Z): Either[ConfigErrors, Z] = - | a1.value.fold(error ⇒ Left(ConfigErrors(error)), a1 ⇒ Right(f(a1))) + | def loadConfig[A1, Z](a1: ConfigValue[A1])(f: A1 => Z): Either[ConfigErrors, Z] = + | a1.value.fold(error => Left(ConfigErrors(error)), a1 => Right(f(a1))) | | def withValue[A1, Z](a1: ConfigValue[A1])(f: A1 => Either[ConfigErrors, Z]): Either[ConfigErrors, Z] = | withValues(a1)(f) | | def withValues[A1, Z](a1: ConfigValue[A1])(f: A1 => Either[ConfigErrors, Z]): Either[ConfigErrors, Z] = - | a1.value.fold(error ⇒ Left(ConfigErrors(error)), f) + | a1.value.fold(error => Left(ConfigErrors(error)), f) | |$defs |} @@ -103,7 +103,7 @@ object SourceGenerators extends AutoPlugin { def generateConfigValueClasses(sourcesRoot: File, rootPackage: String): Seq[File] = { val classes = (2 until maximumNumberOfParams) - .map { current ⇒ + .map { current => val next = current + 1 val nextTypeParam = typeParam(next) val currentTypeParams = typeParams(current) @@ -153,7 +153,7 @@ object SourceGenerators extends AutoPlugin { def generateLoadConfigsSpec(testSourcesRoot: File, rootPackage: String): Seq[File] = { def reads(n: Int, from: Int = 1, typeName: String = "String"): String = - (from to n).map(i ⇒ s"""read[$typeName]("key$i")""").mkString(", ") + (from to n).map(i => s"""read[$typeName]("key$i")""").mkString(", ") def readsFirstMissing(n: Int): String = Seq( @@ -186,7 +186,7 @@ object SourceGenerators extends AutoPlugin { s"(${valueParams(n)}) => (${valueParams(n)})" def values(n: Int): String = - (1 to n).map(i ⇒ s""""value$i"""").mkString(", ") + (1 to n).map(i => s""""value$i"""").mkString(", ") def testsWithParams(n: Int): String = { val tests = @@ -279,7 +279,7 @@ object SourceGenerators extends AutoPlugin { |final class LoadConfigsSpec extends PropertySpec { | "LoadConfigs" when { | "loading configurations" when { - | implicit val source: ConfigSource = sourceWith("key1" → "value1", "key2" → "value2", "key3" → "value3", "key4" → "value4", "key5" → "value5", "key6" → "value6", "key7" → "value7", "key8" → "value8", "key9" → "value9", "key10" → "value10", "key11" → "value11", "key12" → "value12", "key13" → "value13", "key14" → "value14", "key15" → "value15", "key16" → "value16", "key17" → "value17", "key18" → "value18", "key19" → "value19", "key20" → "value20", "key21" → "value21", "key22" → "value22") + | implicit val source: ConfigSource = sourceWith("key1" -> "value1", "key2" -> "value2", "key3" -> "value3", "key4" -> "value4", "key5" -> "value5", "key6" -> "value6", "key7" -> "value7", "key8" -> "value8", "key9" -> "value9", "key10" -> "value10", "key11" -> "value11", "key12" -> "value12", "key13" -> "value13", "key14" -> "value14", "key15" -> "value15", "key16" -> "value16", "key17" -> "value17", "key18" -> "value18", "key19" -> "value19", "key20" -> "value20", "key21" -> "value21", "key22" -> "value22") | |$tests | }