Skip to content

Commit b1d4c6c

Browse files
authored
Resolve all current code warnings (#1143)
* Silence warning about concurrent access to reference in a DispatchQueue * Avoid deprecation warning when assigning `nil` to deprecated property * Avoid warning about capture of non-sendable type in preview HTTP handler Note: this requires SwiftNIO 2.78.0 or later Also, remove unused non-sendable HTTP handlers in tests * Don't check license headers in "./bin/benchmark/.build/*" * Avoid passing non-sendable FileManager into addTeardownBlock in test
1 parent 77a46d5 commit b1d4c6c

File tree

9 files changed

+26
-23
lines changed

9 files changed

+26
-23
lines changed

Package.resolved

+4-4
Original file line numberDiff line numberDiff line change
@@ -95,17 +95,17 @@
9595
"kind" : "remoteSourceControl",
9696
"location" : "https://github.com/apple/swift-nio.git",
9797
"state" : {
98-
"revision" : "fc79798d5a150d61361a27ce0c51169b889e23de",
99-
"version" : "2.68.0"
98+
"revision" : "ba72f31e11275fc5bf060c966cf6c1f36842a291",
99+
"version" : "2.79.0"
100100
}
101101
},
102102
{
103103
"identity" : "swift-system",
104104
"kind" : "remoteSourceControl",
105105
"location" : "https://github.com/apple/swift-system.git",
106106
"state" : {
107-
"revision" : "6a9e38e7bd22a3b8ba80bddf395623cf68f57807",
108-
"version" : "1.3.1"
107+
"revision" : "c8a44d836fe7913603e246acab7c528c2e780168",
108+
"version" : "1.4.0"
109109
}
110110
}
111111
],

