Skip to content

Commit 2bb4834

Browse files
xerialclaude
andauthored
Upgrade Scala to 3.7.1 and use Scala 3 code format style (msgpack#899)
* 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]> * Update CLAUDE.md for Scala 3.7.1 and modern sbt syntax - Fix build command to use modern sbt syntax: Test / compile instead of test:compile - Update Scala version reference to 3.7.1 in testing structure - Update scalafmt configuration notes to reflect Scala 3 dialect and 100 char limit * Update CLAUDE.md to recommend latest Scala 3 version - Change specific version reference to 'always use the latest Scala 3 version' - This ensures the documentation remains current as new Scala 3 versions are released * Update README.md for modern sbt syntax and Scala 3 - Fix sbt command syntax: change test:compile to 'Test / compile' - Add note about Scala 3 dialect and latest version recommendation - Ensure developer documentation matches current project configuration * Update scalafmtAll command description - Change comment from 'Format Scala test code' to 'Format all Scala and sbt code' - More accurately reflects what scalafmtAll does (formats all Scala files, not just tests) - Apply change to both README.md and CLAUDE.md for consistency --------- Co-authored-by: Claude <[email protected]>
1 parent 4bcc43e commit 2bb4834

File tree

7 files changed

+57
-56
lines changed

7 files changed

+57
-56
lines changed

.scalafmt.conf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
version = 3.9.4
1+
version = 3.9.8
22
project.layout = StandardConvention
33
runner.dialect = scala3
44
maxColumn = 100

CLAUDE.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ MessagePack-Java is a binary serialization library that provides a fast and comp
1313
### Build and Compile
1414
```bash
1515
./sbt compile # Compile source code
16-
./sbt test:compile # Compile source and test code
16+
./sbt "Test / compile" # Compile source and test code
1717
./sbt package # Create JAR files
1818
```
1919

@@ -31,7 +31,7 @@ MessagePack-Java is a binary serialization library that provides a fast and comp
3131
### Code Quality
3232
```bash
3333
./sbt jcheckStyle # Run checkstyle (Facebook Presto style)
34-
./sbt scalafmtAll # Format Scala test code
34+
./sbt scalafmtAll # Format all Scala and sbt code
3535
```
3636

3737
### Publishing
@@ -66,7 +66,7 @@ The msgpack-jackson module provides:
6666
- Extension type support including timestamps
6767

6868
### Testing Structure
69-
- **msgpack-core tests**: Written in Scala using AirSpec framework
69+
- **msgpack-core tests**: Written in Scala (always use the latest Scala 3 version) using AirSpec framework
7070
- Location: `msgpack-core/src/test/scala/`
7171
- **msgpack-jackson tests**: Written in Java using JUnit
7272
- Location: `msgpack-jackson/src/test/java/`
@@ -81,7 +81,7 @@ For JDK 17+ compatibility, these options are automatically added:
8181

