This is an automated email from the ASF dual-hosted git repository.
kou pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/arrow-swift.git
The following commit(s) were added to refs/heads/main by this push:
new 0a91054 Add a lint CI (#21)
0a91054 is described below
commit 0a910548269b65bb790a55dc2ffbfb96aeec4b62
Author: Sutou Kouhei <[email protected]>
AuthorDate: Thu Jun 5 11:28:45 2025 +0900
Add a lint CI (#21)
This upgrades SwiftLint to the latest version (0.59.1) from 0.53.0. So
some format fixes are included.
Closes #20.
---
.github/workflows/test.yaml | 56 ++++++++++++++++++++++
.pre-commit-config.yaml | 26 ++++++++++
Arrow/Package.swift | 16 +++----
Arrow/Sources/Arrow/ArrowBufferBuilder.swift | 2 +-
Arrow/Sources/Arrow/ArrowCExporter.swift | 6 +--
Arrow/Sources/Arrow/ArrowCImporter.swift | 4 +-
Arrow/Sources/Arrow/ArrowReaderHelper.swift | 2 +-
Arrow/Sources/Arrow/ArrowWriterHelper.swift | 14 +++---
Arrow/Tests/ArrowTests/ArrayTests.swift | 20 ++++----
ArrowFlight/Sources/ArrowFlight/FlightServer.swift | 4 +-
.../Tests/ArrowFlightTests/FlightTest.swift | 2 +-
11 files changed, 117 insertions(+), 35 deletions(-)
diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml
new file mode 100644
index 0000000..3553a3c
--- /dev/null
+++ b/.github/workflows/test.yaml
@@ -0,0 +1,56 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+name: Test
+
+on:
+ push:
+ branches:
+ - '**'
+ - '!dependabot/**'
+ tags:
+ - '**'
+ pull_request:
+
+concurrency:
+ group: ${{ github.repository }}-${{ github.head_ref || github.sha }}-${{
github.workflow }}
+ cancel-in-progress: true
+
+permissions:
+ contents: read
+
+jobs:
+ lint:
+ name: Lint
+ runs-on: ubuntu-latest
+ timeout-minutes: 15
+ steps:
+ - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 #
v4.2.2
+ - uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 #
v5.6.0
+ with:
+ python-version: 3
+ - uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3
+ with:
+ path: ~/.cache/pre-commit
+ key: pre-commit-${{ hashFiles('.pre-commit-config.yaml') }}
+ restore-keys: pre-commit-
+ - name: Install pre-commit
+ run: |
+ python -m pip install pre-commit
+ - name: Run pre-commit
+ run: |
+ pre-commit run --show-diff-on-failure --color=always --all-files
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
new file mode 100644
index 0000000..08682ff
--- /dev/null
+++ b/.pre-commit-config.yaml
@@ -0,0 +1,26 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+repos:
+ - repo: https://github.com/realm/SwiftLint
+ rev: 0.59.1
+ hooks:
+ - id: swiftlint
+ args:
+ - "--fix"
+ - "--format"
+ - "--strict"
diff --git a/Arrow/Package.swift b/Arrow/Package.swift
index d9e328f..ceac634 100644
--- a/Arrow/Package.swift
+++ b/Arrow/Package.swift
@@ -33,34 +33,34 @@ let package = Package(
dependencies: [
.package(url: "https://github.com/google/flatbuffers.git", branch:
"v25.2.10"),
.package(
- url: "https://github.com/apple/swift-atomics.git",
- .upToNextMajor(from: "1.2.0") // or `.upToNextMinor
- )
+ url: "https://github.com/apple/swift-atomics.git",
+ .upToNextMajor(from: "1.2.0") // or `.upToNextMinor
+ )
],
targets: [
.target(
name: "ArrowC",
path: "Sources/ArrowC",
swiftSettings: [
- // build: .unsafeFlags(["-warnings-as-errors"])
+ // build: .unsafeFlags(["-warnings-as-errors"])
]
),
.target(
name: "Arrow",
dependencies: ["ArrowC",
- .product(name: "FlatBuffers", package: "flatbuffers"),
- .product(name: "Atomics", package: "swift-atomics")
+ .product(name: "FlatBuffers", package:
"flatbuffers"),
+ .product(name: "Atomics", package: "swift-atomics")
],
swiftSettings: [
- // build: .unsafeFlags(["-warnings-as-errors"])
+ // build: .unsafeFlags(["-warnings-as-errors"])
]
),
.testTarget(
name: "ArrowTests",
dependencies: ["Arrow", "ArrowC"],
swiftSettings: [
- // build: .unsafeFlags(["-warnings-as-errors"])
+ // build: .unsafeFlags(["-warnings-as-errors"])
]
)
]
diff --git a/Arrow/Sources/Arrow/ArrowBufferBuilder.swift
b/Arrow/Sources/Arrow/ArrowBufferBuilder.swift
index 47f9c40..cc0bae0 100644
--- a/Arrow/Sources/Arrow/ArrowBufferBuilder.swift
+++ b/Arrow/Sources/Arrow/ArrowBufferBuilder.swift
@@ -245,7 +245,7 @@ public class VariableBufferBuilder<T>:
ValuesBufferBuilder<T>, ArrowBufferBuilde
binData.withUnsafeBytes { bufferPointer in
let rawPointer = bufferPointer.baseAddress!
- self.values.rawPointer.advanced(by: Int(currentIndex))
+ self.values.rawPointer.advanced(by: Int(currentIndex))
.copyMemory(from: rawPointer, byteCount: binData.count)
}
diff --git a/Arrow/Sources/Arrow/ArrowCExporter.swift
b/Arrow/Sources/Arrow/ArrowCExporter.swift
index f2dd8ab..bb95b89 100644
--- a/Arrow/Sources/Arrow/ArrowCExporter.swift
+++ b/Arrow/Sources/Arrow/ArrowCExporter.swift
@@ -79,7 +79,7 @@ public class ArrowCExporter {
public init() {}
public func exportType(_ cSchema: inout ArrowC.ArrowSchema, arrowType:
ArrowType, name: String = "") ->
- Result<Bool, ArrowError> {
+ Result<Bool, ArrowError> {
do {
let exportSchema = try ExportSchema(arrowType, name: name)
cSchema.format = exportSchema.arrowTypeNameCstr
@@ -106,8 +106,8 @@ public class ArrowCExporter {
}
public func exportField(_ schema: inout ArrowC.ArrowSchema, field:
ArrowField) ->
- Result<Bool, ArrowError> {
- return exportType(&schema, arrowType: field.type, name: field.name)
+ Result<Bool, ArrowError> {
+ return exportType(&schema, arrowType: field.type, name: field.name)
}
public func exportArray(_ cArray: inout ArrowC.ArrowArray, arrowData:
ArrowData) {
diff --git a/Arrow/Sources/Arrow/ArrowCImporter.swift
b/Arrow/Sources/Arrow/ArrowCImporter.swift
index e65d78d..8381152 100644
--- a/Arrow/Sources/Arrow/ArrowCImporter.swift
+++ b/Arrow/Sources/Arrow/ArrowCImporter.swift
@@ -59,7 +59,7 @@ public class ArrowCImporter {
public init() {}
public func importType(_ cArrow: String, name: String = "") ->
- Result<ArrowField, ArrowError> {
+ Result<ArrowField, ArrowError> {
do {
let type = try ArrowType.fromCDataFormatId(cArrow)
return .success(ArrowField(name, type: ArrowType(type.info),
isNullable: true))
@@ -69,7 +69,7 @@ public class ArrowCImporter {
}
public func importField(_ cSchema: ArrowC.ArrowSchema) ->
- Result<ArrowField, ArrowError> {
+ Result<ArrowField, ArrowError> {
if cSchema.n_children > 0 {
ArrowCImporter.release(cSchema)
return .failure(.invalid("Children currently not supported"))
diff --git a/Arrow/Sources/Arrow/ArrowReaderHelper.swift
b/Arrow/Sources/Arrow/ArrowReaderHelper.swift
index 18cf41a..78ad280 100644
--- a/Arrow/Sources/Arrow/ArrowReaderHelper.swift
+++ b/Arrow/Sources/Arrow/ArrowReaderHelper.swift
@@ -117,7 +117,7 @@ private func makeFixedHolder<T>(
}
}
- func makeStructHolder(
+func makeStructHolder(
_ field: ArrowField,
buffers: [ArrowBuffer],
nullCount: UInt,
diff --git a/Arrow/Sources/Arrow/ArrowWriterHelper.swift
b/Arrow/Sources/Arrow/ArrowWriterHelper.swift
index 4d63192..b3fa2b4 100644
--- a/Arrow/Sources/Arrow/ArrowWriterHelper.swift
+++ b/Arrow/Sources/Arrow/ArrowWriterHelper.swift
@@ -56,29 +56,29 @@ func toFBType( // swiftlint:disable:this
cyclomatic_complexity function_body_len
switch arrowType.id {
case .int8, .uint8:
return .success(org_apache_arrow_flatbuf_Int.createInt(
- &fbb, bitWidth: 8, isSigned: infoType == ArrowType.ArrowInt8))
+ &fbb, bitWidth: 8, isSigned: infoType ==
ArrowType.ArrowInt8))
case .int16, .uint16:
return .success(org_apache_arrow_flatbuf_Int.createInt(
- &fbb, bitWidth: 16, isSigned: infoType == ArrowType.ArrowInt16))
+ &fbb, bitWidth: 16, isSigned: infoType ==
ArrowType.ArrowInt16))
case .int32, .uint32:
return .success(org_apache_arrow_flatbuf_Int.createInt(
- &fbb, bitWidth: 32, isSigned: infoType == ArrowType.ArrowInt32))
+ &fbb, bitWidth: 32, isSigned: infoType ==
ArrowType.ArrowInt32))
case .int64, .uint64:
return .success(org_apache_arrow_flatbuf_Int.createInt(
- &fbb, bitWidth: 64, isSigned: infoType == ArrowType.ArrowInt64))
+ &fbb, bitWidth: 64, isSigned: infoType ==
ArrowType.ArrowInt64))
case .float:
return
.success(org_apache_arrow_flatbuf_FloatingPoint.createFloatingPoint(&fbb,
precision: .single))
case .double:
return
.success(org_apache_arrow_flatbuf_FloatingPoint.createFloatingPoint(&fbb,
precision: .double))
case .string:
return .success(org_apache_arrow_flatbuf_Utf8.endUtf8(
- &fbb, start: org_apache_arrow_flatbuf_Utf8.startUtf8(&fbb)))
+ &fbb, start:
org_apache_arrow_flatbuf_Utf8.startUtf8(&fbb)))
case .binary:
return .success(org_apache_arrow_flatbuf_Binary.endBinary(
- &fbb, start: org_apache_arrow_flatbuf_Binary.startBinary(&fbb)))
+ &fbb, start:
org_apache_arrow_flatbuf_Binary.startBinary(&fbb)))
case .boolean:
return .success(org_apache_arrow_flatbuf_Bool.endBool(
- &fbb, start: org_apache_arrow_flatbuf_Bool.startBool(&fbb)))
+ &fbb, start:
org_apache_arrow_flatbuf_Bool.startBool(&fbb)))
case .date32:
let startOffset = org_apache_arrow_flatbuf_Date.startDate(&fbb)
org_apache_arrow_flatbuf_Date.add(unit: .day, &fbb)
diff --git a/Arrow/Tests/ArrowTests/ArrayTests.swift
b/Arrow/Tests/ArrowTests/ArrayTests.swift
index d793aa1..d0d7064 100644
--- a/Arrow/Tests/ArrowTests/ArrayTests.swift
+++ b/Arrow/Tests/ArrowTests/ArrayTests.swift
@@ -270,14 +270,14 @@ final class ArrayTests: XCTestCase { //
swiftlint:disable:this type_body_length
dateFormatter.timeStyle = .full
XCTAssertTrue(
dateFormatter.string(from: (structArray[0]![STIndex.date.rawValue]
as? Date)!) ==
- dateFormatter.string(from: dateNow))
+ dateFormatter.string(from: dateNow))
}
func checkHolderForType(_ checkType: ArrowType) throws {
let buffers = [ArrowBuffer(length: 0, capacity: 0,
- rawPointer:
UnsafeMutableRawPointer.allocate(byteCount: 0, alignment: .zero)),
+ rawPointer:
UnsafeMutableRawPointer.allocate(byteCount: 0, alignment: .zero)),
ArrowBuffer(length: 0, capacity: 0,
- rawPointer:
UnsafeMutableRawPointer.allocate(byteCount: 0, alignment: .zero))]
+ rawPointer:
UnsafeMutableRawPointer.allocate(byteCount: 0, alignment: .zero))]
let field = ArrowField("", type: checkType, isNullable: true)
switch makeArrayHolder(field, buffers: buffers, nullCount: 0,
children: nil, rbLength: 0) {
case .success(let holder):
@@ -320,13 +320,13 @@ final class ArrayTests: XCTestCase { //
swiftlint:disable:this type_body_length
let stringHBuilder: ArrowArrayHolderBuilder =
(try ArrowArrayBuilders.loadStringArrayBuilder())
- for index in 0..<100 {
- if index % 10 == 9 {
- stringHBuilder.appendAny(nil)
- } else {
- stringHBuilder.appendAny("test" + String(index))
- }
- }
+ for index in 0..<100 {
+ if index % 10 == 9 {
+ stringHBuilder.appendAny(nil)
+ } else {
+ stringHBuilder.appendAny("test" + String(index))
+ }
+ }
let stringHolder = try stringHBuilder.toHolder()
XCTAssertEqual(stringHolder.nullCount, 10)
diff --git a/ArrowFlight/Sources/ArrowFlight/FlightServer.swift
b/ArrowFlight/Sources/ArrowFlight/FlightServer.swift
index 19644d6..8db44ab 100644
--- a/ArrowFlight/Sources/ArrowFlight/FlightServer.swift
+++ b/ArrowFlight/Sources/ArrowFlight/FlightServer.swift
@@ -81,7 +81,7 @@ extension ArrowFlightServer {
}
public func makeFlightServer(_ handler: ArrowFlightServer) ->
CallHandlerProvider {
- return InternalFlightServer(handler)
+ return InternalFlightServer(handler)
}
internal final class InternalFlightServer:
Arrow_Flight_Protocol_FlightServiceAsyncProvider {
@@ -189,6 +189,6 @@ internal final class InternalFlightServer:
Arrow_Flight_Protocol_FlightServiceAs
throw ArrowFlightError.notImplemented()
}
- internal var interceptors:
Arrow_Flight_Protocol_FlightServiceServerInterceptorFactoryProtocol? { return
nil }
+ internal var interceptors:
Arrow_Flight_Protocol_FlightServiceServerInterceptorFactoryProtocol? { return
nil }
}
diff --git a/ArrowFlight/Tests/ArrowFlightTests/FlightTest.swift
b/ArrowFlight/Tests/ArrowFlightTests/FlightTest.swift
index f7bc3c1..33926cb 100644
--- a/ArrowFlight/Tests/ArrowFlightTests/FlightTest.swift
+++ b/ArrowFlight/Tests/ArrowFlightTests/FlightTest.swift
@@ -238,7 +238,7 @@ public class FlightClientTester {
XCTAssertEqual(rb.batches[0].length, 4)
switch ArrowTable.from(recordBatches: rb.batches) {
case .success(let table):
- for column in table.columns {
+ for column in table.columns {
switch column.type.id {
case .double:
let doubleArray = column.data() as?
ChunkedArray<Double>