diff --git a/.git-blame-ignore-revs b/.git-blame-ignore-revs new file mode 100644 index 00000000..7df95bc8 --- /dev/null +++ b/.git-blame-ignore-revs @@ -0,0 +1,2 @@ +# Scala Steward: Reformat with scalafmt 3.8.6 +c8276942b5ee0d998aac15034433e7305e0c0313 diff --git a/.scalafmt.conf b/.scalafmt.conf index e7552abd..49d0d7d4 100644 --- a/.scalafmt.conf +++ b/.scalafmt.conf @@ -1,4 +1,4 @@ -version = "3.8.3" +version = "3.8.6" runner.dialect = scala213source3 maxColumn = 120 align.preset = most diff --git a/examples/AppModel/booksandrecords-spring-boot/src/main/scala/morphir/examples/booksandrecords/API.scala b/examples/AppModel/booksandrecords-spring-boot/src/main/scala/morphir/examples/booksandrecords/API.scala index 1a6f805d..1d420e7a 100644 --- a/examples/AppModel/booksandrecords-spring-boot/src/main/scala/morphir/examples/booksandrecords/API.scala +++ b/examples/AppModel/booksandrecords-spring-boot/src/main/scala/morphir/examples/booksandrecords/API.scala @@ -12,37 +12,39 @@ distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. -*/ - + */ package morphir.examples.booksandrecords -import com.fasterxml.jackson.annotation.{JsonAutoDetect, JsonProperty, JsonSubTypes, JsonTypeInfo} +import com.fasterxml.jackson.annotation.{ JsonAutoDetect, JsonProperty, JsonSubTypes, JsonTypeInfo } import org.springframework.context.annotation.Bean; - object API { - type DealId = String + type DealId = String type ProductId = String - type Price = Float - type Quantity = Int - + type Price = Float + type Quantity = Int // Commands @JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "type") - @JsonSubTypes(Array - ( - new JsonSubTypes.Type(value = classOf[OpenDeal], name = "openDeal"), - new JsonSubTypes.Type(value = classOf[CloseDeal], name = "closeDeal") - )) + @JsonSubTypes( + Array( + new JsonSubTypes.Type(value = classOf[OpenDeal], name = "openDeal"), + new JsonSubTypes.Type(value = classOf[CloseDeal], name = "closeDeal") + ) + ) sealed trait DealCmd @Bean case class CloseDeal(@JsonProperty("dealId") dealId: DealId) extends DealCmd - @Bean - case class OpenDeal(@JsonProperty("dealId") dealId: DealId, @JsonProperty("productId") productId: ProductId, @JsonProperty("price") price: Price, @JsonProperty("quantity") quantity: Quantity) extends DealCmd + case class OpenDeal( + @JsonProperty("dealId") dealId: DealId, + @JsonProperty("productId") productId: ProductId, + @JsonProperty("price") price: Price, + @JsonProperty("quantity") quantity: Quantity + ) extends DealCmd // Events @JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "type") @@ -57,16 +59,17 @@ object API { case object InvalidQuantity extends RejectReason @JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "type") - @JsonSubTypes(Array - ( - new JsonSubTypes.Type(value = classOf[DealClosed], name = "dealClosed"), - new JsonSubTypes.Type(value = classOf[DealOpened], name = "dealOpened"), - new JsonSubTypes.Type(value = classOf[CommandRejected], name = "CommandRejected") - )) + @JsonSubTypes( + Array( + new JsonSubTypes.Type(value = classOf[DealClosed], name = "dealClosed"), + new JsonSubTypes.Type(value = classOf[DealOpened], name = "dealOpened"), + new JsonSubTypes.Type(value = classOf[CommandRejected], name = "CommandRejected") + ) + ) @JsonAutoDetect(fieldVisibility = JsonAutoDetect.Visibility.ANY) sealed trait DealEvent - case class DealOpened( id: DealId, productId: ProductId, price: Price, quantity: Quantity) extends DealEvent + case class DealOpened(id: DealId, productId: ProductId, price: Price, quantity: Quantity) extends DealEvent case class DealClosed(dealId: DealId) extends DealEvent diff --git a/examples/AppModel/booksandrecords-spring-boot/src/main/scala/morphir/examples/booksandrecords/Logic.scala b/examples/AppModel/booksandrecords-spring-boot/src/main/scala/morphir/examples/booksandrecords/Logic.scala index d74b5dd6..33908ed9 100644 --- a/examples/AppModel/booksandrecords-spring-boot/src/main/scala/morphir/examples/booksandrecords/Logic.scala +++ b/examples/AppModel/booksandrecords-spring-boot/src/main/scala/morphir/examples/booksandrecords/Logic.scala @@ -12,8 +12,7 @@ distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. -*/ - + */ package morphir.examples.booksandrecords @@ -21,34 +20,29 @@ import morphir.examples.booksandrecords.API._ import morphir.examples.booksandrecords.model.State.Deal import morphir.examples.booksandrecords.repository.DealRepository - object Logic { - def openDeal(command: OpenDeal, dealRepository: DealRepository) : DealEvent = { - val dealOptional = dealRepository.findById(command.dealId) - - if (dealOptional.isPresent) { - new CommandRejected(command.dealId, DuplicateDeal, "Duplicated") - } - else if (command.price < 0) { - new CommandRejected(command.dealId, InvalidPrice, "Wrong Price") - } - else if (command.quantity < 0) { - new CommandRejected(command.dealId, InvalidQuantity, "Wrong Quantity") - } - else { - val deal = new Deal(command.dealId, command.productId, command.price, command.quantity) - dealRepository.save(deal) - new DealOpened(command.dealId, command.productId, command.price, command.quantity) - } + def openDeal(command: OpenDeal, dealRepository: DealRepository): DealEvent = { + val dealOptional = dealRepository.findById(command.dealId) + + if (dealOptional.isPresent) { + new CommandRejected(command.dealId, DuplicateDeal, "Duplicated") + } else if (command.price < 0) { + new CommandRejected(command.dealId, InvalidPrice, "Wrong Price") + } else if (command.quantity < 0) { + new CommandRejected(command.dealId, InvalidQuantity, "Wrong Quantity") + } else { + val deal = new Deal(command.dealId, command.productId, command.price, command.quantity) + dealRepository.save(deal) + new DealOpened(command.dealId, command.productId, command.price, command.quantity) } + } - def closeDeal(command: CloseDeal, dealRepository: DealRepository) : DealEvent = { - val dealOptional = dealRepository.findById(command.dealId) + def closeDeal(command: CloseDeal, dealRepository: DealRepository): DealEvent = { + val dealOptional = dealRepository.findById(command.dealId) - if (dealOptional.isPresent) { - dealRepository.deleteById(command.dealId) - new DealClosed(command.dealId) - } - else new CommandRejected(command.dealId, DealNotFound, "Deal Not Found") - } -} \ No newline at end of file + if (dealOptional.isPresent) { + dealRepository.deleteById(command.dealId) + new DealClosed(command.dealId) + } else new CommandRejected(command.dealId, DealNotFound, "Deal Not Found") + } +} diff --git a/examples/AppModel/booksandrecords-spring-boot/src/main/scala/morphir/examples/booksandrecords/State.scala b/examples/AppModel/booksandrecords-spring-boot/src/main/scala/morphir/examples/booksandrecords/State.scala index e2fc832d..c337e171 100644 --- a/examples/AppModel/booksandrecords-spring-boot/src/main/scala/morphir/examples/booksandrecords/State.scala +++ b/examples/AppModel/booksandrecords-spring-boot/src/main/scala/morphir/examples/booksandrecords/State.scala @@ -12,8 +12,7 @@ distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. -*/ - + */ package morphir.examples.booksandrecords.model; @@ -21,11 +20,11 @@ import org.springframework.data.annotation.Id import morphir.examples.booksandrecords.API._ object State { - case class Deal ( - @Id - id : DealId, - productId : ProductId, - price : Price, - quantity : Quantity - ) -} \ No newline at end of file + case class Deal( + @Id + id: DealId, + productId: ProductId, + price: Price, + quantity: Quantity + ) +} diff --git a/examples/AppModel/booksandrecords-spring-boot/src/main/scala/morphir/examples/booksandrecords/StatefulApp.scala b/examples/AppModel/booksandrecords-spring-boot/src/main/scala/morphir/examples/booksandrecords/StatefulApp.scala index 648b76dc..771f4be6 100644 --- a/examples/AppModel/booksandrecords-spring-boot/src/main/scala/morphir/examples/booksandrecords/StatefulApp.scala +++ b/examples/AppModel/booksandrecords-spring-boot/src/main/scala/morphir/examples/booksandrecords/StatefulApp.scala @@ -12,8 +12,7 @@ distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. -*/ - + */ package morphir.examples.booksandrecords.serviceImpl @@ -31,4 +30,4 @@ import org.springframework.stereotype.Service override def logic(dealCmd: API.DealCmd) = processCmd(dealCmd, dealRepository) -} \ No newline at end of file +} diff --git a/examples/AppModel/booksandrecords-spring-boot/src/main/scala/morphir/examples/booksandrecords/processor/CmdProcessor.scala b/examples/AppModel/booksandrecords-spring-boot/src/main/scala/morphir/examples/booksandrecords/processor/CmdProcessor.scala index 8bbbc506..3a06a4e1 100644 --- a/examples/AppModel/booksandrecords-spring-boot/src/main/scala/morphir/examples/booksandrecords/processor/CmdProcessor.scala +++ b/examples/AppModel/booksandrecords-spring-boot/src/main/scala/morphir/examples/booksandrecords/processor/CmdProcessor.scala @@ -12,20 +12,18 @@ distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. -*/ - + */ package morphir.examples.booksandrecords.processor -import morphir.examples.booksandrecords.API.{CloseDeal, DealCmd, DealEvent, OpenDeal} +import morphir.examples.booksandrecords.API.{ CloseDeal, DealCmd, DealEvent, OpenDeal } import morphir.examples.booksandrecords.Logic._ import morphir.examples.booksandrecords.repository.DealRepository object CmdProcessor { - def processCmd(cmd: DealCmd, dealRepository: DealRepository): DealEvent = { + def processCmd(cmd: DealCmd, dealRepository: DealRepository): DealEvent = cmd match { - case cmd: OpenDeal => openDeal(cmd, dealRepository) + case cmd: OpenDeal => openDeal(cmd, dealRepository) case cmd: CloseDeal => closeDeal(cmd, dealRepository) } - } -} \ No newline at end of file +} diff --git a/examples/AppModel/booksandrecords-spring-boot/src/main/scala/morphir/examples/booksandrecords/service/ServiceStatefulApp.scala b/examples/AppModel/booksandrecords-spring-boot/src/main/scala/morphir/examples/booksandrecords/service/ServiceStatefulApp.scala index d846a85d..f358d026 100644 --- a/examples/AppModel/booksandrecords-spring-boot/src/main/scala/morphir/examples/booksandrecords/service/ServiceStatefulApp.scala +++ b/examples/AppModel/booksandrecords-spring-boot/src/main/scala/morphir/examples/booksandrecords/service/ServiceStatefulApp.scala @@ -12,13 +12,12 @@ distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. -*/ - + */ package morphir.examples.booksandrecords.service -import morphir.examples.booksandrecords.API.{DealCmd, DealEvent} +import morphir.examples.booksandrecords.API.{ DealCmd, DealEvent } trait ServiceStatefulApp { def logic(dealCmd: DealCmd): DealEvent -} \ No newline at end of file +} diff --git a/mill-build/build.mill.scala b/mill-build/build.mill.scala index 9d18f94c..85634e28 100644 --- a/mill-build/build.mill.scala +++ b/mill-build/build.mill.scala @@ -1,4 +1,4 @@ -package build +package build import mill._, scalalib._ object `package` extends MillBuildRootModule { @@ -30,8 +30,8 @@ object `package` extends MillBuildRootModule { } } - val forcedVersions = Seq( + val forcedVersions = Seq( ("com.google.guava", "guava", "32.0.1-jre"), - ("org.yaml","snakeyaml","1.33") + ("org.yaml", "snakeyaml", "1.33") ) } diff --git a/mill-build/src/millbuild/CommonCoursierModule.scala b/mill-build/src/millbuild/CommonCoursierModule.scala index de8893a3..2af10cdc 100644 --- a/mill-build/src/millbuild/CommonCoursierModule.scala +++ b/mill-build/src/millbuild/CommonCoursierModule.scala @@ -32,6 +32,6 @@ trait CommonCoursierModule extends CoursierModule { ("com.google.protobuf", "protobuf-java", "3.21.2"), ("com.google.guava", "guava", "32.0.1-jre"), ("org.jsoup", "jsoup", "1.15.3"), - ("org.yaml","snakeyaml","1.33") + ("org.yaml", "snakeyaml", "1.33") ) } diff --git a/mill-build/src/millbuild/MyBuild.scala b/mill-build/src/millbuild/MyBuild.scala index a9fb1dc3..5688b012 100644 --- a/mill-build/src/millbuild/MyBuild.scala +++ b/mill-build/src/millbuild/MyBuild.scala @@ -11,7 +11,7 @@ object MyBuild extends ExternalModule { BuildSettings.load() } - def devMode = T.input { T.env.getOrElse("MORPHIR_SCALA_DEV_MODE", false) == "true" } + def devMode = T.input(T.env.getOrElse("MORPHIR_SCALA_DEV_MODE", false) == "true") def showBuildSettings() = T.command { val settings = buildSettings() diff --git a/mill-build/src/millbuild/crossplatform/CrossPlatform.scala b/mill-build/src/millbuild/crossplatform/CrossPlatform.scala index fb0a1099..1db36991 100644 --- a/mill-build/src/millbuild/crossplatform/CrossPlatform.scala +++ b/mill-build/src/millbuild/crossplatform/CrossPlatform.scala @@ -55,7 +55,7 @@ trait CrossPlatform extends Module with DynamicModule { self => def childPlatformModules: Seq[PlatformModule] = millModuleDirectChildren.collect { case (m: PlatformModule @unchecked) => m } - def targetPlatforms: T[Seq[Platform]] = T { childPlatformModules.map(_.platform) } + def targetPlatforms: T[Seq[Platform]] = T(childPlatformModules.map(_.platform)) /// Try and resolve to an actual platform specific module if it exists (not expecting multiple but in theory it is possible) def childPlatformModules(platform: Platform): Seq[PlatformModule] = diff --git a/mill-build/src/millbuild/crossplatform/Platform.scala b/mill-build/src/millbuild/crossplatform/Platform.scala index 45c7fc8b..b34507b3 100644 --- a/mill-build/src/millbuild/crossplatform/Platform.scala +++ b/mill-build/src/millbuild/crossplatform/Platform.scala @@ -1,6 +1,6 @@ package millbuild.crossplatform -import upickle.default.{ReadWriter => RW, macroRW} +import upickle.default.{ ReadWriter => RW, macroRW } sealed trait Platform extends Ordered[Platform] { self => val isJS: Boolean = self == Platform.JS @@ -10,14 +10,17 @@ sealed trait Platform extends Ordered[Platform] { self => def name: String def compare(that: Platform): Int = self.name.compare(that.name) - def suffixes: Seq[String] = Seq(self.name) ++ pairs.map { - case (a, b) => a + "-" + b + def suffixes: Seq[String] = Seq(self.name) ++ pairs.map { case (a, b) => + a + "-" + b } final def pairs: Seq[(String, String)] = - Platform.all.filter(_ != self).map { p => - if (self < p) (self.name, p.name) - else (p.name, self.name) - }.toSeq + Platform.all + .filter(_ != self) + .map { p => + if (self < p) (self.name, p.name) + else (p.name, self.name) + } + .toSeq override def toString = name } diff --git a/mill-build/src/millbuild/deps.scala b/mill-build/src/millbuild/deps.scala index 06f86b27..a183fc36 100644 --- a/mill-build/src/millbuild/deps.scala +++ b/mill-build/src/millbuild/deps.scala @@ -33,7 +33,7 @@ object Deps { } case object `47Deg` { - val memeid4s = ivy"com.47deg::memeid4s:${Versions.`memeid4s`}" + val memeid4s = ivy"com.47deg::memeid4s:${Versions.`memeid4s`}" } case object geirsson { diff --git a/mill-build/src/millbuild/settings/BuildSettings.scala b/mill-build/src/millbuild/settings/BuildSettings.scala index ab0ff8ce..b7162784 100644 --- a/mill-build/src/millbuild/settings/BuildSettings.scala +++ b/mill-build/src/millbuild/settings/BuildSettings.scala @@ -1,5 +1,5 @@ package millbuild.settings -import zio.{ConfigProvider, Unsafe, Runtime} +import zio.{ ConfigProvider, Unsafe, Runtime } import zio.config._ import zio.config.magnolia.deriveConfig import zio.config.typesafe._ @@ -8,11 +8,11 @@ import com.typesafe.config.ConfigFactory import zio.Config final case class BuildSettings( - jvm: JvmBuildSettings = JvmBuildSettings(), - js: ScalaJsBuildSettings = ScalaJsBuildSettings(), - native: ScalaNativeBuildSettings = ScalaNativeBuildSettings(), - mill: MillSettings = MillSettings(), - scala: ScalaSettings = ScalaSettings() + jvm: JvmBuildSettings = JvmBuildSettings(), + js: ScalaJsBuildSettings = ScalaJsBuildSettings(), + native: ScalaNativeBuildSettings = ScalaNativeBuildSettings(), + mill: MillSettings = MillSettings(), + scala: ScalaSettings = ScalaSettings() ) object BuildSettings { @@ -31,15 +31,17 @@ object BuildSettings { lazy val propertiesFileConfigProvider: ConfigProvider = ConfigProvider.propsProvider.nested("morphir.build") - // .fromPropertiesFile((os.pwd / "build.user.properties").toIO) + // .fromPropertiesFile((os.pwd / "build.user.properties").toIO) lazy val buildUserYamlFileConfigProvider = ConfigProvider.fromYamlPath((os.pwd / "build.user.yaml").wrapped) def load(): BuildSettings = Unsafe.unsafe { implicit u => - Runtime.default.unsafe.run( - loadSettings() - ).getOrThrowFiberFailure() + Runtime.default.unsafe + .run( + loadSettings() + ) + .getOrThrowFiberFailure() } def loadSettings() = diff --git a/morphir/sdk/json/src/morphir/sdk/basics/Codec.scala b/morphir/sdk/json/src/morphir/sdk/basics/Codec.scala index b558d0b7..bb631acd 100644 --- a/morphir/sdk/json/src/morphir/sdk/basics/Codec.scala +++ b/morphir/sdk/json/src/morphir/sdk/basics/Codec.scala @@ -29,6 +29,6 @@ object Codec { /* Encoder / Decoder for Unit Type */ implicit val encodeUnit: Encoder[Unit] = _ => io.circe.Json.obj() - implicit val decodeUnit: Decoder[Unit] = (_: io.circe.HCursor) => Right({}) + implicit val decodeUnit: Decoder[Unit] = (_: io.circe.HCursor) => Right {} } diff --git a/project/modules/crossplatform.sc b/project/modules/crossplatform.sc index 2cbecbf1..977403c9 100644 --- a/project/modules/crossplatform.sc +++ b/project/modules/crossplatform.sc @@ -1,4 +1,4 @@ -import upickle.default.{ReadWriter => RW, macroRW} +import upickle.default.{ ReadWriter => RW, macroRW } sealed trait Platform { def name: String