From 9646c85ac4cd8d45a363eef6eb42fed00e704508 Mon Sep 17 00:00:00 2001 From: Alfredo Torre Date: Thu, 14 Dec 2023 13:08:55 +0100 Subject: [PATCH] Upgrade Scala 2.13.12 --- .scalafmt.conf | 18 +++++++++++ build.sbt | 32 +++++++++++-------- project/build.properties | 2 +- project/plugins.sbt | 20 ++++++------ .../scala/purecsv/safe/tryutil/TryUtil.scala | 2 +- .../purecsv/unsafe/RecordSplitterImpl.scala | 2 +- .../scala/purecsv/safe/TryUtilSuite.scala | 2 +- 7 files changed, 50 insertions(+), 28 deletions(-) create mode 100644 .scalafmt.conf diff --git a/.scalafmt.conf b/.scalafmt.conf new file mode 100644 index 0000000..0aeaf0b --- /dev/null +++ b/.scalafmt.conf @@ -0,0 +1,18 @@ +version = "3.7.17" + +runner.dialect = scala213source3 +align.preset = more +align.openParenCallSite = true +align.openParenDefnSite = true +style = defaultWithAlign +maxColumn = 115 +indent.extendSite = 4 +indent.withSiteRelativeToExtends = 2 +docstrings = "ScalaDoc" +docstrings.style = Asterisk +docstrings.removeEmpty = true +continuationIndent.callSite = 2 +continuationIndent.defnSite = 4 +includeCurlyBraceInSelectChains = false +project.git = true +project.excludeFilters = ["target/"] diff --git a/build.sbt b/build.sbt index c7efcbd..2b78027 100644 --- a/build.sbt +++ b/build.sbt @@ -1,22 +1,25 @@ import sbt.Keys._ +Global / onChangedBuildSource := ReloadOnSourceChanges + lazy val buildSettings = Seq( - organization := "io.kontainers", - scalaVersion := "2.13.10", + organization := "io.kontainers", + scalaVersion := "2.13.12", crossScalaVersions := Seq("2.12.15", scalaVersion.value) ) lazy val publishSettings = Seq( - publishMavenStyle := true, - Test/ publishArtifact := false, + publishMavenStyle := true, + Test / publishArtifact := false, releasePublishArtifactsAction := PgpKeys.publishSigned.value, publishTo := Some( if (isSnapshot.value) - Opts.resolver.sonatypeSnapshots + Opts.resolver.sbtSnapshots else - Opts.resolver.sonatypeStaging), - pomIncludeRepository := { x => false }, - pomExtra := ( + Opts.resolver.sonatypeStaging + ), + pomIncludeRepository := { x => false }, + pomExtra := ( https://github.com/kontainers/PureCSV @@ -42,15 +45,16 @@ lazy val publishSettings = Seq( ) ) -lazy val pureCSV = project.in(file(".")). - settings(buildSettings). - settings(publishSettings). - settings( +lazy val pureCSV = project + .in(file(".")) + .settings(buildSettings) + .settings(publishSettings) + .settings( name := "purecsv", scalacOptions ++= Seq("-feature", "-deprecation"), libraryDependencies ++= Seq( - "com.chuusai" %% "shapeless" % "2.3.10", + "com.chuusai" %% "shapeless" % "2.3.10", "com.github.tototoshi" %% "scala-csv" % "1.3.10", - "org.scalatest" %% "scalatest" % "3.2.14" % Test + "org.scalatest" %% "scalatest" % "3.2.17" % Test ) ) diff --git a/project/build.properties b/project/build.properties index 563a014..e8a1e24 100644 --- a/project/build.properties +++ b/project/build.properties @@ -1 +1 @@ -sbt.version=1.7.2 +sbt.version=1.9.7 diff --git a/project/plugins.sbt b/project/plugins.sbt index 99087dd..53bf9ac 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -1,11 +1,11 @@ /** - * sbt-updates - * - * for easier dependency updates monitoring - * @see https://github.com/rtimush/sbt-updates - */ -addSbtPlugin("com.timushev.sbt" % "sbt-updates" % "0.6.4") - -addSbtPlugin("com.github.sbt" % "sbt-release" % "1.1.0") - -addSbtPlugin("com.github.sbt" % "sbt-pgp" % "2.1.2") + * sbt-updates + * + * for easier dependency updates monitoring + * @see + * https://github.com/rtimush/sbt-updates + */ +addSbtPlugin("com.timushev.sbt" % "sbt-updates" % "0.6.4") +addSbtPlugin("com.github.sbt" % "sbt-release" % "1.1.0") +addSbtPlugin("com.github.sbt" % "sbt-pgp" % "2.1.2") +addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.5.2") diff --git a/src/main/scala/purecsv/safe/tryutil/TryUtil.scala b/src/main/scala/purecsv/safe/tryutil/TryUtil.scala index 41f3722..7e2188a 100644 --- a/src/main/scala/purecsv/safe/tryutil/TryUtil.scala +++ b/src/main/scala/purecsv/safe/tryutil/TryUtil.scala @@ -34,6 +34,6 @@ package object tryutil { } } - implicit class IteratorOfTry[A](iter: Iterator[Try[A]]) extends IterableOfTry[A](iter.toIterable) + implicit class IteratorOfTry[A](iter: Iterator[Try[A]]) extends IterableOfTry[A](iter.iterator.to(Iterable)) } diff --git a/src/main/scala/purecsv/unsafe/RecordSplitterImpl.scala b/src/main/scala/purecsv/unsafe/RecordSplitterImpl.scala index 00a3695..01a44c5 100644 --- a/src/main/scala/purecsv/unsafe/RecordSplitterImpl.scala +++ b/src/main/scala/purecsv/unsafe/RecordSplitterImpl.scala @@ -55,7 +55,7 @@ object RecordSplitterImpl extends RecordSplitter[Reader] { fields: Seq[String], headerMapping: Map[String, String]) = csvReader.iteratorWithHeaders - .map(line => line.mapValues(trimming.trim)) + .map(line => line.view.mapValues(trimming.trim)) .filter(array => array.size != 1 || array.head._2.trim != EmptyString) .map(f => fields.map(field => f.getOrElse(headerMapping.getOrElse(field, field), EmptyString))) diff --git a/src/test/scala/purecsv/safe/TryUtilSuite.scala b/src/test/scala/purecsv/safe/TryUtilSuite.scala index ad9c161..0ae4b9c 100644 --- a/src/test/scala/purecsv/safe/TryUtilSuite.scala +++ b/src/test/scala/purecsv/safe/TryUtilSuite.scala @@ -29,7 +29,7 @@ class MyException(val s: String) extends RuntimeException(s) { class TryUtilSuite extends AnyFunSuite with Matchers { import tryutil._ - def failure(s: String) = Failure(new MyException(s)) + def failure(s: String): Failure[RuntimeException] = Failure(new MyException(s)) test("getSuccessesAndFailures partition an Iterator[Try[A]] into successes and failures") { val startingSuccesses = Seq(Success(1),Success(2))