Package.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ let package = Package(
129129
if ProcessInfo.processInfo.environment["SWIFTCI_USE_LOCAL_DEPS"] == nil {
130130
// Building standalone, so fetch all dependencies remotely.
131131
package.dependencies += [
132-
.package(url: "https://github.com/apple/swift-nio.git", from: "2.53.0"),
132+
.package(url: "https://github.com/apple/swift-nio.git", from: "2.78.0"),
133133
.package(url: "https://github.com/apple/swift-markdown.git", branch: "main"),
134134
.package(url: "https://github.com/apple/swift-lmdb.git", branch: "main"),
135135
.package(url: "https://github.com/apple/swift-argument-parser.git", from: "1.2.2"),

Sources/SwiftDocC/Indexing/Navigator/NavigatorIndex.swift

+7-3
Original file line numberDiff line numberDiff line change
@@ -479,7 +479,11 @@ extension NavigatorIndex {
479479

480480
/// The data provider.
481481
@available(*, deprecated, message: "This deprecated API will be removed after 6.2 is released")
482-
public let renderNodeProvider: RenderNodeProvider?
482+
public var renderNodeProvider: RenderNodeProvider? {
483+
_renderNodeProvider as! RenderNodeProvider?
484+
}
485+
// This property only exist to be able to assign `nil` to `renderNodeProvider` in the new initializer without causing a deprecation warning.
486+
private let _renderNodeProvider: Any?
483487

484488
/// The documentation archive to build an index from.
485489
public let archiveURL: URL?
@@ -575,7 +579,7 @@ extension NavigatorIndex {
575579
/// - usePageTitle: Configure the builder to use the "page title" instead of the "navigator title" as the title for each entry.
576580
public init(archiveURL: URL? = nil, outputURL: URL, bundleIdentifier: String, sortRootChildrenByName: Bool = false, groupByLanguage: Bool = false, writePathsOnDisk: Bool = true, usePageTitle: Bool = false) {
577581
self.archiveURL = archiveURL
578-
self.renderNodeProvider = nil
582+
self._renderNodeProvider = nil
579583
self.outputURL = outputURL
580584
self.bundleIdentifier = bundleIdentifier
581585
self.sortRootChildrenByName = sortRootChildrenByName
@@ -587,7 +591,7 @@ extension NavigatorIndex {
587591
@available(*, deprecated, renamed: "init(archiveURL:outputURL:bundleIdentifier:sortRootChildrenByName:groupByLanguage:writePathsOnDisk:usePageTitle:)", message: "Use 'init(archiveURL:outputURL:bundleIdentifier:sortRootChildrenByName:groupByLanguage:writePathsOnDisk:usePageTitle:)' instead. This deprecated API will be removed after 6.2 is released")
588592
@_disfavoredOverload
589593
public init(renderNodeProvider: RenderNodeProvider? = nil, outputURL: URL, bundleIdentifier: String, sortRootChildrenByName: Bool = false, groupByLanguage: Bool = false, writePathsOnDisk: Bool = true, usePageTitle: Bool = false) {
590-
self.renderNodeProvider = renderNodeProvider
594+
self._renderNodeProvider = renderNodeProvider
591595
self.archiveURL = nil
592596
self.outputURL = outputURL
593597
self.bundleIdentifier = bundleIdentifier

Sources/SwiftDocC/Indexing/Navigator/NavigatorTree.swift

+5
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,12 @@ public class NavigatorTree {
119119

120120
func __read() {
121121
let deadline = DispatchTime.now() + timeout
122+
#if swift(>=5.10)
123+
// Access to this local variable is synchronized using the DispatchQueue `queue`, passed as an argument.
124+
nonisolated(unsafe) var processedNodes = [NavigatorTree.Node]()
125+
#else
122126
var processedNodes = [NavigatorTree.Node]()
127+
#endif
123128

124129
while readingCursor.cursor < readingCursor.data.count {
125130
let length = MemoryLayout<UInt32>.stride

Sources/SwiftDocCTestUtilities/XCTestCase+TemporaryDirectory.swift

+7-9
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,8 @@ public extension XCTestCase {
3636
///
3737
/// - Parameters:
3838
/// - pathComponents: The name of the temporary directory.
39-
/// - fileManager: The file manager that will create the directory.
4039
/// - Returns: The URL of the newly created directory.
41-
func createTemporaryDirectory(named: String, fileManager: FileManager = .default) throws -> URL {
40+
func createTemporaryDirectory(named: String) throws -> URL {
4241
try createTemporaryDirectory(pathComponents: named)
4342
}
4443

@@ -48,9 +47,8 @@ public extension XCTestCase {
4847
///
4948
/// - Parameters:
5049
/// - pathComponents: Additional path components to add to the temporary URL.
51-
/// - fileManager: The file manager that will create the directory.
5250
/// - Returns: The URL of the newly created directory.
53-
func createTemporaryDirectory(pathComponents: String..., fileManager: FileManager = .default) throws -> URL {
51+
func createTemporaryDirectory(pathComponents: String...) throws -> URL {
5452
let bundleParentDir = Bundle(for: Self.self).bundleURL.deletingLastPathComponent()
5553
let baseURL = bundleParentDir.appendingPathComponent(name.replacingWhitespaceAndPunctuation(with: "-"))
5654

@@ -62,20 +60,20 @@ public extension XCTestCase {
6260

6361
addTeardownBlock {
6462
do {
65-
if fileManager.fileExists(atPath: baseURL.path) {
66-
try fileManager.removeItem(at: baseURL)
63+
if FileManager.default.fileExists(atPath: baseURL.path) {
64+
try FileManager.default.removeItem(at: baseURL)
6765
}
6866
} catch {
6967
XCTFail("Failed to remove temporary directory: '\(error)'")
7068
}
7169
}
7270

73-
if !fileManager.fileExists(atPath: bundleParentDir.path) {
71+
if !FileManager.default.fileExists(atPath: bundleParentDir.path) {
7472
// Create the base URL directory without intermediate directories so that an error is raised if the parent directory doesn't exist.
75-
try fileManager.createDirectory(at: baseURL, withIntermediateDirectories: false, attributes: nil)
73+
try FileManager.default.createDirectory(at: baseURL, withIntermediateDirectories: false, attributes: nil)
7674
}
7775

78-
try fileManager.createDirectory(at: tempURL, withIntermediateDirectories: true, attributes: nil)
76+
try FileManager.default.createDirectory(at: tempURL, withIntermediateDirectories: true, attributes: nil)
7977

8078
return tempURL
8179
}

Sources/SwiftDocCUtilities/PreviewServer/PreviewHTTPHandler.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ final class PreviewHTTPHandler: ChannelInboundHandler {
111111

112112
// If we don't need to keep the connection alive, close `context` after flushing the response
113113
if !self.keepAlive {
114-
promise.futureResult.whenComplete { _ in context.close(promise: nil) }
114+
promise.futureResult.assumeIsolated().whenComplete { _ in context.close(promise: nil) }
115115
}
116116

117117
context.writeAndFlush(self.wrapOutboundOut(.end(trailers)), promise: promise)

Tests/SwiftDocCUtilitiesTests/PreviewServer/PreviewHTTPHandlerTests.swift

-2
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,8 @@ class PreviewHTTPHandlerTests: XCTestCase {
3333

3434
let response = Response()
3535

36-
XCTAssertNoThrow(try channel.pipeline.addHandler(HTTPResponseEncoder()).wait())
3736
XCTAssertNoThrow(try channel.pipeline.addHandler(response).wait())
3837
XCTAssertNoThrow(try channel.pipeline.addHandler(channelHandler).wait())
39-
XCTAssertNoThrow(try channel.pipeline.addHandler(HTTPServerPipelineHandler()).wait())
4038

4139
XCTAssertNoThrow(try channel.connect(to: SocketAddress(ipAddress: "127.0.0.1", port: 1)).wait())
4240

Tests/SwiftDocCUtilitiesTests/PreviewServer/ServerTestUtils.swift

-2
Original file line numberDiff line numberDiff line change
@@ -92,10 +92,8 @@ func responseWithPipeline(request: HTTPRequestHead, handler factory: RequestHand
9292

9393
let response = Response()
9494

95-
XCTAssertNoThrow(try channel.pipeline.addHandler(HTTPResponseEncoder()).wait(), file: (file), line: line)
9695
XCTAssertNoThrow(try channel.pipeline.addHandler(response).wait(), file: (file), line: line)
9796
XCTAssertNoThrow(try channel.pipeline.addHandler(channelHandler).wait(), file: (file), line: line)
98-
XCTAssertNoThrow(try channel.pipeline.addHandler(HTTPServerPipelineHandler()).wait(), file: (file), line: line)
9997

10098
XCTAssertNoThrow(try channel.connect(to: SocketAddress(ipAddress: "127.0.0.1", port: 1)).wait(), file: (file), line: line)
10199

bin/check-source

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ for language in swift-or-c bash md-or-tutorial html docker; do
4444
declare -a matching_files
4545
declare -a exceptions
4646
declare -a reader
47-
expections=( )
4847
matching_files=( -name '*' )
4948
reader=head
5049
case "$language" in
@@ -136,6 +135,7 @@ EOF
136135
cd "$here/.."
137136
find . \
138137
\( \! -path './.build/*' -a \
138+
\! -path './bin/benchmark/.build/*' -a \
139139
\! -name '.' -a \
140140
\( "${matching_files[@]}" \) -a \
141141
\( \! \( "${exceptions[@]}" \) \) \) | while read line; do

0 commit comments

Comments
 (0)