Adopt swift-format (#2794)

* Apply formatting

* Apply no block comments rule

* Apply OmitExplicitReturns

* Apple OnlyOneTrailingClosureArgument

* Apply NoAssignmentInExpressions

* Fix up DontRepeatTypeInStaticProperties lint errors

* Apply `OrderedImports`

* Apply `ReplaceForEachWithForLoop`

* format file

* Enable the formatting pipeline

* Adopt `AmbiguousTrailingClosureOverload`

* Fix license header

* Fix format check

* Fix `EndOfLineComment`

* Fix CI

* Adapt CI script to check if changes when running formatting

* Separate lint and format into to steps

* Fix format

* Adopt `UseEarlyExits`

* Revert "Adopt `UseEarlyExits`"

This reverts commit d1ac5bbe12.
This commit is contained in:
Franz Busch authored and GitHub committed 2024-07-19 11:48:17 +02:00
1 parent 980bd3e630
commit c9756e1083
374 files changed
+23992 -14890

No files matched your search

@@ -218,16 +218,16 @@ final class BufferedWriterTests: XCTestCase {
)
}
XCTAssertEqual(writtenBytes, 128)
guard let fileInfo = try await fs.info(forFileAt: path) else {
XCTFail()
return
}
// Test that the newly created file contains all the 128 characters.
XCTAssertEqual(fileInfo.size, 128)
}
func testBufferedWriterReclaimsStorageAfterLargeWrite() async throws {
let fs = FileSystem.shared
let path = try await fs.temporaryFilePath()
@@ -28,7 +28,7 @@ final class FileHandleTests: XCTestCase {
.lexicallyNormalized()
private static func temporaryFileName() -> FilePath {
return FilePath("swift-filesystem-tests-\(UInt64.random(in: .min ... .max))")
FilePath("swift-filesystem-tests-\(UInt64.random(in: .min ... .max))")
}
func withTemporaryFile(
@@ -223,7 +223,7 @@ final class FileHandleTests: XCTestCase {
try await self.withTemporaryFile { handle in
// Check we can successfully return a value.
let value = try await handle.withUnsafeDescriptor { descriptor in
return 42
42
}
XCTAssertEqual(value, 42)
}
@@ -306,7 +306,7 @@ final class FileHandleTests: XCTestCase {
func testWriteAndReadUnseekableFile() async throws {
let privateTempDirPath = try await FileSystem.shared.createTemporaryDirectory(template: "test-XXX")
self.addTeardownBlock {
try await FileSystem.shared.removeItem(at: privateTempDirPath, recursively: true)
try await FileSystem.shared.removeItem(at: privateTempDirPath, recursively: true)
}
guard mkfifo(privateTempDirPath.appending("fifo").string, 0o644) == 0 else {
@@ -327,7 +327,7 @@ final class FileHandleTests: XCTestCase {
func testWriteAndReadUnseekableFileOverMaximumSizeAllowedThrowsError() async throws {
let privateTempDirPath = try await FileSystem.shared.createTemporaryDirectory(template: "test-XXX")
self.addTeardownBlock {
try await FileSystem.shared.removeItem(at: privateTempDirPath, recursively: true)
try await FileSystem.shared.removeItem(at: privateTempDirPath, recursively: true)
}
guard mkfifo(privateTempDirPath.appending("fifo").string, 0o644) == 0 else {
@@ -351,7 +351,7 @@ final class FileHandleTests: XCTestCase {
func testWriteAndReadUnseekableFileWithOffsetsThrows() async throws {
let privateTempDirPath = try await FileSystem.shared.createTemporaryDirectory(template: "test-XXX")
self.addTeardownBlock {
try await FileSystem.shared.removeItem(at: privateTempDirPath, recursively: true)
try await FileSystem.shared.removeItem(at: privateTempDirPath, recursively: true)
}
guard mkfifo(privateTempDirPath.appending("fifo").string, 0o644) == 0 else {
@@ -61,7 +61,7 @@ extension FileSystem {
@available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *)
final class FileSystemTests: XCTestCase {
var fs: FileSystem { return .shared }
var fs: FileSystem { .shared }
func testOpenFileForReading() async throws {
try await self.fs.withFileHandle(forReadingAt: .testDataReadme) { file in
@@ -708,7 +708,7 @@ final class FileSystemTests: XCTestCase {
throw error
} shouldCopyFile: { source, destination in
// Copy the directory and 'file-1-regular'
return (source == path) || (source.lastComponent!.string == "file-0-regular")
(source == path) || (source.lastComponent!.string == "file-0-regular")
}
let paths = try await self.fs.withDirectoryHandle(atPath: copyPath) { dir in