Run spotless formatting (#958)

When we updated spotless's Java and Kotlin formatter, we changed the underlying
formatting rules.
However, due to spotless ratcheting, these formatting changes don't get applied unless a file
gets touched in a commit.

To avoid future PRs introducing lines of change that aren't related to the intention of the PR,
this is a one-time format of all files.
This commit is contained in:
Daniel Chao
2025-02-17 07:36:43 -08:00
committed by GitHub
parent d270829ed3
commit 28b128f86f
79 changed files with 679 additions and 682 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved.
* Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -38,7 +38,7 @@ internal class BinaryEvaluator(
timeout: Duration?,
moduleCacheDir: Path?,
declaredDependencies: DeclaredDependencies?,
outputFormat: String?
outputFormat: String?,
) :
EvaluatorImpl(
transformer,
@@ -53,7 +53,7 @@ internal class BinaryEvaluator(
timeout,
moduleCacheDir,
declaredDependencies,
outputFormat
outputFormat,
) {
fun evaluate(moduleSource: ModuleSource, expression: String?): ByteArray {
return doEvaluate(moduleSource) { module ->

View File

@@ -1,5 +1,5 @@
/*
* Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved.
* Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -21,7 +21,7 @@ import org.pkl.core.messaging.MessageTransport
internal class ClientLogger(
private val evaluatorId: Long,
private val transport: MessageTransport
private val transport: MessageTransport,
) : Logger {
override fun trace(message: String, frame: StackFrame) {
transport.send(LogMessage(evaluatorId, 0, message, frame.moduleUri))

View File

@@ -1,5 +1,5 @@
/*
* Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved.
* Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -25,7 +25,7 @@ import org.pkl.core.module.*
internal class ClientModuleKeyFactory(
private val readerSpecs: Collection<ModuleReaderSpec>,
transport: MessageTransport,
evaluatorId: Long
evaluatorId: Long,
) : ModuleKeyFactory {
private val schemes = readerSpecs.map { it.scheme }

View File

@@ -1,5 +1,5 @@
/*
* Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved.
* Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -56,7 +56,7 @@ class Server(private val transport: MessageTransport) : AutoCloseable {
MessageTransports.stream(
ServerMessagePackDecoder(inputStream),
ServerMessagePackEncoder(outputStream),
::log
::log,
)
)
}
@@ -76,7 +76,7 @@ class Server(private val transport: MessageTransport) : AutoCloseable {
is EvaluateRequest -> handleEvaluate(message)
else -> throw ProtocolException("Unexpected incoming request message: $message")
}
}
},
)
}
@@ -147,7 +147,7 @@ class Server(private val transport: MessageTransport) : AutoCloseable {
private fun buildDeclaredDependencies(
projectFileUri: URI,
dependencies: Map<String, Dependency>,
myPackageUri: URI?
myPackageUri: URI?,
): DeclaredDependencies {
val remoteDependencies = buildMap {
for ((key, dep) in dependencies) {
@@ -156,8 +156,8 @@ class Server(private val transport: MessageTransport) : AutoCloseable {
key,
org.pkl.core.packages.Dependency.RemoteDependency(
PackageUri(dep.packageUri),
dep.checksums
)
dep.checksums,
),
)
}
}
@@ -175,7 +175,7 @@ class Server(private val transport: MessageTransport) : AutoCloseable {
remoteDependencies,
localDependencies,
projectFileUri,
myPackageUri?.let(::PackageUri)
myPackageUri?.let(::PackageUri),
)
}
@@ -210,7 +210,7 @@ class Server(private val transport: MessageTransport) : AutoCloseable {
allowedModules,
allowedResources,
SecurityManagers.defaultTrustLevels,
rootDir
rootDir,
),
httpClient,
ClientLogger(evaluatorId, transport),
@@ -221,14 +221,14 @@ class Server(private val transport: MessageTransport) : AutoCloseable {
timeout,
cacheDir,
dependencies,
message.outputFormat
message.outputFormat,
)
}
private fun createResourceReaders(
message: CreateEvaluatorRequest,
evaluatorId: Long,
modulePathResolver: ModulePathResolver
modulePathResolver: ModulePathResolver,
): List<ResourceReader> = buildList {
add(ResourceReaders.environmentVariable())
add(ResourceReaders.externalProperty())
@@ -248,7 +248,7 @@ class Server(private val transport: MessageTransport) : AutoCloseable {
add(
ResourceReaders.externalResolver(
readerSpec,
MessageTransportResourceResolver(transport, evaluatorId)
MessageTransportResourceResolver(transport, evaluatorId),
)
)
}
@@ -257,7 +257,7 @@ class Server(private val transport: MessageTransport) : AutoCloseable {
private fun createModuleKeyFactories(
message: CreateEvaluatorRequest,
evaluatorId: Long,
modulePathResolver: ModulePathResolver
modulePathResolver: ModulePathResolver,
): List<ModuleKeyFactory> = buildList {
// add client-side module key factory first to ensure it wins over builtin ones
if (message.clientModuleReaders?.isNotEmpty() == true) {
@@ -268,7 +268,7 @@ class Server(private val transport: MessageTransport) : AutoCloseable {
ModuleKeyFactories.externalProcess(
scheme,
getExternalProcess(evaluatorId, spec),
evaluatorId
evaluatorId,
)
)
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved.
* Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -52,13 +52,13 @@ class ServerMessagePackDecoder(unpacker: MessageUnpacker) : BaseMessagePackDecod
map.unpackProject(),
map.unpackHttp(),
unpackStringMapOrNull(map, "externalModuleReaders", ::unpackExternalReader),
unpackStringMapOrNull(map, "externalResourceReaders", ::unpackExternalReader)
unpackStringMapOrNull(map, "externalResourceReaders", ::unpackExternalReader),
)
Message.Type.CREATE_EVALUATOR_RESPONSE ->
CreateEvaluatorResponse(
unpackLong(map, "requestId"),
unpackLongOrNull(map, "evaluatorId"),
unpackStringOrNull(map, "error")
unpackStringOrNull(map, "error"),
)
Message.Type.CLOSE_EVALUATOR -> CloseEvaluator(unpackLong(map, "evaluatorId"))
Message.Type.EVALUATE_REQUEST ->
@@ -67,21 +67,21 @@ class ServerMessagePackDecoder(unpacker: MessageUnpacker) : BaseMessagePackDecod
unpackLong(map, "evaluatorId"),
URI(unpackString(map, "moduleUri")),
unpackStringOrNull(map, "moduleText"),
unpackStringOrNull(map, "expr")
unpackStringOrNull(map, "expr"),
)
Message.Type.EVALUATE_RESPONSE ->
EvaluateResponse(
unpackLong(map, "requestId"),
unpackLong(map, "evaluatorId"),
unpackByteArray(map, "result"),
unpackStringOrNull(map, "error")
unpackStringOrNull(map, "error"),
)
Message.Type.LOG_MESSAGE ->
LogMessage(
unpackLong(map, "evaluatorId"),
unpackInt(map, "level"),
unpackString(map, "message"),
unpackString(map, "frameUri")
unpackString(map, "frameUri"),
)
else -> super.decodeMessage(msgType, map)
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved.
* Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -46,7 +46,7 @@ data class CreateEvaluatorRequest(
val project: Project?,
val http: Http?,
val externalModuleReaders: Map<String, ExternalReader>?,
val externalResourceReaders: Map<String, ExternalReader>?
val externalResourceReaders: Map<String, ExternalReader>?,
) : Message.Client.Request {
override fun type(): Message.Type = Message.Type.CREATE_EVALUATOR_REQUEST
@@ -61,11 +61,11 @@ data class CreateEvaluatorRequest(
return requestId == other.requestId &&
Objects.equals(
allowedModules?.map { it.pattern() },
other.allowedModules?.map { it.pattern() }
other.allowedModules?.map { it.pattern() },
) &&
Objects.equals(
allowedResources?.map { it.pattern() },
other.allowedResources?.map { it.pattern() }
other.allowedResources?.map { it.pattern() },
) &&
clientModuleReaders.equalsNullable(other.clientModuleReaders) &&
clientResourceReaders.equalsNullable(other.clientResourceReaders) &&
@@ -108,7 +108,7 @@ data class Http(
/** PEM-format CA certificates as raw bytes. */
val caCertificates: ByteArray?,
/** Proxy settings */
val proxy: Proxy?
val proxy: Proxy?,
) {
override fun equals(other: Any?): Boolean {
if (this === other) return true
@@ -130,7 +130,7 @@ data class Http(
enum class DependencyType(val value: String) {
LOCAL("local"),
REMOTE("remote")
REMOTE("remote"),
}
sealed interface Dependency {
@@ -145,7 +145,7 @@ data class RemoteDependency(override val packageUri: URI, val checksums: Checksu
data class Project(
val projectFileUri: URI,
override val packageUri: URI?,
val dependencies: Map<String, Dependency>
val dependencies: Map<String, Dependency>,
) : Dependency {
override val type: DependencyType = DependencyType.LOCAL
}
@@ -169,7 +169,7 @@ data class EvaluateRequest(
val evaluatorId: Long,
val moduleUri: URI,
val moduleText: String?,
val expr: String?
val expr: String?,
) : Message.Client.Request {
override fun type(): Message.Type = Message.Type.EVALUATE_REQUEST
@@ -180,7 +180,7 @@ data class EvaluateResponse(
private val requestId: Long,
val evaluatorId: Long,
val result: ByteArray?,
val error: String?
val error: String?,
) : Message.Server.Response {
override fun type(): Message.Type = Message.Type.EVALUATE_RESPONSE
@@ -212,7 +212,7 @@ data class LogMessage(
val evaluatorId: Long,
val level: Int,
val message: String,
val frameUri: String
val frameUri: String,
) : Message.Server.OneWay {
override fun type(): Message.Type = Message.Type.LOG_MESSAGE
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved.
* Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -37,13 +37,13 @@ class JvmServerTest : AbstractServerTest() {
MessageTransports.stream(
ServerMessagePackDecoder(in1),
ServerMessagePackEncoder(out2),
::log
::log,
),
MessageTransports.stream(
ServerMessagePackDecoder(in2),
ServerMessagePackEncoder(out1),
::log
)
::log,
),
)
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved.
* Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -32,7 +32,7 @@ class NativeServerTest : AbstractServerTest() {
TestTransport(
MessageTransports.stream(
ServerMessagePackDecoder(server.inputStream),
ServerMessagePackEncoder(server.outputStream)
ServerMessagePackEncoder(server.outputStream),
) { _ ->
}
)

View File

@@ -1,5 +1,5 @@
/*
* Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved.
* Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -52,18 +52,8 @@ class ServerMessagePackCodecTest {
@Test
fun `round-trip CreateEvaluatorRequest`() {
val resourceReader1 =
ResourceReaderSpec(
"resourceReader1",
true,
true,
)
val resourceReader2 =
ResourceReaderSpec(
"resourceReader2",
true,
false,
)
val resourceReader1 = ResourceReaderSpec("resourceReader1", true, true)
val resourceReader2 = ResourceReaderSpec("resourceReader2", true, false)
val moduleReader1 = ModuleReaderSpec("moduleReader1", true, true, true)
val moduleReader2 = ModuleReaderSpec("moduleReader2", true, false, false)
val externalReader = ExternalReader("external-cmd", listOf("arg1", "arg2"))
@@ -99,18 +89,18 @@ class ServerMessagePackCodecTest {
Project(
projectFileUri = URI("file:///bar"),
packageUri = URI("package://localhost:0/bar@1.1.0"),
dependencies = emptyMap()
dependencies = emptyMap(),
)
)
),
),
"baz" to
RemoteDependency(URI("package://localhost:0/baz@1.1.0"), Checksums("abc123"))
)
RemoteDependency(URI("package://localhost:0/baz@1.1.0"), Checksums("abc123")),
),
),
http =
Http(
proxy = PklEvaluatorSettings.Proxy(URI("http://foo.com:1234"), listOf("bar", "baz")),
caCertificates = byteArrayOf(1, 2, 3, 4)
caCertificates = byteArrayOf(1, 2, 3, 4),
),
externalModuleReaders = mapOf("external" to externalReader, "external2" to externalReader),
externalResourceReaders = mapOf("external" to externalReader),
@@ -136,7 +126,7 @@ class ServerMessagePackCodecTest {
evaluatorId = 456,
moduleUri = URI("some/module.pkl"),
moduleText = null,
expr = "some + expression"
expr = "some + expression",
)
)
}
@@ -148,7 +138,7 @@ class ServerMessagePackCodecTest {
requestId = 123,
evaluatorId = 456,
result = byteArrayOf(1, 2, 3, 4, 5),
error = null
error = null,
)
)
}
@@ -160,7 +150,7 @@ class ServerMessagePackCodecTest {
evaluatorId = 123,
level = 0,
message = "Hello, world!",
frameUri = "file:///some/module.pkl"
frameUri = "file:///some/module.pkl",
)
)
}