Skip to content

Commit af176cf

Browse files
authored
Resolve all current code warnings except the one about NIO (#1148)
* Revert "Revert "Resolve all current code warnings (#1143)" (#1145)" 2bd30b1 * Don't update to a new version of Swift NIO
1 parent 5a9d30c commit af176cf

File tree

7 files changed

+21
-17
lines changed

7 files changed

+21
-17
lines changed

Sources/SwiftDocC/Indexing/Navigator/NavigatorIndex.swift

Lines changed: 7 additions & 3 deletions
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

Lines changed: 5 additions & 0 deletions
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

Lines changed: 7 additions & 9 deletions
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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +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+
// When we can update to Swift NIO 2.78.0 we can call `assumeIsolated()` on the future result and avoid this 'capture of non-sendable type' warning.
114115
promise.futureResult.whenComplete { _ in context.close(promise: nil) }
115116
}
116117

Tests/SwiftDocCUtilitiesTests/PreviewServer/PreviewHTTPHandlerTests.swift

Lines changed: 0 additions & 2 deletions
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

Lines changed: 0 additions & 2 deletions
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

Lines changed: 1 addition & 1 deletion
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)