Skip to content

Commit 7c7c622

Browse files
committed
Add a format-check script for non-code formatting validations
This brings our files into compliance with our existing .editorconfig configuration.
1 parent d09d510 commit 7c7c622

File tree

54 files changed

+245
-187
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+245
-187
lines changed

.github/scripts/format-check.sh

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
#!/bin/bash
2+
##===----------------------------------------------------------------------===##
3+
##
4+
## This source file is part of the Swift open source project
5+
##
6+
## Copyright (c) 2025 Apple Inc. and the Swift project authors
7+
## Licensed under Apache License v2.0 with Runtime Library Exception
8+
##
9+
## See http://swift.org/LICENSE.txt for license information
10+
## See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
11+
##
12+
##===----------------------------------------------------------------------===##
13+
14+
set -euo pipefail
15+
16+
fail=0
17+
18+
while IFS= read -r file; do
19+
# Skip empty or binary files
20+
if [ ! -s "$file" ] || [[ "$file" == *png ]] || [[ "$file" == *mlmodel ]] || [[ "$file" == *mlpackage* ]] ; then
21+
continue
22+
fi
23+
24+
# --- Check for trailing whitespace (spaces or tabs before end of line) ---
25+
# Using POSIX-compatible regex; no -P flag needed.
26+
if grep -nE '[[:space:]]+$' "$file" >/dev/null; then
27+
echo "❌ Trailing whitespace in: $file"
28+
# Print offending lines (indent for readability)
29+
grep -nE '[[:space:]]+$' "$file" | sed 's/^/ /'
30+
fail=1
31+
fi
32+
33+
# --- Check for final newline ---
34+
# tail -c handles both GNU and BSD variants
35+
lastchar=$(tail -c 1 "$file" | od -An -tx1 | tr -d ' \n')
36+
if [[ "$lastchar" != "0a" ]]; then
37+
echo "❌ Missing final newline: $file"
38+
fail=1
39+
fi
40+
41+
done < <(git ls-files)
42+
43+
if [[ $fail -eq 0 ]]; then
44+
echo "✅ All tracked files are clean (no trailing whitespace, final newline present)."
45+
else
46+
echo "⚠️ Some files failed checks."
47+
exit 1
48+
fi

.github/workflows/pull_request.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,3 +54,13 @@ jobs:
5454
license_header_check_project_name: "Swift"
5555
api_breakage_check_enabled: false
5656
format_check_enabled: false
57+
58+
space-format-check:
59+
name: Space format check
60+
runs-on: ubuntu-latest
61+
timeout-minutes: 10
62+
steps:
63+
- name: Checkout repository
64+
uses: actions/checkout@v4
65+
- name: Run space format check
66+
run: cat .github/scripts/format-check.sh | bash

.swift-version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
6.2.0
1+
6.2.0

Plugins/generate-windows-installer-component-groups/generate-windows-installer-component-groups.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ struct GenerateWindowsInstallerComponentGroups: CommandPlugin {
2828
<Component>
2929
<File Source="$(ToolchainRoot)\usr\bin\\#(sourceModule.name).dll" />
3030
</Component>
31-
31+
3232
"""#
3333

3434
let resources = sourceModule.sourceFiles.filter { resource in resource.type == .resource && ["xcspec", "xcbuildrules"].contains(resource.url.pathExtension) }
@@ -41,7 +41,7 @@ struct GenerateWindowsInstallerComponentGroups: CommandPlugin {
4141
<Component>
4242
<File Source="$(ToolchainRoot)\usr\share\pm\SwiftBuild_\#(sourceModule.name).resources\\#(resource.url.lastPathComponent)" />
4343
</Component>
44-
44+
4545
"""#
4646
}
4747
resourcesComponents += " </ComponentGroup>\n"

