Skip to content

Commit 7bbea6b

Browse files
xerialclaude
andcommitted
Upgrade Scala to 3.7.1 and update code format style
- Upgrade Scala version from 2.13.12 to 3.7.1 in build.sbt - Update scalafmt.conf to use Scala 3 dialect and modern formatting rules - Fix Scala 3 compatibility issues in test files: - Update lambda syntax to use parentheses around parameters - Remove deprecated underscore suffix from function references - Apply Scala 3 formatting with scalafmt 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
1 parent 83a1892 commit 7bbea6b

21 files changed

+904
-949
lines changed

.scalafmt.conf

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,17 @@
1-
version = 3.9.8
2-
runner.dialect = scala213
3-
maxColumn = 180
1+
version = 3.9.4
2+
project.layout = StandardConvention
3+
runner.dialect = scala3
4+
maxColumn = 100
45
style = defaultWithAlign
6+
docstrings.blankFirstLine = yes
7+
rewrite.scala3.convertToNewSyntax = true
8+
rewrite.scala3.removeOptionalBraces = yes
9+
rewrite.scala3.insertEndMarkerMinLines = 30
10+
# Add a new line before case class
11+
newlines.topLevelStatementBlankLines = [
12+
{
13+
blanks { after = 1 }
14+
}
15+
]
16+
newlines.source = unfold
517
optIn.breaksInsideChains = true

