Skip to content

Commit fd16ed6

Browse files
authored
ci: removed swift-format dependency
1 parent 64afaaa commit fd16ed6

File tree

10 files changed

+45
-28
lines changed

10 files changed

+45
-28
lines changed

Package.swift

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ let package = Package(
2323
.package(url: "https://github.com/swiftlang/swift-syntax.git", "509.1.0"..<"602.0.0"),
2424
.package(url: "https://github.com/apple/swift-collections.git", from: "1.0.4"),
2525
.package(url: "https://github.com/apple/swift-argument-parser.git", from: "1.2.2"),
26-
.package(url: "https://github.com/swiftlang/swift-format", from: "600.0.0"),
2726
.package(url: "https://github.com/swiftlang/swift-docc-plugin", from: "1.0.0"),
2827
],
2928
targets: [
@@ -75,7 +74,6 @@ let package = Package(
7574
dependencies: [
7675
"PluginCore", "MacroPlugin", "MetaCodable", "HelperCoders",
7776
.product(name: "SwiftSyntaxMacrosTestSupport", package: "swift-syntax"),
78-
.product(name: "SwiftSyntaxMacrosGenericTestSupport", package: "swift-syntax"),
7977
],
8078
plugins: ["MetaProtocolCodable"]
8179
),

[email protected]

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ let package = Package(
2323
.package(url: "https://github.com/swiftlang/swift-syntax.git", "509.1.0"..<"602.0.0"),
2424
.package(url: "https://github.com/apple/swift-collections.git", from: "1.0.4"),
2525
.package(url: "https://github.com/apple/swift-argument-parser.git", from: "1.2.2"),
26-
.package(url: "https://github.com/swiftlang/swift-format", from: "600.0.0"),
2726
],
2827
targets: [
2928
// MARK: Core
@@ -86,7 +85,6 @@ let package = Package(
8685
dependencies: [
8786
"PluginCore", "MacroPlugin", "MetaCodable", "HelperCoders", "Testing",
8887
.product(name: "SwiftSyntaxMacrosTestSupport", package: "swift-syntax"),
89-
.product(name: "SwiftSyntaxMacrosGenericTestSupport", package: "swift-syntax"),
9088
],
9189
plugins: ["MetaProtocolCodable"]
9290
),
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
import MetaCodable
21
import HelperCoders
2+
import MetaCodable
33

44
@Codable(commonStrategies: [.codedBy(.valueCoder())])
55
struct User {
6-
let id: Int // Will use ValueCoder
7-
let name: String // Will use ValueCoder
8-
let active: Bool // Will use ValueCoder
9-
let score: Double // Will use ValueCoder
6+
let id: Int // Will use ValueCoder
7+
let name: String // Will use ValueCoder
8+
let active: Bool // Will use ValueCoder
9+
let score: Double // Will use ValueCoder
1010
}
Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
1-
import MetaCodable
21
import HelperCoders
2+
import MetaCodable
33

44
@Codable(commonStrategies: [
55
.codedBy(.valueCoder()),
6-
.codedBy(.sequenceCoder(elementHelper: .valueCoder(), configuration: .lossy))
6+
.codedBy(
7+
.sequenceCoder(elementHelper: .valueCoder(), configuration: .lossy
8+
),
79
])
810
struct User {
9-
let id: Int // Will use ValueCoder
10-
let tags: [String] // Will use SequenceCoder with ValueCoder
11-
let scores: [Double] // Will use SequenceCoder with ValueCoder
11+
let id: Int // Will use ValueCoder
12+
let tags: [String] // Will use SequenceCoder with ValueCoder
13+
let scores: [Double] // Will use SequenceCoder with ValueCoder
1214
@CodedBy(ISO8601DateCoder()) // Override with specific coder
1315
let createdAt: Date
1416
}

Sources/MetaCodable/MetaCodable.docc/Tutorials/Helper/Code/Product-01.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import MetaCodable
21
import HelperCoders
2+
import MetaCodable
33

44
@Codable
55
struct Product {

Sources/MetaCodable/MetaCodable.docc/Tutorials/Helper/Code/Product-03.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import MetaCodable
21
import HelperCoders
2+
import MetaCodable
33

44
@Codable(commonStrategies: [.codedBy(.valueCoder())])
55
struct Product {

Sources/PluginCore/Attributes/CodedAs.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ package struct CodedAs: PropertyAttribute {
2424
/// the identifier to this type.
2525
var type: TypeSyntax? {
2626
return node.attributeName.as(IdentifierTypeSyntax.self)?
27-
.genericArgumentClause?.arguments.first?.argument.as(TypeSyntax.self)
27+
.genericArgumentClause?.arguments
28+
.first?.argument.as(TypeSyntax.self)
2829
}
2930

3031
/// Creates a new instance with the provided node.

Sources/TestingMacroPlugin/Expression.swift

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,3 +135,11 @@ struct ExpectThrows: ExpressionMacro {
135135
)
136136
}
137137
}
138+
139+
#if !canImport(SwiftSyntax510)
140+
extension FreestandingMacroExpansionSyntax {
141+
var arguments: LabeledExprListSyntax {
142+
return self.argumentList
143+
}
144+
}
145+
#endif

Tests/MetaCodableTests/Codable/CommonStrategiesValueCoderTests.swift

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -414,7 +414,9 @@ struct CommonStrategiesValueCoderTests {
414414
// Test encoding
415415
let encoder = JSONEncoder()
416416
encoder.outputFormatting = .sortedKeys
417-
let encoded = try String(data: encoder.encode(status), encoding: .utf8)
417+
let encoded = try String(
418+
data: encoder.encode(status), encoding: .utf8
419+
)
418420
#expect(encoded == #"{"since":"20250520","type":"active"}"#)
419421

420422
// Test decoding other cases with numeric values
@@ -425,7 +427,9 @@ struct CommonStrategiesValueCoderTests {
425427
}
426428
"""
427429
let inactiveData = try #require(inactiveJson.data(using: .utf8))
428-
let inactiveStatus = try decoder.decode(Status.self, from: inactiveData)
430+
let inactiveStatus = try decoder.decode(
431+
Status.self, from: inactiveData
432+
)
429433
if case .inactive(let reason) = inactiveStatus {
430434
#expect(reason == "404")
431435
} else {
@@ -440,7 +444,9 @@ struct CommonStrategiesValueCoderTests {
440444
}
441445
"""
442446
let pendingData = try #require(pendingJson.data(using: .utf8))
443-
let pendingStatus = try decoder.decode(Status.self, from: pendingData)
447+
let pendingStatus = try decoder.decode(
448+
Status.self, from: pendingData
449+
)
444450
if case .pending(let until) = pendingStatus {
445451
#expect(until == "20251231")
446452
} else {
@@ -553,16 +559,20 @@ struct CommonStrategiesValueCoderTests {
553559

554560
let jsonData = try #require(json.data(using: .utf8))
555561
let decoder = JSONDecoder()
556-
let model = try decoder.decode(ModelWithOverride.self, from: jsonData)
562+
let model = try decoder.decode(
563+
ModelWithOverride.self, from: jsonData
564+
)
557565

558-
#expect(model.id == 42) // Due to CustomIntCoder doubling the value
559-
#expect(model.count == 42) // Normal ValueCoder behavior
566+
#expect(model.id == 42) // Due to CustomIntCoder doubling the value
567+
#expect(model.count == 42) // Normal ValueCoder behavior
560568

561569
// Test encoding
562570
let encoder = JSONEncoder()
563571
encoder.outputFormatting = .sortedKeys
564-
let encoded = try String(data: encoder.encode(model), encoding: .utf8)
565-
#expect(encoded == #"{"count":42,"id":"21"}"#) // CustomIntCoder halves the value for id
572+
let encoded = try String(
573+
data: encoder.encode(model), encoding: .utf8
574+
)
575+
#expect(encoded == #"{"count":42,"id":"21"}"#) // CustomIntCoder halves the value for id
566576
}
567577

568578
@Test
@@ -632,11 +642,11 @@ fileprivate struct CustomIntCoder: HelperCoder {
632642
debugDescription: "Could not decode value"
633643
)
634644
}
635-
return intValue * 2 // Double the value during decoding
645+
return intValue * 2 // Double the value during decoding
636646
}
637647

638648
func encode(_ value: Int, to encoder: Encoder) throws {
639649
var container = encoder.singleValueContainer()
640-
try container.encode(String(value / 2)) // Halve the value during encoding
650+
try container.encode(String(value / 2)) // Halve the value during encoding
641651
}
642652
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
"test": "METACODABLE_CI=true npm exec --package=swiftylab-ci -- test.mjs",
3131
"archive": "echo implement",
3232
"generate": "echo implement",
33-
"format": "METACODABLE_CI=true npm exec --package=swiftylab-ci -- format.mjs",
33+
"format": "METACODABLE_CI=true swift format --in-place --recursive .",
3434
"pod-lint": "Utils/pod_lint.rb",
3535
"preview-doc": "METACODABLE_CI=true SPI_GENERATE_DOCS=true npm exec --package=swiftylab-ci -- preview-doc.mjs MetaCodable",
3636
"build-doc": "METACODABLE_CI=true SPI_GENERATE_DOCS=true npm exec --package=swiftylab-ci -- build-doc.mjs MetaCodable HelperCoders",

0 commit comments

Comments
 (0)