Sources/SWBAndroidPlatform/AndroidSDK.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,11 +108,11 @@ public import Foundation
108108
init(from decoder: any Decoder, configuration: Version) throws {
109109
struct DynamicCodingKey: CodingKey {
110110
var stringValue: String
111-
111+
112112
init?(stringValue: String) {
113113
self.stringValue = stringValue
114114
}
115-
115+
116116
let intValue: Int? = nil
117117

118118
init?(intValue: Int) {

Sources/SWBApplePlatform/EXUtil.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ final class ExtensionPointExtractorSpec: GenericCommandLineToolSpec, SpecIdentif
4646
let inputs = cbc.inputs.map { input in
4747
return delegate.createNode(input.absolutePath)
4848
}.filter { node in
49-
node.path.fileExtension == "swiftconstvalues"
49+
node.path.fileExtension == "swiftconstvalues"
5050
}
5151
var outputs = [any PlannedNode]()
5252

Sources/SWBApplePlatform/ExtensionPointExtractorTaskProducer.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ final class AppExtensionInfoPlistGeneratorTaskProducer: PhasedTaskProducer, Task
126126
let isApplePlatform = context.isApplePlatform
127127
guard AppExtensionPlistGeneratorSpec.shouldConstructTask(scope: scope, productType: productType, isApplePlatform: isApplePlatform) else {
128128
return []
129-
}
129+
}
130130

131131
let tasks: [any PlannedTask] = []
132132
let buildFilesProcessingContext = BuildFilesProcessingContext(scope)

Sources/SWBBuildService/Messages.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1622,7 +1622,7 @@ package struct ServiceMessageHandlers: ServiceExtension {
16221622
service.registerMessageHandler(ComputeDependencyClosureMsg.self)
16231623
service.registerMessageHandler(ComputeDependencyGraphMsg.self)
16241624
service.registerMessageHandler(DumpBuildDependencyInfoMsg.self)
1625-
1625+
16261626
service.registerMessageHandler(BuildDescriptionConfiguredTargetsMsg.self)
16271627
service.registerMessageHandler(BuildDescriptionSelectConfiguredTargetsForIndexMsg.self)
16281628
service.registerMessageHandler(BuildDescriptionConfiguredTargetSourcesMsg.self)

Sources/SWBBuildSystem/BuildOperation.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -474,7 +474,7 @@ package final class BuildOperation: BuildSystemOperation {
474474
// Create the low-level build system.
475475
let adaptor: OperationSystemAdaptor
476476
let system: BuildSystem
477-
477+
478478
let llbQoS: SWBLLBuild.BuildSystem.QualityOfService?
479479
switch request.qos {
480480
case .default: llbQoS = .default

Sources/SWBCore/CustomTaskTypeDescription.swift

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,48 +13,48 @@
1313
public import SWBUtil
1414

1515
public final class CustomTaskTypeDescription: TaskTypeDescription {
16-
16+
1717
private init() {
1818
}
19-
19+
2020
public static let only: any TaskTypeDescription = CustomTaskTypeDescription()
21-
21+
2222
public var payloadType: (any TaskPayload.Type)? {
2323
nil
2424
}
25-
25+
2626
public var isUnsafeToInterrupt: Bool {
2727
false
2828
}
29-
29+
3030
public var toolBasenameAliases: [String] {
3131
[]
3232
}
33-
33+
3434
public func commandLineForSignature(for task: any ExecutableTask) -> [ByteString]? {
3535
return nil
3636
}
37-
37+
3838
public func serializedDiagnosticsPaths(_ task: any ExecutableTask, _ fs: any FSProxy) -> [Path] {
3939
[]
4040
}
41-
41+
4242
public func generateIndexingInfo(for task: any ExecutableTask, input: TaskGenerateIndexingInfoInput) -> [TaskGenerateIndexingInfoOutput] {
4343
[]
4444
}
45-
45+
4646
public func generatePreviewInfo(for task: any ExecutableTask, input: TaskGeneratePreviewInfoInput, fs: any FSProxy) -> [TaskGeneratePreviewInfoOutput] {
4747
[]
4848
}
49-
49+
5050
public func generateDocumentationInfo(for task: any ExecutableTask, input: TaskGenerateDocumentationInfoInput) -> [TaskGenerateDocumentationInfoOutput] {
5151
[]
5252
}
53-
53+
5454
public func customOutputParserType(for task: any ExecutableTask) -> (any TaskOutputParser.Type)? {
5555
ShellScriptOutputParser.self
5656
}
57-
57+
5858
public func interestingPath(for task: any ExecutableTask) -> Path? {
5959
nil
6060
}

0 commit comments

Comments
 (0)