build.sbt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ val buildSettings = Seq[Setting[_]](
3535
organizationName := "MessagePack",
3636
organizationHomepage := Some(url("http://msgpack.org/")),
3737
description := "MessagePack for Java",
38-
scalaVersion := "2.13.12",
38+
scalaVersion := "3.7.1",
3939
Test / logBuffered := false,
4040
// msgpack-java should be a pure-java library, so remove Scala specific configurations
4141
autoScalaLibrary := false,

msgpack-core/src/test/scala/org/msgpack/core/InvalidDataReadTest.scala

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,21 @@ package org.msgpack.core
33
import org.msgpack.core.MessagePackSpec.createMessagePackData
44
import wvlet.airspec.AirSpec
55

6-
/** */
7-
class InvalidDataReadTest extends AirSpec {
6+
/**
7+
*/
8+
class InvalidDataReadTest extends AirSpec:
89

910
test("Reading long EXT32") {
1011
// Prepare an EXT32 data with 2GB (Int.MaxValue size) payload for testing the behavior of MessageUnpacker.skipValue()
1112
// Actually preparing 2GB of data, however, is too much for CI, so we create only the header part.
12-
val msgpack = createMessagePackData(p => p.packExtensionTypeHeader(MessagePack.Code.EXT32, Int.MaxValue))
13-
val u = MessagePack.newDefaultUnpacker(msgpack)
14-
try {
13+
val msgpack = createMessagePackData(p =>
14+
p.packExtensionTypeHeader(MessagePack.Code.EXT32, Int.MaxValue)
15+
)
16+
val u = MessagePack.newDefaultUnpacker(msgpack)
17+
try
1518
// This error will be thrown after reading the header as the input has no EXT32 body
1619
intercept[MessageInsufficientBufferException] {
1720
u.skipValue()
1821
}
19-
} finally {
20-
u.close()
21-
}
22+
finally u.close()
2223
}
23-
}

msgpack-core/src/test/scala/org/msgpack/core/MessageBufferPackerTest.scala

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@ package org.msgpack.core
1717

1818
import java.io.ByteArrayOutputStream
1919
import java.util.Arrays
20-
import org.msgpack.value.ValueFactory._
20+
import org.msgpack.value.ValueFactory.*
2121
import wvlet.airspec.AirSpec
2222

23-
class MessageBufferPackerTest extends AirSpec {
23+
class MessageBufferPackerTest extends AirSpec:
2424
test("MessageBufferPacker") {
2525
test("be equivalent to ByteArrayOutputStream") {
2626
val packer1 = MessagePack.newDefaultBufferPacker
@@ -48,4 +48,3 @@ class MessageBufferPackerTest extends AirSpec {
4848
}
4949

5050
}
51-
}

msgpack-core/src/test/scala/org/msgpack/core/MessageFormatTest.scala

Lines changed: 18 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -22,48 +22,41 @@ import wvlet.airspec.spi.AirSpecException
2222

2323
import scala.util.Random
2424

25-
/** Created on 2014/05/07.
25+
/**
26+
* Created on 2014/05/07.
2627
*/
27-
class MessageFormatTest extends AirSpec with Benchmark {
28+
class MessageFormatTest extends AirSpec with Benchmark:
2829
test("MessageFormat") {
2930
test("cover all byte codes") {
30-
def checkV(b: Byte, tpe: ValueType): Unit = {
31-
try MessageFormat.valueOf(b).getValueType shouldBe tpe
32-
catch {
31+
def checkV(b: Byte, tpe: ValueType): Unit =
32+
try
33+
MessageFormat.valueOf(b).getValueType shouldBe tpe
34+
catch
3335
case e: AirSpecException =>
3436
error(f"Failure when looking at byte ${b}%02x")
3537
throw e
36-
}
37-
}
3838

39-
def checkF(b: Byte, f: MessageFormat): Unit = {
40-
MessageFormat.valueOf(b) shouldBe f
41-
}
39+
def checkF(b: Byte, f: MessageFormat): Unit = MessageFormat.valueOf(b) shouldBe f
4240

43-
def check(b: Byte, tpe: ValueType, f: MessageFormat): Unit = {
41+
def check(b: Byte, tpe: ValueType, f: MessageFormat): Unit =
4442
checkV(b, tpe)
4543
checkF(b, f)
46-
}
4744

48-
for (i <- 0 until 0x7f) {
45+
for i <- 0 until 0x7f do
4946
check(i.toByte, ValueType.INTEGER, MessageFormat.POSFIXINT)
50-
}
5147

52-
for (i <- 0x80 until 0x8f) {
48+
for i <- 0x80 until 0x8f do
5349
check(i.toByte, ValueType.MAP, MessageFormat.FIXMAP)
54-
}
5550

56-
for (i <- 0x90 until 0x9f) {
51+
for i <- 0x90 until 0x9f do
5752
check(i.toByte, ValueType.ARRAY, MessageFormat.FIXARRAY)
58-
}
5953

6054
check(Code.NIL, ValueType.NIL, MessageFormat.NIL)
6155

6256
MessageFormat.valueOf(Code.NEVER_USED) shouldBe MessageFormat.NEVER_USED
6357

64-
for (i <- Seq(Code.TRUE, Code.FALSE)) {
58+
for i <- Seq(Code.TRUE, Code.FALSE) do
6559
check(i, ValueType.BOOLEAN, MessageFormat.BOOLEAN)
66-
}
6760

6861
check(Code.BIN8, ValueType.BINARY, MessageFormat.BIN8)
6962
check(Code.BIN16, ValueType.BINARY, MessageFormat.BIN16)
@@ -97,9 +90,8 @@ class MessageFormatTest extends AirSpec with Benchmark {
9790
check(Code.ARRAY16, ValueType.ARRAY, MessageFormat.ARRAY16)
9891
check(Code.ARRAY32, ValueType.ARRAY, MessageFormat.ARRAY32)
9992

100-
for (i <- 0xe0 to 0xff) {
93+
for i <- 0xe0 to 0xff do
10194
check(i.toByte, ValueType.INTEGER, MessageFormat.NEGFIXINT)
102-
}
10395
}
10496

10597
test("improve the valueOf performance") {
@@ -112,20 +104,19 @@ class MessageFormatTest extends AirSpec with Benchmark {
112104
time("lookup", repeat = 10) {
113105
block("switch") {
114106
var i = 0
115-
while (i < N) {
107+
while i < N do
116108
MessageFormat.toMessageFormat(idx(i))
117109
i += 1
118-
}
119110
}
120111

121112
block("table") {
122113
var i = 0
123-
while (i < N) {
114+
while i < N do
124115
MessageFormat.valueOf(idx(i))
125116
i += 1
126-
}
127117
}
128118
}
129119
}
130120
}
131-
}
121+
122+
end MessageFormatTest

msgpack-core/src/test/scala/org/msgpack/core/MessagePackSpec.scala

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -20,31 +20,29 @@ import wvlet.log.io.{TimeReport, Timer}
2020

2121
import java.io.ByteArrayOutputStream
2222

23-
object MessagePackSpec {
24-
def toHex(arr: Array[Byte]) = arr.map(x => f"$x%02x").mkString(" ")
25-
def createMessagePackData(f: MessagePacker => Unit): Array[Byte] = {
23+
object MessagePackSpec:
24+
def toHex(arr: Array[Byte]) = arr.map(x => f"$x%02x").mkString(" ")
25+
def createMessagePackData(f: MessagePacker => Unit): Array[Byte] =
2626
val b = new ByteArrayOutputStream()
2727
val packer = MessagePack.newDefaultPacker(b)
2828
f(packer)
2929
packer.close()
3030
b.toByteArray
31-
}
32-
}
3331

34-
trait Benchmark extends Timer {
32+
trait Benchmark extends Timer:
3533
private val numWarmUpRuns = 10
3634

37-
override protected def time[A](blockName: String, logLevel: LogLevel = LogLevel.INFO, repeat: Int = 1, blockRepeat: Int = 1)(f: => A): TimeReport = {
38-
super.time(blockName, logLevel = LogLevel.INFO, repeat)(f)
39-
}
35+
override protected def time[A](
36+
blockName: String,
37+
logLevel: LogLevel = LogLevel.INFO,
38+
repeat: Int = 1,
39+
blockRepeat: Int = 1
40+
)(f: => A): TimeReport = super.time(blockName, logLevel = LogLevel.INFO, repeat)(f)
4041

41-
override protected def block[A](name: String)(f: => A): TimeReport = {
42+
override protected def block[A](name: String)(f: => A): TimeReport =
4243
var i = 0
43-
while (i < numWarmUpRuns) {
44+
while i < numWarmUpRuns do
4445
f
4546
i += 1
46-
}
4747

4848
super.block(name)(f)
49-
}
50-
}

0 commit comments

Comments
 (0)