Feature/project#28
Conversation
There was a problem hiding this comment.
Code Review
This pull request integrates swift-format for consistent code styling and updates the package manifest to apply global Swift settings and linting across targets. Key changes include adopting public import for several modules, transitioning to any Error in Task types, and refactoring LRUCache tests to use a unified protocol for cross-implementation testing. Feedback focuses on simplifying the target configuration logic in Package.swift, correcting typos in method names and log strings, and replacing non-idiomatic if case let usage with standard assignments.
| for target in package.targets { | ||
| if [.executable, .test, .regular].contains(target.type) { | ||
| do { | ||
| var swiftSettings = target.swiftSettings ?? [] | ||
| defer { | ||
| target.swiftSettings = swiftSettings | ||
| } | ||
| swiftSettings += [ | ||
| .enableUpcomingFeature("InternalImportsByDefault"), | ||
| .enableUpcomingFeature("NonisolatedNonsendingByDefault"), | ||
| .enableUpcomingFeature("MemberImportVisibility"), | ||
| .enableUpcomingFeature("InferIsolatedConformances"), | ||
| .enableUpcomingFeature("ImmutableWeakCaptures"), | ||
| .enableUpcomingFeature("ExistentialAny") | ||
| ] | ||
| } | ||
| do { | ||
| var plugins = target.plugins ?? [] | ||
| defer { | ||
| target.plugins = plugins | ||
| } | ||
| plugins += [ | ||
| .plugin(name: "Lint", package: "swift-format-plugin") | ||
| ] | ||
| } | ||
| } | ||
| } |
There was a problem hiding this comment.
The loop to apply global settings can be simplified by removing the do blocks and defer statements, which makes the configuration more concise and readable.
for target in package.targets {
if [.executable, .test, .regular].contains(target.type) {
target.swiftSettings = (target.swiftSettings ?? []) + [
.enableUpcomingFeature("InternalImportsByDefault"),
.enableUpcomingFeature("NonisolatedNonsendingByDefault"),
.enableUpcomingFeature("MemberImportVisibility"),
.enableUpcomingFeature("InferIsolatedConformances"),
.enableUpcomingFeature("ImmutableWeakCaptures"),
.enableUpcomingFeature("ExistentialAny")
]
target.plugins = (target.plugins ?? []) + [
.plugin(name: "Lint", package: "swift-format-plugin")
]
}
}| } | ||
|
|
||
| private func peformChange(_ change: Staging<Key>.Change, with url: URL) -> Task<Void, Error> { | ||
| private func peformChange(_ change: Staging<Key>.Change, with url: URL) -> Task<Void, any Error> { |
There was a problem hiding this comment.
Typo in method name: peformChange should be performChange. Note that you should also update the call site in the _flush method.
| private func peformChange(_ change: Staging<Key>.Change, with url: URL) -> Task<Void, any Error> { | |
| private func performChange(_ change: Staging<Key>.Change, with url: URL) -> Task<Void, any Error> { |
| if case let dir = url.deletingLastPathComponent(), | ||
| !FileManager.default.fileExists(atPath: dir.path) { | ||
| !FileManager.default.fileExists(atPath: dir.path) | ||
| { |
| size -= item.meta.totalFileAllocatedSize ?? 0 | ||
| logger.debug("\(self.logKey)sweeped item: \(item.url.lastPathComponent), size: \(item.meta.totalFileAllocatedSize ?? 0)") | ||
| logger.debug( | ||
| "\(self.logKey)sweeped item: \(item.url.lastPathComponent), size: \(item.meta.totalFileAllocatedSize ?? 0)" |
There was a problem hiding this comment.
No description provided.