Skip to content

Commit

Permalink
Update scalafmt-core to 3.7.17 (#260)
Browse files Browse the repository at this point in the history
* Update scalafmt-core to 3.7.17

* Reformat with scalafmt 3.7.17

Executed command: scalafmt --non-interactive

* Add 'Reformat with scalafmt 3.7.17' to .git-blame-ignore-revs
  • Loading branch information
scala-steward authored Nov 17, 2023
1 parent ee33b9b commit 9937bed
Show file tree
Hide file tree
Showing 16 changed files with 80 additions and 69 deletions.
3 changes: 3 additions & 0 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
# Scala Steward: Reformat with scalafmt 3.7.14
5322317e378d136bf4d876be5d68dd5c9a637fa2

# Scala Steward: Reformat with scalafmt 3.7.17
b24ba10341261bd7f44e08fc26862d43b860f06a
2 changes: 1 addition & 1 deletion .scalafmt.conf
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version = "3.7.16"
version = "3.7.17"
runner.dialect = scala213
maxColumn = 120
project.git = true
Expand Down
36 changes: 16 additions & 20 deletions build.sbt
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import Dependencies.*
import ScalaVersions.*
import IntellijIdeaScalaVersion.*
import ScalaVersions.*
import commandmatrix.Dimension
import sbt.*
import sbt.Keys.*
import sbt.internal.ProjectMatrix


ThisBuild / scalaVersion := scala213

// {{{ Configure Intellij Idea
Expand All @@ -16,25 +15,24 @@ val intellijIdeaScalaVersion = IntellijIdeaScalaVersion(scala213)
Global / excludeLintKeys += ideSkipProject
// }}}

/**
* Early Semver
/** Early Semver
*
* Given a version number major.minor.patch, you MUST increment the:
* - [[major]] version if backward [[binary]] compatibility is broken,
* - [[minor]] version if backward [[source]] compatibility is broken, and
* - [[patch]] version to signal neither [[binary]] nor [[source]] incompatibility.
* When the [[major]] version is [[0]], a [[minor]] version increment *MAY* contain
* both [[source]] and [[binary]] breakages, but a [[patch]] version increment *MUST* remain [[binary]] compatible.
* - [[major]] version if backward [[binary]] compatibility is broken,
* - [[minor]] version if backward [[source]] compatibility is broken, and
* - [[patch]] version to signal neither [[binary]] nor [[source]] incompatibility. When the [[major]] version is
* [[0]], a [[minor]] version increment *MAY* contain both [[source]] and [[binary]] breakages, but a [[patch]]
* version increment *MUST* remain [[binary]] compatible.
*
* Links
* - https://www.scala-lang.org/blog/2021/02/16/preventing-version-conflicts-with-versionscheme.html
* - https://docs.scala-lang.org/overviews/core/binary-compatibility-for-library-authors.html#versioning-scheme---communicating-compatibility-breakages
* - https://www.scala-lang.org/blog/2021/02/16/preventing-version-conflicts-with-versionscheme.html
* - https://docs.scala-lang.org/overviews/core/binary-compatibility-for-library-authors.html#versioning-scheme---communicating-compatibility-breakages
*/
ThisBuild / versionScheme := Some("early-semver")

ThisBuild / libraryDependencies ++= Seq(
scalatest,
mockito,
mockito
)

// format: off
Expand All @@ -49,11 +47,10 @@ lazy val api = (projectMatrix in file("modules/api"))
.settings(
name := "websocket-api",
commonOptions,
libraryDependencies += scalatestplus(scalaVersion.value),
libraryDependencies += scalatestplus(scalaVersion.value)
)
.jvmOnly(intellijIdeaScalaVersion)


lazy val backendNetty = (projectMatrix in file("modules/backend-netty"))
.dependsOn(api % "test->test;compile->compile")
.settings(
Expand Down Expand Up @@ -93,7 +90,6 @@ lazy val backendPekko = (projectMatrix in file("modules/backend-pekko"))
)
.jvmOnly(intellijIdeaScalaVersion, excluding = { case `scala211` => })


lazy val backendJdkHttpClient = (projectMatrix in file("modules/backend-jdk-http-client"))
.dependsOn(api % "test->test;compile->compile")
.settings(
Expand Down Expand Up @@ -122,8 +118,8 @@ lazy val serdeJsoniterScala = (projectMatrix in file("modules/serde-jsoniter"))
name := "websocket-serde-avro4s",
commonOptions,
libraryDependencies ++= Seq(
jsoniterScala(scalaVersion.value).core % Compile,
jsoniterScala(scalaVersion.value).macros % Test,
jsoniterScala(scalaVersion.value).core % Compile,
jsoniterScala(scalaVersion.value).macros % Test
)
)
.jvmOnly(intellijIdeaScalaVersion)
Expand Down Expand Up @@ -167,7 +163,7 @@ lazy val root = (project in file("."))
)
.settings(
name := "websocket-root",
disablePublishing,
disablePublishing
)
.settings()

