Skip to content

Commit 5a49333

Browse files
fatbobmanclaude
andcommitted
fix: Remove all trailing commas for Linux Swift 6.0 compatibility
- Update SwiftLint config to include Sources and Tests directories - Fix SwiftFormat config to use --commas inline instead of always - Remove trailing commas from all test files - Add fix-linux-trailing-comma branch to CI workflow for testing This comprehensive fix ensures all Swift files comply with Linux Swift 6.0 compiler requirements regarding trailing commas. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 18b2ae6 commit 5a49333

32 files changed

+130
-136
lines changed

.github/workflows/linux-compatibility.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: Linux Compatibility Tests
22

33
on:
44
push:
5-
branches: [ main, develop ]
5+
branches: [ main, develop, fix-linux-trailing-comma ]
66
pull_request:
77
branches: [ main, develop ]
88

.swiftformat

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@
2020
# 指定闭合括号与前一行在同一行
2121
--closurevoid remove
2222
# 移除闭包的 void 类型
23-
--commas always
24-
# 始终在参数列表中使用逗号
23+
--commas inline
24+
# 仅在内联时使用逗号(避免尾随逗号以兼容 Linux Swift 6.0)
2525
--complexattrs preserve
2626
# 保留复杂属性
2727
--computedvarattrs preserve
@@ -96,8 +96,7 @@
9696
# 设置最大宽度为 200 字符
9797
--modifierorder
9898
# 设置修饰符顺序
99-
--nevertrailing
100-
# 禁用尾随逗号(兼容 Linux Swift 6.0)
99+
# --nevertrailing 选项不存在,使用 --commas inline 代替
101100
--nilinit remove
102101
# 移除 nil 初始化
103102
--nospaceoperators

.swiftlint.yml

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,13 @@ disabled_rules:
66
- opening_brace
77

88
included:
9-
- Domain/Sources
10-
- Persistent/Sources
11-
# 如果需要包含测试,添加:
12-
# - Domain/Tests
13-
# - Persistent/Tests
9+
- Sources
10+
- Tests
1411

1512
excluded:
1613
- .build
1714
- .swiftpm
1815
- Generated
19-
- Domain/Tests
20-
- Persistent/Test
2116

2217
missing_docs:
2318
severity: warning

Tests/Objects2XLSXTests/BookGenerationProgressTests.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ struct BookGenerationProgressTests {
100100
.generatingStyles,
101101
.generatingSharedStrings,
102102
.generatingCoreProperties,
103-
.generatingAppProperties,
103+
.generatingAppProperties
104104
]
105105

106106
// 验证进度递增
@@ -154,7 +154,7 @@ struct BookGenerationProgressTests {
154154
.generatingAppProperties,
155155
.preparingPackage,
156156
.cleaningUp,
157-
.completed,
157+
.completed
158158
]
159159

160160
// 验证整个流程的进度是递增的

Tests/Objects2XLSXTests/BookWriteTests.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ struct BookWriteTests {
1414
// Create test data
1515
let testData = [
1616
TestPerson(name: "Alice", age: 30, email: "alice@test.com"),
17-
TestPerson(name: "Bob", age: 25, email: "bob@test.com"),
17+
TestPerson(name: "Bob", age: 25, email: "bob@test.com")
1818
]
1919

2020
// Create sheet
@@ -102,13 +102,13 @@ struct BookWriteTests {
102102
// Create test data for multiple sheets
103103
let people = [
104104
TestPerson(name: "John", age: 30, email: "john@test.com"),
105-
TestPerson(name: "Jane", age: 25, email: "jane@test.com"),
105+
TestPerson(name: "Jane", age: 25, email: "jane@test.com")
106106
]
107107

108108
let products = [
109109
TestProduct(name: "iPhone", price: 999.0),
110110
TestProduct(name: "MacBook", price: 1999.0),
111-
TestProduct(name: "iPad", price: 599.0),
111+
TestProduct(name: "iPad", price: 599.0)
112112
]
113113

114114
// Create sheets
@@ -126,7 +126,7 @@ struct BookWriteTests {
126126
// Create book
127127
let book = Book(style: BookStyle(), sheets: [
128128
peopleSheet.eraseToAnySheet(),
129-
productsSheet.eraseToAnySheet(),
129+
productsSheet.eraseToAnySheet()
130130
])
131131

132132
// Test complete write flow

Tests/Objects2XLSXTests/BookXMLGenerationTests.swift

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ struct BookXMLGenerationTests {
2828
hasHeader: false,
2929
estimatedDataRowCount: 5,
3030
activeColumnCount: 2,
31-
dataRange: nil),
31+
dataRange: nil)
3232
]
3333

3434
// Create book and generate XML
@@ -77,7 +77,7 @@ struct BookXMLGenerationTests {
7777
hasHeader: true,
7878
estimatedDataRowCount: 0,
7979
activeColumnCount: 0,
80-
dataRange: nil),
80+
dataRange: nil)
8181
]
8282

