Skip to content

Commit 19ab5e3

Browse files
committed
Add a swift-format configuration file and format
Add a `swift-format` configuration file and format the repository.
1 parent 84b3e6e commit 19ab5e3

File tree

540 files changed

+31927
-27369
lines changed

Some content is hidden

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

540 files changed

+31927
-27369
lines changed

.swift-format

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"version": 1,
3+
"lineLength": 10000,
4+
"indentation": {
5+
"spaces": 4
6+
},
7+
"lineBreakBeforeEachArgument": true,
8+
"maximumBlankLines" : 1,
9+
"multiElementCollectionTrailingCommas" : true,
10+
"rules": {
11+
},
12+
"tabWidth": 4
13+
}

Benchmarks/Benchmarks/PackageGraphBenchmarks/PackageGraphBenchmarks.swift

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,17 @@
1-
@_spi(DontAdoptOutsideOfSwiftPMExposedForBenchmarksAndTestsOnly)
2-
import Basics
1+
@_spi(DontAdoptOutsideOfSwiftPMExposedForBenchmarksAndTestsOnly) import Basics
32
import Benchmark
43
import Foundation
54
import PackageModel
65

7-
@_spi(DontAdoptOutsideOfSwiftPMExposedForBenchmarksAndTestsOnly)
8-
import func PackageGraph.loadModulesGraph
6+
@_spi(DontAdoptOutsideOfSwiftPMExposedForBenchmarksAndTestsOnly) import func PackageGraph.loadModulesGraph
97

108
import Workspace
119

1210
let benchmarks = {
1311
let defaultMetrics: [BenchmarkMetric]
1412
if let envVar = ProcessInfo.processInfo.environment["SWIFTPM_BENCHMARK_ALL_METRICS"],
15-
envVar.lowercased() == "true" || envVar == "1" {
13+
envVar.lowercased() == "true" || envVar == "1"
14+
{
1615
defaultMetrics = .all
1716
} else {
1817
defaultMetrics = [
@@ -23,23 +22,26 @@ let benchmarks = {
2322

2423
let modulesGraphDepth: Int
2524
if let envVar = ProcessInfo.processInfo.environment["SWIFTPM_BENCHMARK_MODULES_GRAPH_DEPTH"],
26-
let parsedValue = Int(envVar) {
25+
let parsedValue = Int(envVar)
26+
{
2727
modulesGraphDepth = parsedValue
2828
} else {
2929
modulesGraphDepth = 150
3030
}
3131

3232
let modulesGraphWidth: Int
3333
if let envVar = ProcessInfo.processInfo.environment["SWIFTPM_BENCHMARK_MODULES_GRAPH_WIDTH"],
34-
let parsedValue = Int(envVar) {
34+
let parsedValue = Int(envVar)
35+
{
3536
modulesGraphWidth = parsedValue
3637
} else {
3738
modulesGraphWidth = 150
3839
}
3940

4041
let packagesGraphDepth: Int
4142
if let envVar = ProcessInfo.processInfo.environment["SWIFTPM_BENCHMARK_PACKAGES_GRAPH_DEPTH"],
42-
let parsedValue = Int(envVar) {
43+
let parsedValue = Int(envVar)
44+
{
4345
packagesGraphDepth = parsedValue
4446
} else {
4547
packagesGraphDepth = 10
@@ -103,18 +105,18 @@ let benchmarks = {
103105
)
104106
) { benchmark in
105107
try syntheticModulesGraph(
106-
benchmark,
107-
modulesGraphDepth: modulesGraphDepth,
108+
benchmark,
109+
modulesGraphDepth: modulesGraphDepth,
108110
modulesGraphWidth: modulesGraphWidth,
109111
includeMacros: true
110112
)
111113
}
112114
}
113115

114116
func syntheticModulesGraph(
115-
_ benchmark: Benchmark,
116-
modulesGraphDepth: Int,
117-
modulesGraphWidth: Int,
117+
_ benchmark: Benchmark,
118+
modulesGraphDepth: Int,
119+
modulesGraphWidth: Int,
118120
includeMacros: Bool = false
119121
) throws {
120122
// If macros are included, modules are split in three parts:
@@ -137,9 +139,12 @@ func syntheticModulesGraph(
137139
let macrosDependenciesModules: [TargetDescription]
138140
if includeMacros {
139141
macrosModules = try (0..<modulesGraphWidth / macrosDenominator).map { i in
140-
try TargetDescription(name: "Macros\(i)", dependencies: (0..<min(i, modulesGraphDepth)).map {
141-
.target(name: "MacrosDependency\($0)")
142-
})
142+
try TargetDescription(
143+
name: "Macros\(i)",
144+
dependencies: (0..<min(i, modulesGraphDepth)).map {
145+
.target(name: "MacrosDependency\($0)")
146+
}
147+
)
143148
}
144149
macrosDependenciesModules = try (0..<modulesGraphWidth / macrosDenominator).map { i in
145150
try TargetDescription(name: "MacrosDependency\(i)")

Benchmarks/Package.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import PackageDescription
1616
let package = Package(
1717
name: "SwiftPMBenchmarks",
1818
platforms: [
19-
.macOS("14"),
19+
.macOS("14")
2020
],
2121
dependencies: [
2222
.package(path: "../"),
@@ -31,8 +31,8 @@ let package = Package(
3131
],
3232
path: "Benchmarks/PackageGraphBenchmarks",
3333
plugins: [
34-
.plugin(name: "BenchmarkPlugin", package: "package-benchmark"),
34+
.plugin(name: "BenchmarkPlugin", package: "package-benchmark")
3535
]
36-
),
36+
)
3737
]
3838
)

Examples/package-info/Package.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@ let package = Package(
66
name: "package-info",
77
platforms: [
88
.macOS(.v13),
9-
.iOS(.v13)
9+
.iOS(.v13),
1010
],
1111
dependencies: [
1212
// This just points to the SwiftPM at the root of this repository.
13-
.package(name: "swift-package-manager", path: "../../"),
13+
.package(name: "swift-package-manager", path: "../../")
1414
// You will want to depend on a stable semantic version instead:
1515
// .package(url: "https://github.com/swiftlang/swift-package-manager", .exact("0.4.0"))
1616
],
@@ -20,6 +20,6 @@ let package = Package(
2020
dependencies: [
2121
.product(name: "SwiftPM", package: "swift-package-manager")
2222
]
23-
),
23+
)
2424
]
2525
)

0 commit comments

Comments
 (0)