diff --git a/CHANGELOG.md b/CHANGELOG.md index a1c60e407..be03a46ec 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,34 @@ # Change Log +## [0.54.0](https://github.com/nicklockwood/SwiftFormat/releases/tag/0.54.0) (2024-06-11) + +- Added `blankLineAfterSwitchCase` rule for inserting blank lines after switch cases +- Added `consistentSwitchCaseSpacing` rule for ensuring consistent spacing between switch cases +- Added `redundantProperty` rule for removing variable assignments where value is immediately returned +- Added `redundantTypedThrows` rule for stripping redundant `Never` or `any Error` `throws` types +- Setting `--report` without `--reporter` type now raises an error if type can't be inferred +- Added XML reporter for Checkstyle-compatible lint reporting (use the `--reporter xml` option) +- Added `--typedelimiter` option for controlling spacing around the colon in type definitions +- Added `--initcodernil` option for returning `nil` instead of asserting in unavailable `init?(coder:)` +- The `fileHeader` rule now uses git info for `created` date (if available) instead of file system +- Added git `author`, `author.name` and `author.email` tokens for file header templates +- Added `--callsiteparen` option for controlling closing paren placement at function call sites +- The `wrapAttributes` rule can now be applied differently to computed properties vs stored properties +- The `wrapAttributes` rule can now be applied differently to complex (parameterized) vs simple attributes +- Replaced `--varattributes` with `--storedvarattrs`, `--computedvarattrs` and `--complexattrs` options +- Added `—-nilinit` option for controlling whether `redundantNilInit` adds or removes explicit `nil` +- Added ability to organize declarations by type over visibility (use `--organizationmode type`) +- Fixed bug where enabling `organizeDeclarations` for structs caused `sortDeclarations` to have no effect +- Fixed bug where if statement body could be incorrectly parsed as a trailing closure +- Improved attribute handling in `opaqueGenericParameters rule` +- SwiftFormat now recognizes `init` and `_modify` property accessors +- Fixed bug with `preferForLoop` rule and tuple argument matching +- Extended `conditionalAssignment` rule to handle more cases +- Added `--condassignment after-property` option +- Fixed await being hoisted outside of macro arguments +- Fixed unsafe adding/removal of `self` within macros +- Added `os_log` to `--selfrequired` defaults + ## [0.53.10](https://github.com/nicklockwood/SwiftFormat/releases/tag/0.53.10) (2024-05-18) - Fixed creation of spurious `stdout` directory when using `--output stdout` diff --git a/CommandLineTool/swiftformat b/CommandLineTool/swiftformat index e1e26447c..bfd28635c 100755 Binary files a/CommandLineTool/swiftformat and b/CommandLineTool/swiftformat differ diff --git a/README.md b/README.md index 81c46a7dd..db054fc50 100644 --- a/README.md +++ b/README.md @@ -252,7 +252,7 @@ let package = Package( name: "BuildTools", platforms: [.macOS(.v10_11)], dependencies: [ - .package(url: "https://github.com/nicklockwood/SwiftFormat", from: "0.53.9"), + .package(url: "https://github.com/nicklockwood/SwiftFormat", from: "0.54.0"), ], targets: [.target(name: "BuildTools", path: "")] ) @@ -286,7 +286,7 @@ You can also use `swift run -c release --package-path BuildTools swiftformat "$S 1. Add the `swiftformat` binary to your project directory via [CocoaPods](https://cocoapods.org/), by adding the following line to your Podfile then running `pod install`: ```ruby - pod 'SwiftFormat/CLI', '~> 0.49' + pod 'SwiftFormat/CLI', '~> 0.54' ``` **NOTE:** This will only install the pre-built command-line app, not the source code for the SwiftFormat framework. @@ -354,7 +354,7 @@ You can use `SwiftFormat` as a SwiftPM command plugin. ```swift dependencies: [ // ... - .package(url: "https://github.com/nicklockwood/SwiftFormat", from: "0.53.9"), + .package(url: "https://github.com/nicklockwood/SwiftFormat", from: "0.54.0"), ] ``` @@ -965,6 +965,7 @@ SwiftFormat is not a commercially-funded product, it's a labor of love given fre Credits ------------ +* [Cal Stephens](https://github.com/calda) - Numerous new formatting rules, options and bug fixes * [Tony Arnold](https://github.com/tonyarnold) - SwiftFormat for Xcode * [Vincent Bernier](https://github.com/vinceburn) - SwiftFormat for Xcode settings UI * [Vikram Kriplaney](https://github.com/markiv) - SwiftFormat for Xcode icon and search feature @@ -972,7 +973,6 @@ Credits * [Maxime Marinel](https://github.com/bourvill) - Git pre-commit hook script * [Romain Pouclet](https://github.com/palleas) - Homebrew formula * [Aerobounce](https://github.com/aerobounce) - Homebrew cask and Sublime Text plugin -* [Cal Stephens](https://github.com/calda) - Several new formatting rules and options * [Facundo Menzella](https://github.com/facumenzella) - Several new formatting rules and options * [Ali Akhtarzada](https://github.com/aliak00) - Several path-related CLI enhancements * [Yonas Kolb](https://github.com/yonaskolb) - Swift Package Manager integration @@ -989,6 +989,7 @@ Credits * [Saleem Abdulrasool](https://github.com/compnerd) - Windows build workflow * [Arthur Semenyutin](https://github.com/vox-humana) - Docker image * [Marco Eidinger](https://github.com/MarcoEidinger) - Swift Package Manager plugin +* [Hampus Tågerud](https://github.com/hampustagerud) - Git integration for fileHeader rule * [Nick Lockwood](https://github.com/nicklockwood) - Everything else ([Full list of contributors](https://github.com/nicklockwood/SwiftFormat/graphs/contributors)) diff --git a/Sources/GitFileInfo.swift b/Sources/GitFileInfo.swift index d1394f0ae..cd8291496 100644 --- a/Sources/GitFileInfo.swift +++ b/Sources/GitFileInfo.swift @@ -62,32 +62,36 @@ extension GitFileInfo { private extension String { func shellOutput(cwd: URL? = nil) -> String? { - let process = Process() - let pipe = Pipe() + #if os(macOS) || os(Linux) || os(Windows) + let process = Process() + let pipe = Pipe() - process.executableURL = URL(fileURLWithPath: "/bin/bash") - process.arguments = ["-c", self] - process.standardOutput = pipe - process.standardError = pipe + process.executableURL = URL(fileURLWithPath: "/bin/bash") + process.arguments = ["-c", self] + process.standardOutput = pipe + process.standardError = pipe - if let safeCWD = cwd { - process.currentDirectoryURL = safeCWD - } + if let safeCWD = cwd { + process.currentDirectoryURL = safeCWD + } - let file = pipe.fileHandleForReading + let file = pipe.fileHandleForReading - do { try process.run() } - catch { return nil } + do { try process.run() } + catch { return nil } - process.waitUntilExit() + process.waitUntilExit() - guard process.terminationStatus == 0 else { - return nil - } + guard process.terminationStatus == 0 else { + return nil + } - let outputData = file.readDataToEndOfFile() - return String(data: outputData, encoding: .utf8)? - .trimmingCharacters(in: .whitespacesAndNewlines) + let outputData = file.readDataToEndOfFile() + return String(data: outputData, encoding: .utf8)? + .trimmingCharacters(in: .whitespacesAndNewlines) + #else + return nil + #endif } } diff --git a/Sources/SwiftFormat.swift b/Sources/SwiftFormat.swift index 40796ff1d..562c77e54 100644 --- a/Sources/SwiftFormat.swift +++ b/Sources/SwiftFormat.swift @@ -32,7 +32,7 @@ import Foundation /// The current SwiftFormat version -let swiftFormatVersion = "0.53.10" +let swiftFormatVersion = "0.54.0" public let version = swiftFormatVersion /// The standard SwiftFormat config file name diff --git a/SwiftFormat.podspec.json b/SwiftFormat.podspec.json index c1af2c8ce..f912e1bb1 100644 --- a/SwiftFormat.podspec.json +++ b/SwiftFormat.podspec.json @@ -1,6 +1,6 @@ { "name": "SwiftFormat", - "version": "0.53.10", + "version": "0.54.0", "license": { "type": "MIT", "file": "LICENSE.md" @@ -10,7 +10,7 @@ "authors": "Nick Lockwood", "source": { "git": "https://github.com/nicklockwood/SwiftFormat.git", - "tag": "0.53.10" + "tag": "0.54.0" }, "default_subspecs": "Core", "subspecs": [ diff --git a/SwiftFormat.xcodeproj/project.pbxproj b/SwiftFormat.xcodeproj/project.pbxproj index 2fe883b3f..3f86acb12 100644 --- a/SwiftFormat.xcodeproj/project.pbxproj +++ b/SwiftFormat.xcodeproj/project.pbxproj @@ -1154,7 +1154,7 @@ "@loader_path/Frameworks", ); MACOSX_DEPLOYMENT_TARGET = 10.14; - MARKETING_VERSION = 0.53.10; + MARKETING_VERSION = 0.54.0; MODULE_VERIFIER_SUPPORTED_LANGUAGES = "objective-c objective-c++"; MODULE_VERIFIER_SUPPORTED_LANGUAGE_STANDARDS = "gnu99 gnu++11"; PRODUCT_BUNDLE_IDENTIFIER = com.charcoaldesign.SwiftFormat; @@ -1187,7 +1187,7 @@ "@loader_path/Frameworks", ); MACOSX_DEPLOYMENT_TARGET = 10.14; - MARKETING_VERSION = 0.53.10; + MARKETING_VERSION = 0.54.0; MODULE_VERIFIER_SUPPORTED_LANGUAGES = "objective-c objective-c++"; MODULE_VERIFIER_SUPPORTED_LANGUAGE_STANDARDS = "gnu99 gnu++11"; PRODUCT_BUNDLE_IDENTIFIER = com.charcoaldesign.SwiftFormat; @@ -1294,7 +1294,7 @@ "@executable_path/../Frameworks", ); MACOSX_DEPLOYMENT_TARGET = 10.14; - MARKETING_VERSION = 0.53.10; + MARKETING_VERSION = 0.54.0; PRODUCT_BUNDLE_IDENTIFIER = "com.charcoaldesign.SwiftFormat-for-Xcode"; PRODUCT_NAME = "SwiftFormat for Xcode"; PROVISIONING_PROFILE_SPECIFIER = ""; @@ -1325,7 +1325,7 @@ "@executable_path/../Frameworks", ); MACOSX_DEPLOYMENT_TARGET = 10.14; - MARKETING_VERSION = 0.53.10; + MARKETING_VERSION = 0.54.0; PRODUCT_BUNDLE_IDENTIFIER = "com.charcoaldesign.SwiftFormat-for-Xcode"; PRODUCT_NAME = "SwiftFormat for Xcode"; PROVISIONING_PROFILE_SPECIFIER = ""; @@ -1353,7 +1353,7 @@ "@executable_path/../../../../Frameworks", ); MACOSX_DEPLOYMENT_TARGET = 10.14; - MARKETING_VERSION = 0.53.10; + MARKETING_VERSION = 0.54.0; PRODUCT_BUNDLE_IDENTIFIER = "com.charcoaldesign.SwiftFormat-for-Xcode.SourceEditorExtension"; PRODUCT_NAME = SwiftFormat; PROVISIONING_PROFILE_SPECIFIER = ""; @@ -1382,7 +1382,7 @@ "@executable_path/../../../../Frameworks", ); MACOSX_DEPLOYMENT_TARGET = 10.14; - MARKETING_VERSION = 0.53.10; + MARKETING_VERSION = 0.54.0; PRODUCT_BUNDLE_IDENTIFIER = "com.charcoaldesign.SwiftFormat-for-Xcode.SourceEditorExtension"; PRODUCT_NAME = SwiftFormat; PROVISIONING_PROFILE_SPECIFIER = "";