Expand Down Expand Up @@ -233,10 +229,10 @@ val includeScala211PlusFolders = Seq[Setting[_]](
case Some((2, 11)) => Nil
case _ => specificFolder(sourceDirectory.value, "2.11+")
}
},
}
)

lazy val commonOptions = Seq[Setting[_]](
Compile / doc / scalacOptions ++= Seq("-groups", "-implicits", "-no-link-warnings"),
scalacOptions := ScalaCompilerOptions(scalaVersion.value),
scalacOptions := ScalaCompilerOptions(scalaVersion.value)
)
9 changes: 7 additions & 2 deletions github.sbt
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
import CustomGithubActions.{aggregateCC, generateCC, uploadCC}
import ScalaVersions.{scala211, scala212, scala213, scala3}
import CustomGithubActions.aggregateCC
import CustomGithubActions.generateCC
import CustomGithubActions.uploadCC
import ScalaVersions.scala211
import ScalaVersions.scala212
import ScalaVersions.scala213
import ScalaVersions.scala3

ThisBuild / githubWorkflowTargetPaths := Paths.Ignore(List("**.md"))
ThisBuild / githubWorkflowScalaVersions := Seq(scala211, scala212, scala213, scala3)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.github.andyglow.utils

import org.scalatest.matchers.should.Matchers._
import org.scalatest.funsuite.AnyFunSuite
import org.scalatest.matchers.should.Matchers._
import org.scalatestplus.scalacheck.ScalaCheckPropertyChecks._

