From 18379e18fd3407d26eb1796d5464f1155067314e Mon Sep 17 00:00:00 2001 From: Thomas Rasch Date: Tue, 17 Nov 2026 17:45:39 +0000 Subject: [PATCH] Clean up the SwiftFormat configuration Align the configuration with the shared SwiftFormat setup, bump the CI-pinned SwiftFormat to 0.64.6, and reformat the test suite so the lint gate passes. --- .github/workflows/swift.yml | 2 +- .swift-version | 1 + .swiftformat | 66 +++---------------- Tests/MapnikTests/APIHardeningTests.swift | 8 +-- Tests/MapnikTests/MapnikDatasourceTests.swift | 4 +- Tests/MapnikTests/MetatileTests.swift | 6 +- 6 files changed, 19 insertions(+), 68 deletions(-) create mode 100644 .swift-version diff --git a/.github/workflows/swift.yml b/.github/workflows/swift.yml index b36298e..8893be2 100644 --- a/.github/workflows/swift.yml +++ b/.github/workflows/swift.yml @@ -21,7 +21,7 @@ jobs: - name: Install SwiftFormat run: | curl -fsSL -o /tmp/swiftformat.zip \ - https://github.com/nicklockwood/SwiftFormat/releases/download/0.64.5/swiftformat_linux.zip + https://github.com/nicklockwood/SwiftFormat/releases/download/0.64.6/swiftformat_linux.zip unzip -q /tmp/swiftformat.zip -d /tmp/swiftformat install -m 0755 /tmp/swiftformat/swiftformat_linux /usr/local/bin/swiftformat swiftformat --version diff --git a/.swift-version b/.swift-version new file mode 100644 index 0000000..c596943 --- /dev/null +++ b/.swift-version @@ -0,0 +1 @@ +6.4 diff --git a/.swiftformat b/.swiftformat index 86df1d9..41dd5ab 100644 --- a/.swiftformat +++ b/.swiftformat @@ -1,44 +1,29 @@ ---acronyms ID,URL,UUID +--min-version 0.64.6 --allman false --allow-partial-wrapping false --anonymous-for-each convert --asset-literals visual-width ---async-capturing ---before-marks --binary-grouping 4,8 --blank-line-after-switch-case multiline-only --call-site-paren same-line ---category-mark "MARK: %c" ---class-threshold 0 ---closing-paren default --closure-void remove --complex-attributes preserve --computed-var-attributes preserve --conditional-assignment after-property ---conflict-markers reject --date-format system --decimal-grouping 3,6 ---default-test-suite-attributes --doc-comments before-declarations --else-position next-line --empty-braces no-space --enum-namespaces always ---enum-threshold 0 --equatable-macro none --exponent-case lowercase --exponent-grouping disabled --extension-acl on-declarations ---extension-mark "MARK: - %t + %c" ---extension-threshold 0 --file-macro "#file" --fraction-grouping disabled ---fragment false --func-attributes preserve ---generic-types ---group-blank-lines true ---grouped-extension "MARK: %c" --guard-else auto ---guard-like-if-statements preserve --header ignore --hex-grouping 4,8 --hex-literal-case uppercase @@ -48,75 +33,39 @@ --indent-blank-lines false --indent-case false --indent-strings false ---inferred-types always --init-coder-nil false ---lifecycle --line-after-marks true --line-between-guards false --linebreaks lf --list-wrap-threshold none ---mark-categories true ---mark-class-threshold 0 ---mark-enum-threshold 0 ---mark-extension-threshold 0 ---mark-extensions always ---mark-struct-threshold 0 ---mark-types always --markdown-files ignore --max-width none -# Match SwiftLint's modifier_order rule so formatting and lint fixes agree. ---modifier-order override,nonisolated,isolated,open,public,package,internal,fileprivate,private,open(set),public(set),package(set),internal(set),fileprivate(set),private(set),dynamic,mutating,nonmutating,lazy,final,required,convenience,static,class,unowned,weak ---never-trailing --nil-init remove ---no-space-operators ---no-wrap-operators ---non-complex-attributes --octal-grouping 4,8 --operator-func spaced ---organization-mode visibility ---organize-types actor,class,enum,struct --pattern-let hoist --prefer-synthesized-init-for-internal-structs never ---preserve-acronyms ---preserve-decls ---preserved-property-types Package,CoordinateEntryRow --property-types infer-locals-only --ranges spaced --redundant-async tests-only --redundant-optional-binding same-name-only --redundant-throws tests-only --self init-only ---self-required --semicolons inline-only --short-optionals except-properties --single-line-for-each ignore ---single-line-ternary convert --smart-tabs enabled --some-any true ---sort-swiftui-properties none ---sorted-patterns --stored-var-attributes preserve ---strip-unused-args always ---struct-threshold 0 --suite-name-format preserve --tab-width unspecified ---test-case-access-control internal ---test-case-name-format preserve ---throw-capturing +--test-case-name-format standard-identifiers --timezone system ---trailing-closures --trailing-commas always --trim-whitespace always --type-attributes prev-line ---type-blank-lines insert ---type-body-marks preserve +--type-blank-lines preserve --type-delimiter space-after ---type-mark "MARK: - %t" ---type-marks ---type-order ---url-macro none ---visibility-marks ---visibility-order --void-type Void --wrap-arguments before-first --wrap-collections before-first @@ -129,7 +78,10 @@ --wrap-ternary before-operators --wrap-type-aliases before-first --xcode-indentation enabled ---xctest-symbols --yoda-swap always ---disable trailingClosures,unusedArguments,preferExplicitFalse ---enable blankLineAfterSwitchCase,blankLinesAfterGuardStatements,blockComments,isEmpty,preferContains,preferCountWhere,preferFirstWhere,preferFlatMap,preferLazyMap,preferMinOverSorted,preferSwiftStringAPI,preferSwiftTesting,singlePropertyPerLine,sortSwitchCases,unusedPrivateDeclarations,wrapEnumCases,wrapMultilineConditionalAssignment,wrapMultilineFunctionChains +--disable trailingClosures,unusedArguments +--enable blankLineAfterSwitchCase,blankLinesAfterGuardStatements,blockComments,isEmpty,preferContains,preferCountWhere,preferFirstWhere,preferFlatMap,preferMinOverSorted,preferSwiftStringAPI,preferSwiftTesting,singlePropertyPerLine,sortSwitchCases,unusedPrivateDeclarations,wrapEnumCases,wrapMultilineConditionalAssignment,wrapMultilineFunctionChains,commonTypos,forWhere,emptyExtensions,noExplicitOwnership + +# Build products, dependency checkouts and generated data. SwiftFormat +# rewrites files in place, so these must never be scanned. +--exclude .build,.swiftpm diff --git a/Tests/MapnikTests/APIHardeningTests.swift b/Tests/MapnikTests/APIHardeningTests.swift index 26424c4..c0f4b79 100644 --- a/Tests/MapnikTests/APIHardeningTests.swift +++ b/Tests/MapnikTests/APIHardeningTests.swift @@ -9,7 +9,7 @@ struct APIGapTests { /// tileCount counts unique tiles, matching the tilelist. @Test - func `tile count counts unique tiles`() { + func tileCountCountsUniqueTiles() { let builder = TilelistBuilder() builder.add(MapTile(x: 1, y: 2, z: 3)) builder.add(MapTile(x: 1, y: 2, z: 3)) @@ -21,7 +21,7 @@ struct APIGapTests { /// Vector renders honour a requested page size. @Test - func `vector renders honour page size`() throws { + func vectorRendersHonourPageSize() throws { let map = try Mapnik(xml: Fixtures.polygonStyle) let svg = try map.renderSVG(width: 400, height: 300) @@ -35,7 +35,7 @@ struct APIGapTests { /// Vector renders without an explicit size use the map's current size. @Test - func `vector renders default to map size`() throws { + func vectorRendersDefaultToMapSize() throws { let map = try Mapnik(xml: Fixtures.polygonStyle) let svg = try map.renderSVG() let text = String(decoding: svg, as: UTF8.self) @@ -44,7 +44,7 @@ struct APIGapTests { /// ImageFormat's mapnik type string is observable. @Test - func `image format exposes type string`() { + func imageFormatExposesTypeString() { #expect(ImageFormat.png().typeString == "png") #expect(ImageFormat.png(colors: 64).typeString == "png:c=64") #expect(ImageFormat.png256.typeString == "png256") diff --git a/Tests/MapnikTests/MapnikDatasourceTests.swift b/Tests/MapnikTests/MapnikDatasourceTests.swift index ee4c7b9..a27ad51 100644 --- a/Tests/MapnikTests/MapnikDatasourceTests.swift +++ b/Tests/MapnikTests/MapnikDatasourceTests.swift @@ -287,7 +287,7 @@ struct DatasourceLifetimeTests { /// Datasources can be created, queried and destroyed concurrently. @Test - func `concurrent datasource lifecycle is safe`() async throws { + func concurrentDatasourceLifecycleIsSafe() async throws { try await withThrowingTaskGroup(of: Void.self) { group in for _ in 0 ..< 8 { group.addTask { @@ -306,7 +306,7 @@ struct DatasourceLifetimeTests { /// A map keeps working after the counting datasource handle is destroyed. @Test - func `map outlives counting datasource handle`() throws { + func mapOutlivesCountingDatasourceHandle() throws { let map = try Mapnik(xml: Fixtures.polygonStyle) let counter = try #require(mapnik_counting_datasource_create()) defer { mapnik_counting_datasource_destroy(counter) } diff --git a/Tests/MapnikTests/MetatileTests.swift b/Tests/MapnikTests/MetatileTests.swift index 2b2d10d..7e9ab8a 100644 --- a/Tests/MapnikTests/MetatileTests.swift +++ b/Tests/MapnikTests/MetatileTests.swift @@ -409,10 +409,8 @@ struct MetatileTests { for tile in block.tiles { #expect(plain.contains(tile), "tile \(tile) outside the bounding box") } - for tile in block.blockTiles { - if plain.contains(tile) { - #expect(block.tiles.contains(tile)) - } + for tile in block.blockTiles where plain.contains(tile) { + #expect(block.tiles.contains(tile)) } } }