From 5ec9de245efe3e78af388cb7cab6cc10b49bf1da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADt=20=C5=A0est=C3=A1k?= Date: Mon, 16 Oct 2023 20:32:22 +0200 Subject: [PATCH] Switch to Scala 3 (#51) --- build.sbt | 8 +++++--- client/src/main/scala/com/v6ak/zbdb/Parser.scala | 6 +++--- .../src/main/scala/com/v6ak/zbdb/ParticipantTable.scala | 4 ++-- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/build.sbt b/build.sbt index 32ef4de..3c09327 100644 --- a/build.sbt +++ b/build.sbt @@ -3,7 +3,9 @@ import java.io.IOException val appVersion= "1.0" -lazy val scalaV = "2.13.12" +lazy val scalaV2 = "2.13.12" + +lazy val scalaV3 = "3.3.1" val bootstrapVersion = "5.3.2" @@ -54,7 +56,7 @@ lazy val server = (project in file("server")).settings( version := appVersion, name := "zbdb-stats-server", scalacOptions ++= Seq("-deprecation", "-feature"), - scalaVersion := scalaV, + scalaVersion := scalaV2, scalaJSProjects := Seq(client), scalaJSStage := FullOptStage, Assets / pipelineStages := Seq(scalaJSPipeline), @@ -115,7 +117,7 @@ lazy val client = (project in file("client")).settings( version := appVersion, scalacOptions ++= Seq("-deprecation", "-feature"), scalaJSStage := FullOptStage, - scalaVersion := scalaV, + scalaVersion := scalaV3, scalaJSUseMainModuleInitializer := true, Test / scalaJSUseMainModuleInitializer := false, webpack / version := "5.88.2", // https://github.com/ScalablyTyped/Converter/issues/546 diff --git a/client/src/main/scala/com/v6ak/zbdb/Parser.scala b/client/src/main/scala/com/v6ak/zbdb/Parser.scala index 17d7582..9e1a267 100644 --- a/client/src/main/scala/com/v6ak/zbdb/Parser.scala +++ b/client/src/main/scala/com/v6ak/zbdb/Parser.scala @@ -96,7 +96,7 @@ object Parser{ def parse(csvData: String, startTime: Moment, totalEndTime: Moment, maxHourDelta: Int, formatVersion: FormatVersion) = { val fullDataTable: IndexedSeq[IndexedSeq[String]] = CsvParser.parse(csvData) - val Seq(header1, header2, header3, dataWithTail @ _*) = fullDataTable.drop(formatVersion.headSize) + val Seq(header1, header2, header3, dataWithTail @ _*) = fullDataTable.drop(formatVersion.headSize) : @unchecked val (dataTable, footer) = formatVersion.tail.split(dataWithTail.dropWhile(_.head == "").toIndexedSeq) footer.foreach{fl => assertEmpty(fl.toSet.filterNot(_.forall(c => c.isDigit || c==':')) -- Set("", "nejdříve na stanovišti", "nejrychleji projitý úsek", "Na trati")) @@ -150,9 +150,9 @@ object Parser{ private def isUsefulCell(cell: String): Boolean = cell != "" && cell != "X" && cell != "0:00" private def parseParticipant(participantData: immutable.IndexedSeq[String], parts: immutable.IndexedSeq[Part], startTime: Moment, maxHourDelta: Int, totalEndTime: Moment, formatVersion: FormatVersion): Participant = { - val Seq(num, participantDataAfterNum@_*) = participantData + val Seq(num, participantDataAfterNum@_*) = participantData : @unchecked val (firstName, lastName, nick, participantDataAfterName) = formatVersion.nameFormat.parse(participantDataAfterNum) - val Seq(genderString, ageString, other@_*) = participantDataAfterName + val Seq(genderString, ageString, other@_*) = participantDataAfterName : @unchecked if ((formatVersion.ageType == AgeType.No) && (ageString != "")) { sys.error("You seem to have left some data in age column. Clean it first, please.") } diff --git a/client/src/main/scala/com/v6ak/zbdb/ParticipantTable.scala b/client/src/main/scala/com/v6ak/zbdb/ParticipantTable.scala index 859f526..7c08b04 100644 --- a/client/src/main/scala/com/v6ak/zbdb/ParticipantTable.scala +++ b/client/src/main/scala/com/v6ak/zbdb/ParticipantTable.scala @@ -27,7 +27,7 @@ final case class ParticipantTable (startTime: Moment, parts: Seq[Part], data: Se } val finishedParticipantsInContext = finishedParticipantsGroups.flatten val bestTotalTimeOption = finishedParticipantsInContext.headOption.map(_.totalTime) - val unfinishedParticipantsInContext = unfinishedParticipants.map(ParticipantInContext.Failed) + val unfinishedParticipantsInContext = unfinishedParticipants.map(ParticipantInContext.Failed.apply) val allParticipantsInContext = finishedParticipantsInContext ++ unfinishedParticipantsInContext (allParticipantsInContext.map(pic => pic.participant -> pic).toMap, bestTotalTimeOption) } @@ -144,7 +144,7 @@ final case class ParticipantTable (startTime: Moment, parts: Seq[Part], data: Se row.partTimes lazyZip nextPartInfos ) - .map(FullPartInfo) + .map(FullPartInfo.apply) .zipWithIndex .flatMap((partWalkEvents(row) _).tupled) }