class EncodeHexSpec extends AnyFunSuite {
Expand All @@ -16,8 +16,8 @@ class EncodeHexSpec extends AnyFunSuite {
test("regular cases") {
EncodeHex(Array.empty[Byte]) shouldBe empty

EncodeHex(0xFA) shouldBe "FA"
EncodeHex(0xFA, 0xAC) shouldBe "FA AC"
EncodeHex(0xfa) shouldBe "FA"
EncodeHex(0xfa, 0xac) shouldBe "FA AC"

EncodeHex(0x00, 0x01) shouldBe "00 01"
EncodeHex(0x00, 0x01, 0x02) shouldBe "00 01 02"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package com.github.andyglow.websocket

import org.scalatest.matchers.should.Matchers._
import org.scalatest.funsuite.AnyFunSuite
import org.scalatest.OptionValues._
import java.net.URI
import org.scalatest.OptionValues._
import org.scalatest.funsuite.AnyFunSuite
import org.scalatest.matchers.should.Matchers._

class ServerAddressSpec extends AnyFunSuite {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package com.github.andyglow.websocket

import com.github.andyglow.utils.EncodeHex

import java.nio.{ByteBuffer, CharBuffer}
import java.nio.ByteBuffer
import java.nio.CharBuffer
import scala.collection.mutable.ListBuffer

class TestPlatform extends Platform {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ package com.github.andyglow.websocket

final class PekkoPlatformPlainSpec extends IntegrationSpecBase {
override val platform: PekkoPlatform = PekkoPlatform
override val ssl = false
override val isPingSupported = false
override val ssl = false
override val isPingSupported = false
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,30 @@ package com.github.andyglow.websocket.serde

import com.github.andyglow.websocket.Platform
import com.sksamuel.avro4s._

import java.io.ByteArrayOutputStream

class Avro4SSerde {
import java.nio.charset.StandardCharsets.UTF_8

object binary {
given [T](using p: Platform, enc: Encoder[T], dec: Decoder[T], sf: SchemaFor[T]): p.MessageAdapter[T] = new p.MessageAdapter[T] {
override type F = p.Binary
override def toMessage(x: T)(using ic: p.InternalContext): p.Binary = p.implicits.ByteArrayMessageAdapter.toMessage(Avro4SHelper.messageToByteArray(x))
override def fromMessage(x: p.Binary)(using ic: p.InternalContext): T = Avro4SHelper.byteArrayToMessage(p.implicits.ByteArrayMessageAdapter.fromMessage(x))
}
given [T](using p: Platform, enc: Encoder[T], dec: Decoder[T], sf: SchemaFor[T]): p.MessageAdapter[T] =
new p.MessageAdapter[T] {
override type F = p.Binary
override def toMessage(x: T)(using ic: p.InternalContext): p.Binary =
p.implicits.ByteArrayMessageAdapter.toMessage(Avro4SHelper.messageToByteArray(x))
override def fromMessage(x: p.Binary)(using ic: p.InternalContext): T =
Avro4SHelper.byteArrayToMessage(p.implicits.ByteArrayMessageAdapter.fromMessage(x))
}
}

object json {
given [T](using p: Platform, enc: Encoder[T], dec: Decoder[T], sf: SchemaFor[T]): p.MessageAdapter[T] = new p.MessageAdapter[T] {
override type F = p.Text
override def toMessage(x: T)(using ic: p.InternalContext): p.Text = p.implicits.StringMessageAdapter.toMessage(Avro4SHelper.messageToJsonString(x))
override def fromMessage(x: p.Text)(using ic: p.InternalContext): T = Avro4SHelper.jsonStringToMessage(p.implicits.StringMessageAdapter.fromMessage(x))
}
given [T](using p: Platform, enc: Encoder[T], dec: Decoder[T], sf: SchemaFor[T]): p.MessageAdapter[T] =
new p.MessageAdapter[T] {
override type F = p.Text
override def toMessage(x: T)(using ic: p.InternalContext): p.Text =
p.implicits.StringMessageAdapter.toMessage(Avro4SHelper.messageToJsonString(x))
override def fromMessage(x: p.Text)(using ic: p.InternalContext): T =
Avro4SHelper.jsonStringToMessage(p.implicits.StringMessageAdapter.fromMessage(x))
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ private[serde] object Avro4SHelper {
in.iterator.next()
}


def messageToJsonString[T](x: T)(implicit enc: Encoder[T], sf: SchemaFor[T]): String = {
val os = new ByteArrayOutputStream
val out = AvroOutputStream.json[T].to(os).build()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package com.github.andyglow.websocket.serde

import com.sksamuel.avro4s.{Encoder, Decoder, SchemaFor}
import com.sksamuel.avro4s.Decoder
import com.sksamuel.avro4s.Encoder
import com.sksamuel.avro4s.SchemaFor
import org.scalatest.funsuite.AnyFunSuite
import org.scalatest.matchers.should.Matchers.*

Expand All @@ -15,13 +17,8 @@ class Avro4sSerdeBinarySpec extends AnyFunSuite {
// import SchemaFor.given

val serde = new Avro4SSerde
import serde.binary.given_MessageAdapter_T

// println("SF " + summon[SchemaFor[Int]])
// println("Enc " + summon[Encoder[Int]])
// println("Dec " + summon[Decoder[Int]])

import serde._
import serde.binary.given_MessageAdapter_T

val cli = platform.newClient()
import cli._
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package com.github.andyglow.websocket.serde

import com.github.plokhotnyuk.jsoniter_scala.core._
import com.github.andyglow.websocket.Platform
import com.github.plokhotnyuk.jsoniter_scala.core._

class JsoniterScalaSerde {

implicit def jsoniterScalaMessageAdapter[T](
implicit p: Platform,
implicit def jsoniterScalaMessageAdapter[T](implicit
p: Platform,
codec: JsonValueCodec[T]
): p.MessageAdapter[T] = new p.MessageAdapter[T] {
override type F = p.Text
Expand All @@ -21,4 +21,4 @@ class JsoniterScalaSerde {
}
}

object JsoniterScalaSerde extends JsoniterScalaSerde
object JsoniterScalaSerde extends JsoniterScalaSerde
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package com.github.andyglow.websocket.serde
import com.github.andyglow.websocket.TestModels._
import com.github.andyglow.websocket.TestPlatform
import com.github.plokhotnyuk.jsoniter_scala.core.JsonValueCodec
import org.scalatest.matchers.should.Matchers._
import org.scalatest.funsuite.AnyFunSuite
import org.scalatest.matchers.should.Matchers._

class JsoniterScalaSerdeSpec extends AnyFunSuite {
import JsoniterScalaSerdeSpec._
Expand Down Expand Up @@ -61,11 +61,11 @@ class JsoniterScalaSerdeSpec extends AnyFunSuite {
object JsoniterScalaSerdeSpec {
import com.github.plokhotnyuk.jsoniter_scala.macros._

implicit val intCodec: JsonValueCodec[Int] = JsonCodecMaker.make
implicit val stringCodec: JsonValueCodec[String] = JsonCodecMaker.make
implicit val doubleCodec: JsonValueCodec[Double] = JsonCodecMaker.make
implicit val booleanCodec: JsonValueCodec[Boolean] = JsonCodecMaker.make
implicit val testModelCodec: JsonValueCodec[TestModel] = JsonCodecMaker.make
implicit val nestedEntryCodec: JsonValueCodec[NestedEntry] = JsonCodecMaker.make
implicit val intCodec: JsonValueCodec[Int] = JsonCodecMaker.make
implicit val stringCodec: JsonValueCodec[String] = JsonCodecMaker.make
implicit val doubleCodec: JsonValueCodec[Double] = JsonCodecMaker.make
implicit val booleanCodec: JsonValueCodec[Boolean] = JsonCodecMaker.make
implicit val testModelCodec: JsonValueCodec[TestModel] = JsonCodecMaker.make
implicit val nestedEntryCodec: JsonValueCodec[NestedEntry] = JsonCodecMaker.make
implicit def nestedTestModel[T: JsonValueCodec]: JsonValueCodec[NestedTestModel[T]] = JsonCodecMaker.make
}
10 changes: 7 additions & 3 deletions project/IntellijIdeaScalaVersion.scala
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import ScalaVersions.allScalaVersions
import commandmatrix.extra.{MatrixAction, ProjectMatrixExtraOps}
import commandmatrix.extra.MatrixAction
import commandmatrix.extra.ProjectMatrixExtraOps
import sbt.Keys.scalaVersion
import sbt.VirtualAxis
import sbt.internal.ProjectMatrix
Expand All @@ -20,12 +21,15 @@ object IntellijIdeaScalaVersion {

implicit final class ProjectMatrixSyntaxExtension(val pm: ProjectMatrix) extends AnyVal {

def jvmOnly(scalaVersion: IntellijIdeaScalaVersion, excluding: PartialFunction[String, Unit] = PartialFunction.empty): ProjectMatrix = {
def jvmOnly(
scalaVersion: IntellijIdeaScalaVersion,
excluding: PartialFunction[String, Unit] = PartialFunction.empty
): ProjectMatrix = {
val scalaVersions = allScalaVersions(excluding.lift.andThen(_.isDefined))
pm.someVariations(scalaVersions = scalaVersions, List(VirtualAxis.jvm))(
scalaVersion.oneAxisAtATimeExportedTpIntellijIdea,
IntellijIdeaScalaVersion.jvmOnly
)
}
}
}
}
6 changes: 4 additions & 2 deletions project/ScalaCompilerOptions.scala
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ object ScalaCompilerOptions {
)

private val base = Seq(
"-encoding", "UTF-8",
"-encoding",
"UTF-8",
"-feature",
"-unchecked",
"-deprecation",
Expand Down Expand Up @@ -64,7 +65,8 @@ object ScalaCompilerOptions {
"-language:higherKinds",
"-language:implicitConversions",
"-explain",
"-release", "8"
"-release",
"8"
)

def apply(scalaVersion: String): Seq[String] = {
Expand Down
2 changes: 1 addition & 1 deletion sonatype.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,4 @@ resolvers ++= Seq("snapshots", "releases").flatMap(Resolver.sonatypeOssRepos)
// and publishes directly to sonatype servers for snapshots
// use `sonatypeBundleRelease` for releases
// and `sonatypeReleaseAll` for snapshots
ThisBuild / publishTo := sonatypePublishToBundle.value
ThisBuild / publishTo := sonatypePublishToBundle.value

0 comments on commit 9937bed

Please sign in to comment.