【发布时间】:2023-01-13 10:33:58
【问题描述】:
我对 SwiftLint 相当缺乏经验,但由于如下文中所示的 linting 错误,我的分支无法在 CircleCI 中构建。
我们使用 Carthage 和 Swift Package Manager。从构建阶段 -> Swiftlint Lint 部分可以看出,我们运行了一个 swiftlint shell 脚本。
我的问题是究竟是什么导致了这个问题?我所看到的只是一堆“警告”。输出没有指出究竟是什么导致了 linting 失败(除非所有警告都必须修复)?
另外,如何在本地运行 swift lint 检查而不必在 CircleCI 上运行它?
swiftformat --config .swiftformat --lint .
Running SwiftFormat...
(lint mode - no files will be changed.)
Reading config file at /root/project/.swiftformat
Reading config file at /root/project/.swiftformat
/root/project/Shared/Classes/RestaurantDatabase.swift:253:1: warning: (trailingSpace) Remove trailing space at end of a line.
/root/project/Shared/Classes/RestaurantDatabase.swift:261:1: warning: (trailingSpace) Remove trailing space at end of a line.
/root/project/Shared/Classes/RestaurantDatabase.swift:266:1: warning: (trailingSpace) Remove trailing space at end of a line.
/root/project/Shared/Classes/RestaurantDatabase.swift:277:1: warning: (braces) Wrap braces in accordance with selected style (K&R or Allman).
/root/project/Shared/Classes/RestaurantDatabase.swift:277:1: warning: (wrapMultilineStatementBraces) Wrap the opening brace of multiline statements.
/root/project/Shared/Classes/RestaurantDatabase.swift:278:1: warning: (wrapMultilineStatementBraces) Wrap the opening brace of multiline statements.
/root/project/Shared/Services/Restaurant Creation/TrustedDeviceManager.swift:12:1: warning: (trailingSpace) Remove trailing space at end of a line.
/root/project/Shared/Services/Restaurant Creation/TrustedDeviceManager.swift:421:1: warning: (trailingSpace) Remove trailing space at end of a line.
/root/project/Shared/Services/Restaurant Creation/TrustedDeviceManager.swift:426:1: warning: (trailingSpace) Remove trailing space at end of a line.
/root/project/Shared/Services/Restaurant Creation/TrustedDeviceManager.swift:429:1: warning: (redundantLetError) Remove redundant let error from catch clause.
/root/project/Shared/Services/Restaurant Creation/TrustedDeviceManager.swift:433:1: warning: (trailingSpace) Remove trailing space at end of a line.
/root/project/Shared/Services/Restaurant Creation/TrustedDeviceManager.swift:436:1: warning: (redundantLetError) Remove redundant let error from catch clause.
/root/project/Shared/Services/Restaurant Creation/TrustedDeviceManager.swift:440:1: warning: (trailingSpace) Remove trailing space at end of a line.
/root/project/Shared/Services/Restaurant Creation/TrustedDeviceManager.swift:442:1: warning: (elseOnSameLine) Place else, catch or while keyword in accordance with current style (same or next line).
/root/project/Shared/Services/Restaurant Creation/TrustedDeviceManager.swift:442:1: warning: (wrapMultilineStatementBraces) Wrap the opening brace of multiline statements.
/root/project/Shared/Services/Restaurant Creation/TrustedDeviceManager.swift:443:1: warning: (elseOnSameLine) Place else, catch or while keyword in accordance with current style (same or next line).
/root/project/Shared/Services/Restaurant Creation/TrustedDeviceManager.swift:443:1: warning: (wrapMultilineStatementBraces) Wrap the opening brace of multiline statements.
/root/project/Shared/Services/Restaurant Creation/TrustedDeviceManager.swift:446:1: warning: (trailingSpace) Remove trailing space at end of a line.
/root/project/Shared/Services/Restaurant Creation/TrustedDeviceManager.swift:449:1: warning: (trailingSpace) Remove trailing space at end of a line.
/root/project/Shared/Services/Restaurant Creation/TrustedDeviceManager.swift:457:1: warning: (trailingSpace) Remove trailing space at end of a line.
/root/project/Shared/Services/Restaurant Creation/TrustedDeviceManager.swift:460:1: warning: (trailingSpace) Remove trailing space at end of a line.
/root/project/Shared/Services/Restaurant Creation/TrustedDeviceManager.swift:473:1: warning: (trailingCommas) Add or remove trailing comma from the last item in a collection literal.
/root/project/iOS/Sources/Domains/SupportMode/SupportModeViewModel.swift:314:1: warning: (trailingSpace) Remove trailing space at end of a line.
/root/project/iOS/Sources/Domains/Connectivity/Devices/Utils/DeviceTrust+Utilities.swift:30:1: warning: (trailingSpace) Remove trailing space at end of a line.
/root/project/iOS/Sources/Domains/Connectivity/Devices/Utils/DeviceTrust+Utilities.swift:113:1: warning: (braces) Wrap braces in accordance with selected style (K&R or Allman).
/root/project/iOS/Sources/Domains/Connectivity/Devices/Utils/DeviceTrust+Utilities.swift:113:1: warning: (wrapMultilineStatementBraces) Wrap the opening brace of multiline statements.
/root/project/iOS/Sources/Domains/Connectivity/Devices/Utils/DeviceTrust+Utilities.swift:114:1: warning: (wrapMultilineStatementBraces) Wrap the opening brace of multiline statements.
SwiftFormat completed in 11.35s.
Source input did not pass lint check.
4/2250 files require formatting, 6 files skipped.
Exited with code exit status 1
CircleCI received exit code 1
【问题讨论】: