From d56d9f126774906fc4f269a01f2bffa34f08d0b3 Mon Sep 17 00:00:00 2001 From: George Barnett Date: Thu, 28 Mar 2024 14:54:51 +0000 Subject: [PATCH] Update formatting script Motivation: The formatting script only checkes Sources and Tests. The Plugins and directory are currently not checked. Moreover the formatter is using the 5.9 version. Modifications: - Update the formatter to use 5.10 - Upadte the formatting script to check Plugins - Run formatter Result: Formatting checks more places --- Plugins/GRPCSwiftPlugin/plugin.swift | 18 ++++++++++-------- scripts/format.sh | 10 +++++++--- 2 files changed, 17 insertions(+), 11 deletions(-) diff --git a/Plugins/GRPCSwiftPlugin/plugin.swift b/Plugins/GRPCSwiftPlugin/plugin.swift index 4f4d6e6e6..f29000bc0 100644 --- a/Plugins/GRPCSwiftPlugin/plugin.swift +++ b/Plugins/GRPCSwiftPlugin/plugin.swift @@ -36,9 +36,9 @@ struct GRPCSwiftPlugin { return "The input file '\(path)' does not have a '.proto' extension." case let .noConfigFound(path): return """ - No configuration file found named '\(path)'. The file must not be listed in the \ - 'exclude:' argument for the target in Package.swift. - """ + No configuration file found named '\(path)'. The file must not be listed in the \ + 'exclude:' argument for the target in Package.swift. + """ } } } @@ -99,11 +99,13 @@ struct GRPCSwiftPlugin { sourceFiles: FileList, tool: (String) throws -> PackagePlugin.PluginContext.Tool ) throws -> [Command] { - guard let configurationFilePath = sourceFiles.first( - where: { - $0.path.lastComponent == Self.configurationFileName - } - )?.path else { + guard + let configurationFilePath = sourceFiles.first( + where: { + $0.path.lastComponent == Self.configurationFileName + } + )?.path + else { throw PluginError.noConfigFound(Self.configurationFileName) } diff --git a/scripts/format.sh b/scripts/format.sh index d995546f9..2eda38c00 100755 --- a/scripts/format.sh +++ b/scripts/format.sh @@ -56,7 +56,7 @@ THIS_SCRIPT=$0 HERE="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" REPO="$HERE/.." SWIFTFORMAT_DIR="$HERE/.swift-format-source" -SWIFTFORMAT_VERSION=509.0.0 +SWIFTFORMAT_VERSION=510.0.0 # Clone SwiftFormat if we don't already have it. if [ ! -d "$SWIFTFORMAT_DIR" ]; then @@ -91,7 +91,9 @@ fi if "$lint"; then "${SWIFTFORMAT_BIN}" lint \ --parallel --recursive --strict \ - "${REPO}/Sources" "${REPO}/Tests" \ + "${REPO}/Sources" \ + "${REPO}/Tests" \ + "${REPO}/Plugins" \ && SWIFT_FORMAT_RC=$? || SWIFT_FORMAT_RC=$? if [[ "${SWIFT_FORMAT_RC}" -ne 0 ]]; then @@ -108,7 +110,9 @@ if "$lint"; then elif "$format"; then "${SWIFTFORMAT_BIN}" format \ --parallel --recursive --in-place \ - "${REPO}/Sources" "${REPO}/Tests" \ + "${REPO}/Sources" \ + "${REPO}/Tests" \ + "${REPO}/Plugins" \ && SWIFT_FORMAT_RC=$? || SWIFT_FORMAT_RC=$? if [[ "${SWIFT_FORMAT_RC}" -ne 0 ]]; then