8383
let book = Book(style: BookStyle())
@@ -102,7 +102,7 @@ struct BookXMLGenerationTests {
102102
hasHeader: true,
103103
estimatedDataRowCount: 5,
104104
activeColumnCount: 2,
105-
dataRange: nil),
105+
dataRange: nil)
106106
]
107107

108108
// Create temp directory
@@ -296,7 +296,7 @@ struct BookXMLGenerationTests {
296296
hasHeader: false,
297297
estimatedDataRowCount: 5,
298298
activeColumnCount: 2,
299-
dataRange: nil),
299+
dataRange: nil)
300300
]
301301

302302
let book = Book(style: BookStyle())
@@ -348,7 +348,7 @@ struct BookXMLGenerationTests {
348348
hasHeader: true,
349349
estimatedDataRowCount: 5,
350350
activeColumnCount: 2,
351-
dataRange: nil),
351+
dataRange: nil)
352352
]
353353

354354
// Create temp directory
@@ -447,7 +447,7 @@ struct BookXMLGenerationTests {
447447
hasHeader: true,
448448
estimatedDataRowCount: 50,
449449
activeColumnCount: 3,
450-
dataRange: nil),
450+
dataRange: nil)
451451
]
452452

453453
let book = Book(style: BookStyle())
@@ -503,7 +503,7 @@ struct BookXMLGenerationTests {
503503
hasHeader: true,
504504
estimatedDataRowCount: 10,
505505
activeColumnCount: 2,
506-
dataRange: nil),
506+
dataRange: nil)
507507
]
508508

509509
// Create temp directory

