From 2a335baf400a26ecd4080e4652bf185d13919d74 Mon Sep 17 00:00:00 2001 From: Scala Steward Date: Wed, 5 Feb 2025 14:33:17 +0000 Subject: [PATCH 1/3] Update scalafmt-core to 3.8.6 --- .scalafmt.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.scalafmt.conf b/.scalafmt.conf index 719c6e47..c5f0a7c6 100644 --- a/.scalafmt.conf +++ b/.scalafmt.conf @@ -1,4 +1,4 @@ -version = 3.8.3 +version = 3.8.6 runner.dialect = scala213 From 5bddf5048ec33364f774e09fa454651e46fd58cf Mon Sep 17 00:00:00 2001 From: Scala Steward Date: Wed, 5 Feb 2025 14:33:33 +0000 Subject: [PATCH 2/3] Reformat with scalafmt 3.8.6 Executed command: scalafmt --non-interactive --- .../json/JodaJavaLocalDateCompatSpec.scala | 18 ++-- .../format/DefaultMongoFormatsTest.scala | 3 +- .../mongo/generic/SumTypesDerivingSpec.scala | 3 +- project/Fmpp.scala | 2 +- .../test/scala/HighPrecisionMoneySpec.scala | 21 ++-- util/src/test/scala/MoneySpec.scala | 100 ++++++++---------- 6 files changed, 62 insertions(+), 85 deletions(-) diff --git a/json/json-core/src/test/scala/io/sphere/json/JodaJavaLocalDateCompatSpec.scala b/json/json-core/src/test/scala/io/sphere/json/JodaJavaLocalDateCompatSpec.scala index f8295527..1b49c7a0 100644 --- a/json/json-core/src/test/scala/io/sphere/json/JodaJavaLocalDateCompatSpec.scala +++ b/json/json-core/src/test/scala/io/sphere/json/JodaJavaLocalDateCompatSpec.scala @@ -26,26 +26,20 @@ class JodaJavaLocalDateCompatSpec extends AnyWordSpec with Matchers { } "parsing a LocalDate" should { - "accept two digit years" in { + "accept two digit years" in test(jsonDateStringWith(year = "50")) - } - "accept year zero" in { + "accept year zero" in test(JString("0-10-31")) - } - "accept no day set" in { + "accept no day set" in test(JString("2024-09")) - } - "accept up to nine digit years" in { + "accept up to nine digit years" in (1 to 9).foreach { l => val year = List.fill(l)("1").mkString("") test(jsonDateStringWith(year = year)) } - } - "accept a year with leading zero" in { + "accept a year with leading zero" in test(jsonDateStringWith(year = "02020")) - } - "accept a year with leading plus sign" in { + "accept a year with leading plus sign" in test(jsonDateStringWith(year = "+02020")) - } } } diff --git a/mongo/mongo-core/src/test/scala/io/sphere/mongo/format/DefaultMongoFormatsTest.scala b/mongo/mongo-core/src/test/scala/io/sphere/mongo/format/DefaultMongoFormatsTest.scala index f03efc81..51531b6a 100644 --- a/mongo/mongo-core/src/test/scala/io/sphere/mongo/format/DefaultMongoFormatsTest.scala +++ b/mongo/mongo-core/src/test/scala/io/sphere/mongo/format/DefaultMongoFormatsTest.scala @@ -125,13 +125,12 @@ class DefaultMongoFormatsTest check(map, format) } - "support Java Locale" in { + "support Java Locale" in Locale.getAvailableLocales.filter(_.toLanguageTag != LangTag.UNDEFINED).foreach { (l: Locale) => localeFormat.fromMongoValue(localeFormat.toMongoValue(l)).toLanguageTag must be( l.toLanguageTag) } - } "support UUID" in { val format = uuidFormat diff --git a/mongo/mongo-derivation/src/test/scala/io/sphere/mongo/generic/SumTypesDerivingSpec.scala b/mongo/mongo-derivation/src/test/scala/io/sphere/mongo/generic/SumTypesDerivingSpec.scala index 3a4bb47d..4356b0b4 100644 --- a/mongo/mongo-derivation/src/test/scala/io/sphere/mongo/generic/SumTypesDerivingSpec.scala +++ b/mongo/mongo-derivation/src/test/scala/io/sphere/mongo/generic/SumTypesDerivingSpec.scala @@ -47,9 +47,8 @@ class SumTypesDerivingSpec extends AnyWordSpec with Matchers { "deriveMongoFormat[Color6]" mustNot compile } - "use intermediate level" in { + "use intermediate level" in Color7.format - } "do not use sealed trait info when using a case class directly" in { check(Color8.format, Color8.Custom("2356"), dbObj("type" -> "Custom", "rgb" -> "2356")) diff --git a/project/Fmpp.scala b/project/Fmpp.scala index 31b41844..0f32b272 100644 --- a/project/Fmpp.scala +++ b/project/Fmpp.scala @@ -11,7 +11,7 @@ import java.io.File object Fmpp { private lazy val fmpp = TaskKey[Seq[File]]("fmpp") private lazy val fmppOptions = SettingKey[Seq[String]]("fmppOptions") - private lazy val FmppConfig = config("fmpp") hide + private lazy val FmppConfig = config("fmpp").hide lazy val settings = fmppConfigSettings(Compile) ++ Seq( libraryDependencies += "net.sourceforge.fmpp" % "fmpp" % "0.9.16" % FmppConfig.name, diff --git a/util/src/test/scala/HighPrecisionMoneySpec.scala b/util/src/test/scala/HighPrecisionMoneySpec.scala index 1b80016b..bf9be2f6 100644 --- a/util/src/test/scala/HighPrecisionMoneySpec.scala +++ b/util/src/test/scala/HighPrecisionMoneySpec.scala @@ -48,9 +48,8 @@ class HighPrecisionMoneySpec extends AnyFunSpec with Matchers with ScalaCheckDri } it("should throw error on overflow in the unary '-' operator.") { - a[MoneyOverflowException] must be thrownBy { + a[MoneyOverflowException] must be thrownBy -(BigDecimal(Long.MinValue) / 1000).EUR_PRECISE(3) - } } it("should support the binary '+' operator.") { @@ -68,9 +67,8 @@ class HighPrecisionMoneySpec extends AnyFunSpec with Matchers with ScalaCheckDri } it("should throw error on overflow in the binary '+' operator.") { - a[MoneyOverflowException] must be thrownBy { + a[MoneyOverflowException] must be thrownBy (BigDecimal(Long.MaxValue) / 1000).EUR_PRECISE(3) + 1 - } } it("should support the binary '-' operator.") { @@ -88,9 +86,8 @@ class HighPrecisionMoneySpec extends AnyFunSpec with Matchers with ScalaCheckDri } it("should throw error on overflow in the binary '-' operator.") { - a[MoneyOverflowException] must be thrownBy { + a[MoneyOverflowException] must be thrownBy (BigDecimal(Long.MinValue) / 1000).EUR_PRECISE(3) - 1 - } } it("should support the binary '*' operator.") { @@ -108,9 +105,8 @@ class HighPrecisionMoneySpec extends AnyFunSpec with Matchers with ScalaCheckDri } it("should throw error on overflow in the binary '*' operator.") { - a[MoneyOverflowException] must be thrownBy { + a[MoneyOverflowException] must be thrownBy (BigDecimal(Long.MaxValue / 1000) / 2 + 1).EUR_PRECISE(3) * 2 - } } it("should support the binary '%' operator.") { @@ -128,9 +124,8 @@ class HighPrecisionMoneySpec extends AnyFunSpec with Matchers with ScalaCheckDri } it("should throw error on overflow in the binary '%' operator.") { - noException must be thrownBy { + noException must be thrownBy BigDecimal(Long.MaxValue / 1000).EUR_PRECISE(3) % 0.5 - } } it("should support the binary '/%' operator.") { @@ -140,9 +135,8 @@ class HighPrecisionMoneySpec extends AnyFunSpec with Matchers with ScalaCheckDri } it("should throw error on overflow in the binary '/%' operator.") { - a[MoneyOverflowException] must be thrownBy { + a[MoneyOverflowException] must be thrownBy BigDecimal(Long.MaxValue / 1000).EUR_PRECISE(3) /% 0.5 - } } it("should support the remainder operator.") { @@ -152,9 +146,8 @@ class HighPrecisionMoneySpec extends AnyFunSpec with Matchers with ScalaCheckDri } it("should not overflow when getting the remainder of a division ('%').") { - noException must be thrownBy { + noException must be thrownBy BigDecimal(Long.MaxValue / 1000).EUR_PRECISE(3).remainder(0.5) - } } it("should partition the value properly.") { diff --git a/util/src/test/scala/MoneySpec.scala b/util/src/test/scala/MoneySpec.scala index 9a12f3a3..5e7e643f 100644 --- a/util/src/test/scala/MoneySpec.scala +++ b/util/src/test/scala/MoneySpec.scala @@ -16,140 +16,132 @@ class MoneySpec extends AnyFunSpec with Matchers with ScalaCheckDrivenPropertyCh describe("Money") { it("should have value semantics.") { - (1.23 EUR) must equal(1.23 EUR) + (1.23.EUR) must equal(1.23.EUR) } it( "should default to HALF_EVEN rounding mode when using monetary notation and use provided rounding mode when performing operations.") { implicit val mode = BigDecimal.RoundingMode.HALF_EVEN - (1.001 EUR) must equal(1.00 EUR) - (1.005 EUR) must equal(1.00 EUR) - (1.015 EUR) must equal(1.02 EUR) - ((1.00 EUR) + 0.001) must equal(1.00 EUR) - ((1.00 EUR) + 0.005) must equal(1.00 EUR) - ((1.00 EUR) + 0.015) must equal(1.02 EUR) - ((1.00 EUR) - 0.005) must equal(1.00 EUR) - ((1.00 EUR) - 0.015) must equal(0.98 EUR) - ((1.00 EUR) + 0.0115) must equal(1.01 EUR) + (1.001.EUR) must equal(1.00.EUR) + (1.005.EUR) must equal(1.00.EUR) + (1.015.EUR) must equal(1.02.EUR) + ((1.00.EUR) + 0.001) must equal(1.00.EUR) + ((1.00.EUR) + 0.005) must equal(1.00.EUR) + ((1.00.EUR) + 0.015) must equal(1.02.EUR) + ((1.00.EUR) - 0.005) must equal(1.00.EUR) + ((1.00.EUR) - 0.015) must equal(0.98.EUR) + ((1.00.EUR) + 0.0115) must equal(1.01.EUR) } it( "should not accept an amount with an invalid scale for the used currency when using the constructor directly.") { - an[IllegalArgumentException] must be thrownBy { + an[IllegalArgumentException] must be thrownBy Money(1.0001, java.util.Currency.getInstance("EUR")) - } } it("should not be prone to common rounding errors known from floating point numbers.") { - var m = 0.00 EUR + var m = 0.00.EUR for (i <- 1 to 10) m = m + 0.10 - m must equal(1.00 EUR) + m must equal(1.00.EUR) } it("should support the unary '-' operator.") { - -EUR(1.00) must equal(-1.00 EUR) + -EUR(1.00) must equal(-1.00.EUR) } it("should throw error on overflow in the unary '-' operator.") { - a[MoneyOverflowException] must be thrownBy { + a[MoneyOverflowException] must be thrownBy -euroCents(Long.MinValue) - } } it("should support the binary '+' operator.") { - (1.42 EUR) + (1.58 EUR) must equal(3.00 EUR) + (1.42.EUR) + (1.58.EUR) must equal(3.00.EUR) } it("should support the binary '+' operator on different currencies.") { - an[IllegalArgumentException] must be thrownBy { - (1.42 EUR) + (1.58 USD) - } + an[IllegalArgumentException] must be thrownBy + (1.42.EUR) + (1.58.USD) } it("should throw error on overflow in the binary '+' operator.") { - a[MoneyOverflowException] must be thrownBy { + a[MoneyOverflowException] must be thrownBy euroCents(Long.MaxValue) + 1 - } } it("should support the binary '-' operator.") { - (1.33 EUR) - (0.33 EUR) must equal(1.00 EUR) + (1.33.EUR) - (0.33.EUR) must equal(1.00.EUR) } it("should throw error on overflow in the binary '-' operator.") { - a[MoneyOverflowException] must be thrownBy { + a[MoneyOverflowException] must be thrownBy euroCents(Long.MinValue) - 1 - } } it("should support the binary '*' operator, requiring a rounding mode.") { implicit val mode = BigDecimal.RoundingMode.HALF_EVEN - (1.33 EUR) * (1.33 EUR) must equal(1.77 EUR) + (1.33.EUR) * (1.33.EUR) must equal(1.77.EUR) } it("should throw error on overflow in the binary '*' operator.") { - a[MoneyOverflowException] must be thrownBy { + a[MoneyOverflowException] must be thrownBy euroCents(Long.MaxValue / 2 + 1) * 2 - } } it("should support the binary '/%' (divideAndRemainder) operator.") { implicit val mode = BigDecimal.RoundingMode.HALF_EVEN - (1.33 EUR) /% 0.3 must equal(4.00 EUR, 0.13 EUR) - (1.33 EUR) /% 0.003 must equal(443.00 EUR, 0.00 EUR) + (1.33.EUR) /% 0.3 must equal(4.00.EUR, 0.13.EUR) + (1.33.EUR) /% 0.003 must equal(443.00.EUR, 0.00.EUR) } it("should throw error on overflow in the binary '/%' (divideAndRemainder) operator.") { - a[MoneyOverflowException] must be thrownBy { + a[MoneyOverflowException] must be thrownBy euroCents(Long.MaxValue) /% 0.5 - } } it("should support getting the remainder of a division ('%').") { implicit val mode = BigDecimal.RoundingMode.HALF_EVEN - (1.25 EUR).remainder(1.1) must equal(0.15 EUR) - (1.25 EUR) % 1.1 must equal(0.15 EUR) + 1.25.EUR.remainder(1.1) must equal(0.15.EUR) + (1.25.EUR) % 1.1 must equal(0.15.EUR) } it("should not overflow when getting the remainder of a division ('%').") { - noException must be thrownBy { + noException must be thrownBy euroCents(Long.MaxValue).remainder(0.5) - } } it("should support partitioning an amount without losing or gaining money.") { - (0.05 EUR).partition(3, 7) must equal(Seq(0.02 EUR, 0.03 EUR)) - (10 EUR).partition(1, 2) must equal(Seq(3.34 EUR, 6.66 EUR)) - (10 EUR).partition(3, 1, 3) must equal(Seq(4.29 EUR, 1.43 EUR, 4.28 EUR)) + 0.05.EUR.partition(3, 7) must equal(Seq(0.02.EUR, 0.03.EUR)) + 10.EUR.partition(1, 2) must equal(Seq(3.34.EUR, 6.66.EUR)) + 10.EUR.partition(3, 1, 3) must equal(Seq(4.29.EUR, 1.43.EUR, 4.28.EUR)) } it("should allow comparing money with the same currency.") { - ((1.10 EUR) > (1.00 EUR)) must be(true) - ((1.00 EUR) >= (1.00 EUR)) must be(true) - ((1.00 EUR) < (1.10 EUR)) must be(true) - ((1.00 EUR) <= (1.00 EUR)) must be(true) + ((1.10.EUR) > (1.00.EUR)) must be(true) + ((1.00.EUR) >= (1.00.EUR)) must be(true) + ((1.00.EUR) < (1.10.EUR)) must be(true) + ((1.00.EUR) <= (1.00.EUR)) must be(true) } it("should support currencies with a scale of 0 (i.e. Japanese Yen)") { - (1 JPY) must equal(1 JPY) + (1.JPY) must equal(1.JPY) } it("should be able to update the centAmount") { - (1.10 EUR).withCentAmount(170) must be(1.70 EUR) - (1.10 EUR).withCentAmount(1711) must be(17.11 EUR) - (1 JPY).withCentAmount(34) must be(34 JPY) + 1.10.EUR.withCentAmount(170) must be(1.70.EUR) + 1.10.EUR.withCentAmount(1711) must be(17.11.EUR) + 1.JPY.withCentAmount(34) must be(34.JPY) } it("should provide convenient toString") { - (1 JPY).toString must be("1 JPY") - (1.00 EUR).toString must be("1.00 EUR") - (0.10 EUR).toString must be("0.10 EUR") - (0.01 EUR).toString must be("0.01 EUR") - (0.00 EUR).toString must be("0.00 EUR") - (94.5 EUR).toString must be("94.50 EUR") + 1.JPY.toString must be("1 JPY") + 1.00.EUR.toString must be("1.00 EUR") + 0.10.EUR.toString must be("0.10 EUR") + 0.01.EUR.toString must be("0.01 EUR") + 0.00.EUR.toString must be("0.00 EUR") + 94.5.EUR.toString must be("94.50 EUR") } it("should not fail on toString") { From 7dadf75416dbcc61ded967561a216da85ea2f457 Mon Sep 17 00:00:00 2001 From: Scala Steward Date: Wed, 5 Feb 2025 14:33:33 +0000 Subject: [PATCH 3/3] Add 'Reformat with scalafmt 3.8.6' to .git-blame-ignore-revs --- .git-blame-ignore-revs | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 .git-blame-ignore-revs diff --git a/.git-blame-ignore-revs b/.git-blame-ignore-revs new file mode 100644 index 00000000..cd15ed03 --- /dev/null +++ b/.git-blame-ignore-revs @@ -0,0 +1,2 @@ +# Scala Steward: Reformat with scalafmt 3.8.6 +5bddf5048ec33364f774e09fa454651e46fd58cf