8282
## Code Style Requirements
8383
- Java code follows Facebook Presto style (enforced by checkstyle)
84-
- Scala test code uses Scalafmt with 180 character line limit
84+
- Scala test code uses Scalafmt with Scala 3 dialect and 100 character line limit
8585
- Checkstyle runs automatically during compilation
8686
- No external dependencies allowed in msgpack-core
8787

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ msgpack-java uses [sbt](http://www.scala-sbt.org/) for building the projects. Fo
6666
Coding style
6767
* msgpack-java uses [the same coding style](https://github.com/airlift/codestyle) with Facebook Presto
6868
* [IntelliJ setting file](https://raw.githubusercontent.com/airlift/codestyle/master/IntelliJIdea14/Airlift.xml)
69+
* Scala test code uses Scalafmt with Scala 3 dialect (always use the latest Scala 3 version)
6970

7071
### Basic sbt commands
7172
Enter the sbt console:
@@ -76,14 +77,14 @@ $ ./sbt
7677
Here is a list of sbt commands for daily development:
7778
```
7879
> ~compile # Compile source codes
79-
> ~test:compile # Compile both source and test codes
80+
> ~"Test / compile" # Compile both source and test codes
8081
> ~test # Run tests upon source code change
8182
> ~testOnly *MessagePackTest # Run tests in the specified class
8283
> ~testOnly *MessagePackTest -- (pattern) # Run tests matching the pattern
8384
> project msgpack-core # Focus on a specific project
8485
> package # Create a jar file in the target folder of each project
8586
> jcheckStyle # Run check style
86-
> scalafmtAll # Reformat code
87+
> scalafmtAll # Format all Scala and sbt code
8788
```
8889

8990
### Publishing

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,7 @@ class MessagePackTest extends AirSpec with PropertyCheck with Benchmark:
376376
test("report errors when packing/unpacking malformed strings") {
377377
pending("We need to produce malformed utf-8 strings in Java 8")
378378
// Create 100 malformed UTF8 Strings
379-
val r = new Random(0)
379+
val r = new Random(0)
380380
val malformedStrings = Iterator
381381
.continually {
382382
val b = new Array[Byte](10)
@@ -580,12 +580,12 @@ class MessagePackTest extends AirSpec with PropertyCheck with Benchmark:
580580

581581
kvs
582582
.grouped(2)
583-
.map((kvp: Array[Value]) =>
583+
.map { (kvp: Array[Value]) =>
584584
val k = kvp(0)
585585
val v = kvp(1)
586586

587587
(k.asStringValue().asString, v.asStringValue().asString)
588-
)
588+
}
589589
.toMap
590590
}
591591
.toList

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ class MessagePackerTest extends AirSpec with Benchmark:
211211
}
212212

213213
test("compute totalWrittenBytes") {
214-
val out = new ByteArrayOutputStream
214+
val out = new ByteArrayOutputStream
215215
val packerTotalWrittenBytes =
216216
withResource(MessagePack.newDefaultPacker(out)) { packer =>
217217
packer

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ import scala.util.Random
3030

3131
object MessageUnpackerTest:
3232
class SplitMessageBufferInput(array: Array[Array[Byte]]) extends MessageBufferInput:
33-
var cursor = 0
33+
var cursor = 0
3434
override def next(): MessageBuffer =
3535
if cursor < array.length then
3636
val a = array(cursor)
@@ -45,7 +45,7 @@ import org.msgpack.core.MessageUnpackerTest.*
4545

4646
class MessageUnpackerTest extends AirSpec with Benchmark:
4747

48-
private val universal = MessageBuffer.allocate(0).isInstanceOf[MessageBufferU]
48+
private val universal = MessageBuffer.allocate(0).isInstanceOf[MessageBufferU]
4949
private def testData: Array[Byte] =
5050
val out = new ByteArrayOutputStream()
5151
val packer = MessagePack.newDefaultPacker(out)
@@ -435,7 +435,7 @@ class MessageUnpackerTest extends AirSpec with Benchmark:
435435
val t =
436436
time("skip performance", repeat = N) {
437437
block("v6") {
438-
val v6 = new org.msgpack.MessagePack()
438+
val v6 = new org.msgpack.MessagePack()
439439
val unpacker =
440440
new org.msgpack.unpacker.MessagePackUnpacker(v6, new ByteArrayInputStream(data))
441441
var count = 0
@@ -567,7 +567,7 @@ class MessageUnpackerTest extends AirSpec with Benchmark:
567567
val t =
568568
time("unpack performance", repeat = N) {
569569
block("v6") {
570-
val v6 = new org.msgpack.MessagePack()
570+
val v6 = new org.msgpack.MessagePack()
571571
val unpacker =
572572
new org.msgpack.unpacker.MessagePackUnpacker(v6, new ByteArrayInputStream(data))
573573
var count = 0
@@ -655,7 +655,7 @@ class MessageUnpackerTest extends AirSpec with Benchmark:
655655

656656
time("unpackBinary", repeat = 100) {
657657
block("v6") {
658-
val v6 = new org.msgpack.MessagePack()
658+
val v6 = new org.msgpack.MessagePack()
659659
val unpacker =
660660
new org.msgpack.unpacker.MessagePackUnpacker(v6, new ByteArrayInputStream(b))
661661
var i = 0

msgpack-core/src/test/scala/org/msgpack/value/VariableTest.scala

Lines changed: 40 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -181,39 +181,39 @@ class VariableTest extends AirSpec with PropertyCheck:
181181

182182
test("read integers") {
183183
forAll { (i: Int) =>
184-
check(
185-
_.packInt(i),
186-
checker =
187-
v =>
188-
val iv = validateValue(v.asIntegerValue(), asInteger = true)
189-
iv.asInt() shouldBe i
190-
iv.asLong() shouldBe i.toLong
191-
)
184+
check(
185+
_.packInt(i),
186+
checker =
187+
v =>
188+
val iv = validateValue(v.asIntegerValue(), asInteger = true)
189+
iv.asInt() shouldBe i
190+
iv.asLong() shouldBe i.toLong
191+
)
192192
}
193193
}
194194

195195
test("read double") {
196196
forAll { (x: Double) =>
197-
check(
198-
_.packDouble(x),
199-
checker =
200-
v =>
201-
val iv = validateValue(v.asFloatValue(), asFloat = true)
202-
// iv.toDouble shouldBe v
203-
// iv.toFloat shouldBe x.toFloat
204-
)
197+
check(
198+
_.packDouble(x),
199+
checker =
200+
v =>
201+
val iv = validateValue(v.asFloatValue(), asFloat = true)
202+
// iv.toDouble shouldBe v
203+
// iv.toFloat shouldBe x.toFloat
204+
)
205205
}
206206
}
207207

208208
test("read boolean") {
209209
forAll { (x: Boolean) =>
210-
check(
211-
_.packBoolean(x),
212-
checker =
213-
v =>
214-
val iv = validateValue(v.asBooleanValue(), asBoolean = true)
215-
iv.getBoolean shouldBe x
216-
)
210+
check(
211+
_.packBoolean(x),
212+
checker =
213+
v =>
214+
val iv = validateValue(v.asBooleanValue(), asBoolean = true)
215+
iv.getBoolean shouldBe x
216+
)
217217
}
218218
}
219219

@@ -234,13 +234,13 @@ class VariableTest extends AirSpec with PropertyCheck:
234234

235235
test("read string") {
236236
forAll { (x: String) =>
237-
check(
238-
_.packString(x),
239-
checker =
240-
v =>
241-
val iv = validateValue(v.asStringValue(), asString = true)
242-
iv.asString() shouldBe x
243-
)
237+
check(
238+
_.packString(x),
239+
checker =
240+
v =>
241+
val iv = validateValue(v.asStringValue(), asString = true)
242+
iv.asString() shouldBe x
243+
)
244244
}
245245
}
246246

@@ -280,7 +280,7 @@ class VariableTest extends AirSpec with PropertyCheck:
280280
},
281281
checker =
282282
v =>
283-
val iv = validateValue(v.asMapValue(), asMap = true)
283+
val iv = validateValue(v.asMapValue(), asMap = true)
284284
val lst =
285285
iv.map()
286286
.asScala
@@ -293,15 +293,15 @@ class VariableTest extends AirSpec with PropertyCheck:
293293

294294
test("read timestamps") {
295295
forAll { (millis: Long) =>
296-
val i = Instant.ofEpochMilli(millis)
297-
check(
298-
_.packTimestamp(i),
299-
checker =
300-
v =>
301-
val ts = validateValue(v.asTimestampValue(), asTimestamp = true)
302-
ts.isTimestampValue shouldBe true
303-
ts.toInstant shouldBe i
304-
)
296+
val i = Instant.ofEpochMilli(millis)
297+
check(
298+
_.packTimestamp(i),
299+
checker =
300+
v =>
301+
val ts = validateValue(v.asTimestampValue(), asTimestamp = true)
302+
ts.isTimestampValue shouldBe true
303+
ts.toInstant shouldBe i
304+
)
305305
}
306306
}
307307
}

0 commit comments

Comments
 (0)