Tests/Objects2XLSXTests/BoolTypeEnhancementTests.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ struct BoolTypeEnhancementTests {
110110
let data = [
111111
TestModel(name: "User A", isActive: true, optionalActive: true, isPremium: true),
112112
TestModel(name: "User B", isActive: false, optionalActive: nil, isPremium: nil),
113-
TestModel(name: "User C", isActive: true, optionalActive: false, isPremium: nil),
113+
TestModel(name: "User C", isActive: true, optionalActive: false, isPremium: nil)
114114
]
115115

116116
let sheet = Sheet<TestModel>(name: "Test", dataProvider: { data }) {
@@ -146,7 +146,7 @@ struct BoolTypeEnhancementTests {
146146
let defaultValue = true
147147

148148
let data = [
149-
TestModel(name: "User", isActive: true, optionalActive: nil, isPremium: nil),
149+
TestModel(name: "User", isActive: true, optionalActive: nil, isPremium: nil)
150150
]
151151

152152
let sheet = Sheet<TestModel>(name: "Test", dataProvider: { data }) {
@@ -176,7 +176,7 @@ struct BoolTypeEnhancementTests {
176176
@Test("Bool Column toString transformation")
177177
func boolColumnToStringTransformation() throws {
178178
let data = [
179-
TestModel(name: "User", isActive: true, optionalActive: false, isPremium: nil),
179+
TestModel(name: "User", isActive: true, optionalActive: false, isPremium: nil)
180180
]
181181

182182
let sheet = Sheet<TestModel>(name: "Test", dataProvider: { data }) {
@@ -211,7 +211,7 @@ struct BoolTypeEnhancementTests {
211211
let data = [
212212
BoolTestModel(status: "active", optionalStatus: "yes"),
213213
BoolTestModel(status: "inactive", optionalStatus: nil),
214-
BoolTestModel(status: "ACTIVE", optionalStatus: "true"),
214+
BoolTestModel(status: "ACTIVE", optionalStatus: "true")
215215
]
216216

217217
let sheet = Sheet<BoolTestModel>(name: "Test", dataProvider: { data }) {
@@ -291,7 +291,7 @@ struct BoolTypeEnhancementTests {
291291
.oneAndZero,
292292
.tAndF,
293293
.yesAndNo,
294-
.custom(true: "On", false: "Off"),
294+
.custom(true: "On", false: "Off")
295295
]
296296

297297
let expectedTrue = ["TRUE", "1", "T", "YES", "ON"]

Tests/Objects2XLSXTests/BooleanSharedStringOptimizationTests.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ struct BooleanSharedStringOptimizationTests {
2727
let people = [
2828
TestPerson(name: "Alice", isActive: true, hasPermission: true),
2929
TestPerson(name: "Bob", isActive: false, hasPermission: false),
30-
TestPerson(name: "Charlie", isActive: true, hasPermission: nil),
30+
TestPerson(name: "Charlie", isActive: true, hasPermission: nil)
3131
]
3232

3333
let sheet = Sheet<TestPerson>(name: "People", dataProvider: { people }) {
@@ -72,7 +72,7 @@ struct BooleanSharedStringOptimizationTests {
7272
let people = [
7373
TestPerson(name: "Alice", isActive: true, hasPermission: true),
7474
TestPerson(name: "Bob", isActive: false, hasPermission: false),
75-
TestPerson(name: "Charlie", isActive: true, hasPermission: nil),
75+
TestPerson(name: "Charlie", isActive: true, hasPermission: nil)
7676
]
7777

7878
let sheet = Sheet<TestPerson>(name: "People", dataProvider: { people }) {
@@ -112,7 +112,7 @@ struct BooleanSharedStringOptimizationTests {
112112
func yesAndNoUsesSharedString() throws {
113113
let people = [
114114
TestPerson(name: "Alice", isActive: true, hasPermission: true),
115-
TestPerson(name: "Bob", isActive: false, hasPermission: false),
115+
TestPerson(name: "Bob", isActive: false, hasPermission: false)
116116
]
117117

118118
let sheet = Sheet<TestPerson>(name: "People", dataProvider: { people }) {
@@ -145,7 +145,7 @@ struct BooleanSharedStringOptimizationTests {
145145
@Test("tAndF expressions should use SharedString")
146146
func tAndFUsesSharedString() throws {
147147
let people = [
148-
TestPerson(name: "Alice", isActive: true, hasPermission: false),
148+
TestPerson(name: "Alice", isActive: true, hasPermission: false)
149149
]
150150

151151
let sheet = Sheet<TestPerson>(name: "People", dataProvider: { people }) {
@@ -181,7 +181,7 @@ struct BooleanSharedStringOptimizationTests {
181181
func customExpressionsAlwaysSharedString() throws {
182182
let people = [
183183
TestPerson(name: "Alice", isActive: true, hasPermission: false),
184-
TestPerson(name: "Bob", isActive: false, hasPermission: true),
184+
TestPerson(name: "Bob", isActive: false, hasPermission: true)
185185
]
186186

187187
// Test short custom expressions (now use SharedString for Excel compatibility)
@@ -208,7 +208,7 @@ struct BooleanSharedStringOptimizationTests {
208208
// Test long custom expressions (should use SharedString)
209209
let longPeople = [
210210
TestPerson(name: "Alice", isActive: true, hasPermission: false),
211-
TestPerson(name: "Bob", isActive: false, hasPermission: true),
211+
TestPerson(name: "Bob", isActive: false, hasPermission: true)
212212
]
213213
let longSheet = Sheet<TestPerson>(name: "Long", dataProvider: { longPeople }) {
214214
Column(

Tests/Objects2XLSXTests/CellStyleMergeTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ struct CellStyleMergeTests {
257257
font: Font(size: 16, name: "Arial"), // override font
258258
fill: nil, // keep base fill
259259
alignment: Alignment.center, // override alignment
260-
border: nil, // keep base border
260+
border: nil // keep base border
261261
)
262262

263263
let merged = CellStyle.merge(base: base, additional: additional)

Tests/Objects2XLSXTests/ColumnWidthTests.swift

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ struct ColumnWidthTests {
2323
let products = [
2424
TestProductWithDesc(id: 1, name: "Product A", price: 99.99, description: "A very long description that requires more space"),
2525
TestProductWithDesc(id: 2, name: "Product B", price: 149.99, description: nil),
26-
TestProductWithDesc(id: 3, name: "Product C", price: 199.99, description: "Short desc"),
26+
TestProductWithDesc(id: 3, name: "Product C", price: 199.99, description: "Short desc")
2727
]
2828

2929
let columns: [AnyColumn<TestProductWithDesc>] = [
@@ -38,7 +38,7 @@ struct ColumnWidthTests {
3838
.eraseToAnyColumn(),
3939
Column<TestProductWithDesc, String?, TextColumnType>(name: "Description", keyPath: \.description, mapping: { TextColumnType(TextColumnConfig(value: $0)) }, nilHandling: .keepEmpty)
4040
.width(40)
41-
.eraseToAnyColumn(),
41+
.eraseToAnyColumn()
4242
]
4343

4444
let sheet = Sheet(name: "Products", dataProvider: { products }, columns: { columns })
@@ -78,7 +78,7 @@ struct ColumnWidthTests {
7878
@Test("Mixed column width sources - Column and SheetStyle")
7979
func mixedColumnWidthSources() throws {
8080
let products = [
81-
TestProductWithDesc(id: 1, name: "Product A", price: 99.99, description: "Description A"),
81+
TestProductWithDesc(id: 1, name: "Product A", price: 99.99, description: "Description A")
8282
]
8383

8484
let columns: [AnyColumn<TestProductWithDesc>] = [
@@ -93,7 +93,7 @@ struct ColumnWidthTests {
9393
.eraseToAnyColumn(),
9494
Column<TestProductWithDesc, String?, TextColumnType>(name: "Description", keyPath: \.description, mapping: { TextColumnType(TextColumnConfig(value: $0)) }, nilHandling: .keepEmpty)
9595
// No width specified in Column
96-
.eraseToAnyColumn(),
96+
.eraseToAnyColumn()
9797
]
9898

9999
// Set some widths directly in SheetStyle
@@ -128,14 +128,14 @@ struct ColumnWidthTests {
128128
let products = [
129129
TestProductWithDesc(id: 1, name: "Product A", price: 99.99, description: "Description A"),
130130
TestProductWithDesc(id: 2, name: "Product B", price: 149.99, description: "Description B"),
131-
TestProductWithDesc(id: 3, name: "Product C", price: 199.99, description: "Description C"),
131+
TestProductWithDesc(id: 3, name: "Product C", price: 199.99, description: "Description C")
132132
]
133133

134134
let columns: [AnyColumn<TestProductWithDesc>] = [
135135
Column<TestProductWithDesc, String, TextColumnType>(name: "Name", keyPath: \.name)
136136
.eraseToAnyColumn(),
137137
Column<TestProductWithDesc, Double, DoubleColumnType>(name: "Price", keyPath: \.price)
138-
.eraseToAnyColumn(),
138+
.eraseToAnyColumn()
139139
]
140140

141141
var sheetStyle = SheetStyle()
@@ -187,7 +187,7 @@ struct ColumnWidthTests {
187187
let columns: [AnyColumn<TestProductWithDesc>] = [
188188
Column<TestProductWithDesc, String, TextColumnType>(name: "Name", keyPath: \.name)
189189
.width(20) // Default unit is characters
190-
.eraseToAnyColumn(),
190+
.eraseToAnyColumn()
191191
]
192192

193193
var sheetStyle = SheetStyle()
@@ -226,7 +226,7 @@ struct ColumnWidthTests {
226226
.eraseToAnyColumn(),
227227
Column<TestProductWithDesc, Double, DoubleColumnType>(name: "Price", keyPath: \.price)
228228
.width(15)
229-
.eraseToAnyColumn(),
229+
.eraseToAnyColumn()
230230
]
231231

232232
let sheet = Sheet(name: "Products", dataProvider: { products }, columns: { columns })

0 commit comments

Comments
 (0)