From 0e4e08bfc44c26cadede9cf1fb505d59184162d0 Mon Sep 17 00:00:00 2001 From: yonaskolb Date: Sun, 10 Nov 2019 11:56:23 +1100 Subject: [PATCH] run swift format for Swift 5.1 --- .swiftformat | 2 +- Sources/Core/Glob.swift | 14 +++++----- Sources/Core/MD5.swift | 6 ++--- Sources/Core/PathExtensions.swift | 2 +- Sources/ProjectSpec/AggregateTarget.swift | 8 +++--- Sources/ProjectSpec/BuildScript.swift | 2 +- Sources/ProjectSpec/Dependency.swift | 6 ++--- Sources/ProjectSpec/DeploymentTarget.swift | 4 +-- Sources/ProjectSpec/Plist.swift | 6 ++--- Sources/ProjectSpec/Project.swift | 20 +++++++------- Sources/ProjectSpec/ProjectReference.swift | 2 +- Sources/ProjectSpec/ProjectTarget.swift | 4 +-- Sources/ProjectSpec/Scheme.swift | 16 ++++++------ Sources/ProjectSpec/Settings.swift | 4 +-- Sources/ProjectSpec/SpecFile.swift | 2 +- Sources/ProjectSpec/SpecLoader.swift | 2 +- Sources/ProjectSpec/SpecOptions.swift | 2 +- Sources/ProjectSpec/Target.swift | 8 +++--- Sources/ProjectSpec/TargetReference.swift | 4 +-- Sources/ProjectSpec/TargetSource.swift | 4 +-- Sources/ProjectSpec/Template.swift | 16 ++++++------ Sources/ProjectSpec/Version.swift | 10 +++---- Sources/ProjectSpec/XCProjExtensions.swift | 14 +++++----- Sources/TestSupport/TestHelpers.swift | 6 ++--- Sources/XcodeGenCLI/Arguments.swift | 2 +- .../XcodeGenCLI/Commands/DumpCommand.swift | 3 +-- .../Commands/GenerateCommand.swift | 3 +-- Sources/XcodeGenCLI/GenerationError.swift | 4 +-- .../CarthageDependencyResolver.swift | 4 +-- .../XcodeGenKit/CarthageVersionLoader.swift | 4 +-- Sources/XcodeGenKit/PBXProjGenerator.swift | 12 ++++----- Sources/XcodeGenKit/SchemeGenerator.swift | 4 +-- Sources/XcodeGenKit/SettingsBuilder.swift | 2 +- Sources/XcodeGenKit/SourceGenerator.swift | 8 +++--- Sources/XcodeGenKit/Version.swift | 8 +++--- Sources/XcodeGenKit/XCProjExtensions.swift | 4 +-- Tests/CoreTests/PathExtensionsTests.swift | 2 +- Tests/Fixtures/SPM/SPM/AppDelegate.swift | 2 +- .../TestProject/NestedFiles/Foo/Nested.swift | 2 +- .../StandaloneFiles/Standalone.swift | 2 +- .../StaticLibrary_Swift/StaticLibrary.swift | 2 +- .../CarthageDependencyResolverTests.swift | 2 +- Tests/XcodeGenKitTests/GeneratorHelpers.swift | 4 +-- .../ProjectGeneratorTests.swift | 26 +++++++++---------- .../SourceGeneratorTests.swift | 8 +++--- 45 files changed, 135 insertions(+), 137 deletions(-) diff --git a/.swiftformat b/.swiftformat index a93ce03f..1899668f 100644 --- a/.swiftformat +++ b/.swiftformat @@ -1,6 +1,6 @@ --exclude .build --exclude .swiftpm ---swiftversion 5.0 +--swiftversion 5.1 --disable redundantSelf --disable sortedImports --disable blankLinesAtStartOfScope diff --git a/Sources/Core/Glob.swift b/Sources/Core/Glob.swift index 45453b43..9eccc61d 100644 --- a/Sources/Core/Glob.swift +++ b/Sources/Core/Glob.swift @@ -62,8 +62,8 @@ public class Glob: Collection { public let behavior: Behavior public let blacklistedDirectories: [String] var paths = [String]() - public var startIndex: Int { return paths.startIndex } - public var endIndex: Int { return paths.endIndex } + public var startIndex: Int { paths.startIndex } + public var endIndex: Int { paths.endIndex } /// Initialize a glob /// @@ -109,13 +109,13 @@ public class Glob: Collection { // MARK: Subscript Support public subscript(i: Int) -> String { - return paths[i] + paths[i] } // MARK: Protocol of IndexableBase public func index(after i: Int) -> Int { - return i + 1 + i + 1 } // MARK: Private @@ -123,7 +123,7 @@ public class Glob: Collection { private var globalFlags = GLOB_TILDE | GLOB_BRACE | GLOB_MARK private func executeGlob(pattern: UnsafePointer, gt: UnsafeMutablePointer) -> Bool { - return glob(pattern, globalFlags, nil, gt) == 0 + glob(pattern, globalFlags, nil, gt) == 0 } private func expandGlobstar(pattern: String) -> [String] { @@ -171,7 +171,7 @@ public class Glob: Collection { } private func exploreDirectories(path: String) throws -> [String] { - return try FileManager.default.contentsOfDirectory(atPath: path) + try FileManager.default.contentsOfDirectory(atPath: path) .compactMap { subpath -> [String]? in if blacklistedDirectories.contains(subpath) { return nil @@ -228,6 +228,6 @@ public class Glob: Collection { private extension Sequence { func array() -> [Element] { - return Array(self) + Array(self) } } diff --git a/Sources/Core/MD5.swift b/Sources/Core/MD5.swift index 49ad10a1..bffb6d37 100644 --- a/Sources/Core/MD5.swift +++ b/Sources/Core/MD5.swift @@ -68,7 +68,7 @@ func arrayOfBytes(_ value: T, length: Int? = nil) -> [UInt8] { extension Int { /** Array of bytes with optional padding (little-endian) */ func bytes(_ totalBytes: Int = MemoryLayout.size) -> [UInt8] { - return arrayOfBytes(self, length: totalBytes) + arrayOfBytes(self, length: totalBytes) } } @@ -147,12 +147,12 @@ struct BytesSequence: Sequence { let data: [UInt8] func makeIterator() -> BytesIterator { - return BytesIterator(chunkSize: chunkSize, data: data) + BytesIterator(chunkSize: chunkSize, data: data) } } func rotateLeft(_ value: UInt32, bits: UInt32) -> UInt32 { - return ((value << bits) & 0xFFFF_FFFF) | (value >> (32 - bits)) + ((value << bits) & 0xFFFF_FFFF) | (value >> (32 - bits)) } class MD5: HashProtocol { diff --git a/Sources/Core/PathExtensions.swift b/Sources/Core/PathExtensions.swift index 0e0546ce..0d996dd8 100644 --- a/Sources/Core/PathExtensions.swift +++ b/Sources/Core/PathExtensions.swift @@ -11,7 +11,7 @@ extension Path { /// - `../a/b` simplifies to `../a/b` /// - `a/../../c` simplifies to `../c` public func simplifyingParentDirectoryReferences() -> Path { - return normalize().components.reduce(Path(), +) + normalize().components.reduce(Path(), +) } /// Returns the relative path necessary to go from `base` to `self`. diff --git a/Sources/ProjectSpec/AggregateTarget.swift b/Sources/ProjectSpec/AggregateTarget.swift index 20f67dc7..b2964e5b 100644 --- a/Sources/ProjectSpec/AggregateTarget.swift +++ b/Sources/ProjectSpec/AggregateTarget.swift @@ -32,14 +32,14 @@ public struct AggregateTarget: ProjectTarget { extension AggregateTarget: CustomStringConvertible { public var description: String { - return "\(name)\(targets.isEmpty ? "" : ": \(targets.joined(separator: ", "))")" + "\(name)\(targets.isEmpty ? "" : ": \(targets.joined(separator: ", "))")" } } extension AggregateTarget: Equatable { public static func == (lhs: AggregateTarget, rhs: AggregateTarget) -> Bool { - return lhs.name == rhs.name && + lhs.name == rhs.name && lhs.targets == rhs.targets && lhs.settings == rhs.settings && lhs.configFiles == rhs.configFiles && @@ -64,7 +64,7 @@ extension AggregateTarget: NamedJSONDictionaryConvertible { extension AggregateTarget: JSONEncodable { public func toJSONValue() -> Any { - return [ + [ "settings": settings.toJSONValue(), "targets": targets, "configFiles": configFiles, @@ -78,7 +78,7 @@ extension AggregateTarget: JSONEncodable { extension AggregateTarget: PathContainer { static var pathProperties: [PathProperty] { - return [ + [ .dictionary([ .string("configFiles"), .object("buildScripts", BuildScript.pathProperties), diff --git a/Sources/ProjectSpec/BuildScript.swift b/Sources/ProjectSpec/BuildScript.swift index 7494ed52..9c280e1d 100644 --- a/Sources/ProjectSpec/BuildScript.swift +++ b/Sources/ProjectSpec/BuildScript.swift @@ -94,7 +94,7 @@ extension BuildScript: JSONEncodable { extension BuildScript: PathContainer { static var pathProperties: [PathProperty] { - return [ + [ .string("path"), ] } diff --git a/Sources/ProjectSpec/Dependency.swift b/Sources/ProjectSpec/Dependency.swift index 9958eb2e..ebd0084d 100644 --- a/Sources/ProjectSpec/Dependency.swift +++ b/Sources/ProjectSpec/Dependency.swift @@ -32,11 +32,11 @@ public struct Dependency: Equatable { self.implicit = implicit self.weakLink = weakLink } - + public enum CarthageLinkType: String { case dynamic case `static` - + public static let `default` = dynamic } @@ -139,7 +139,7 @@ extension Dependency: JSONEncodable { extension Dependency: PathContainer { static var pathProperties: [PathProperty] { - return [ + [ .string("framework"), ] } diff --git a/Sources/ProjectSpec/DeploymentTarget.swift b/Sources/ProjectSpec/DeploymentTarget.swift index 7cba891a..f75fdd0b 100644 --- a/Sources/ProjectSpec/DeploymentTarget.swift +++ b/Sources/ProjectSpec/DeploymentTarget.swift @@ -55,7 +55,7 @@ extension Version { /// doesn't print patch if 0 public var deploymentTarget: String { - return "\(major).\(minor)\(patch > 0 ? ".\(patch)" : "")" + "\(major).\(minor)\(patch > 0 ? ".\(patch)" : "")" } } @@ -81,7 +81,7 @@ extension DeploymentTarget: JSONObjectConvertible { extension DeploymentTarget: JSONEncodable { public func toJSONValue() -> Any { - return [ + [ "iOS": iOS?.string, "tvOS": tvOS?.string, "watchOS": watchOS?.string, diff --git a/Sources/ProjectSpec/Plist.swift b/Sources/ProjectSpec/Plist.swift index 8014c7bc..d478fd01 100644 --- a/Sources/ProjectSpec/Plist.swift +++ b/Sources/ProjectSpec/Plist.swift @@ -12,7 +12,7 @@ public struct Plist: Equatable { } public static func == (lhs: Plist, rhs: Plist) -> Bool { - return lhs.path == rhs.path && + lhs.path == rhs.path && NSDictionary(dictionary: lhs.properties).isEqual(to: rhs.properties) } } @@ -27,7 +27,7 @@ extension Plist: JSONObjectConvertible { extension Plist: JSONEncodable { public func toJSONValue() -> Any { - return [ + [ "path": path, "properties": properties, ] @@ -37,7 +37,7 @@ extension Plist: JSONEncodable { extension Plist: PathContainer { static var pathProperties: [PathProperty] { - return [ + [ .string("path"), ] } diff --git a/Sources/ProjectSpec/Project.swift b/Sources/ProjectSpec/Project.swift index 1a4d16a3..db33c267 100644 --- a/Sources/ProjectSpec/Project.swift +++ b/Sources/ProjectSpec/Project.swift @@ -79,27 +79,27 @@ public struct Project: BuildSettingsContainer { } public func getProjectReference(_ projectName: String) -> ProjectReference? { - return projectReferencesMap[projectName] + projectReferencesMap[projectName] } public func getTarget(_ targetName: String) -> Target? { - return targetsMap[targetName] + targetsMap[targetName] } public func getAggregateTarget(_ targetName: String) -> AggregateTarget? { - return aggregateTargetsMap[targetName] + aggregateTargetsMap[targetName] } public func getProjectTarget(_ targetName: String) -> ProjectTarget? { - return targetsMap[targetName] ?? aggregateTargetsMap[targetName] + targetsMap[targetName] ?? aggregateTargetsMap[targetName] } public func getConfig(_ configName: String) -> Config? { - return configs.first { $0.name == configName } + configs.first { $0.name == configName } } public var defaultProjectPath: Path { - return basePath + "\(name).xcodeproj" + basePath + "\(name).xcodeproj" } } @@ -136,7 +136,7 @@ extension Project: CustomDebugStringConvertible { extension Project: Equatable { public static func == (lhs: Project, rhs: Project) -> Bool { - return lhs.name == rhs.name && + lhs.name == rhs.name && lhs.targets == rhs.targets && lhs.aggregateTargets == rhs.aggregateTargets && lhs.settings == rhs.settings && @@ -216,7 +216,7 @@ extension Project { extension Project: PathContainer { static var pathProperties: [PathProperty] { - return [ + [ .string("configFiles"), .string("localPackages"), .object("options", SpecOptions.pathProperties), @@ -259,13 +259,13 @@ extension Project { extension BuildSettingsContainer { fileprivate var configFilePaths: [Path] { - return configFiles.values.map { Path($0) } + configFiles.values.map { Path($0) } } } extension Project: JSONEncodable { public func toJSONValue() -> Any { - return toJSONDictionary() + toJSONDictionary() } public func toJSONDictionary() -> JSONDictionary { diff --git a/Sources/ProjectSpec/ProjectReference.swift b/Sources/ProjectSpec/ProjectReference.swift index 3781e4d0..b0cb84a3 100644 --- a/Sources/ProjectSpec/ProjectReference.swift +++ b/Sources/ProjectSpec/ProjectReference.swift @@ -20,7 +20,7 @@ extension ProjectReference: NamedJSONDictionaryConvertible { extension ProjectReference: JSONEncodable { public func toJSONValue() -> Any { - return [ + [ "path": path, ] } diff --git a/Sources/ProjectSpec/ProjectTarget.swift b/Sources/ProjectSpec/ProjectTarget.swift index b45ea801..0411b0eb 100644 --- a/Sources/ProjectSpec/ProjectTarget.swift +++ b/Sources/ProjectSpec/ProjectTarget.swift @@ -11,13 +11,13 @@ public protocol ProjectTarget: BuildSettingsContainer { extension Target { public var buildScripts: [BuildScript] { - return preBuildScripts + postCompileScripts + postBuildScripts + preBuildScripts + postCompileScripts + postBuildScripts } } extension Project { public var projectTargets: [ProjectTarget] { - return targets.map { $0 as ProjectTarget } + aggregateTargets.map { $0 as ProjectTarget } + targets.map { $0 as ProjectTarget } + aggregateTargets.map { $0 as ProjectTarget } } } diff --git a/Sources/ProjectSpec/Scheme.swift b/Sources/ProjectSpec/Scheme.swift index 5f4ef025..3aaa7187 100644 --- a/Sources/ProjectSpec/Scheme.swift +++ b/Sources/ProjectSpec/Scheme.swift @@ -126,7 +126,7 @@ public struct Scheme: Equatable { public static let randomExecutionOrderDefault = false public static let parallelizableDefault = false - public var name: String { return targetReference.name } + public var name: String { targetReference.name } public let targetReference: TargetReference public var randomExecutionOrder: Bool public var parallelizable: Bool @@ -187,7 +187,7 @@ public struct Scheme: Equatable { } public var shouldUseLaunchSchemeArgsEnv: Bool { - return commandLineArguments.isEmpty && environmentVariables.isEmpty + commandLineArguments.isEmpty && environmentVariables.isEmpty } } @@ -219,7 +219,7 @@ public struct Scheme: Equatable { } public var shouldUseLaunchSchemeArgsEnv: Bool { - return commandLineArguments.isEmpty && environmentVariables.isEmpty + commandLineArguments.isEmpty && environmentVariables.isEmpty } } @@ -272,7 +272,7 @@ extension Scheme.ExecutionAction: JSONObjectConvertible { extension Scheme.ExecutionAction: JSONEncodable { public func toJSONValue() -> Any { - return [ + [ "script": script, "name": name, "settingsTarget": settingsTarget, @@ -423,7 +423,7 @@ extension Scheme.Profile: JSONObjectConvertible { extension Scheme.Profile: JSONEncodable { public func toJSONValue() -> Any { - return [ + [ "commandLineArguments": commandLineArguments, "preActions": preActions.map { $0.toJSONValue() }, "postActions": postActions.map { $0.toJSONValue() }, @@ -442,7 +442,7 @@ extension Scheme.Analyze: JSONObjectConvertible { extension Scheme.Analyze: JSONEncodable { public func toJSONValue() -> Any { - return [ + [ "config": config, ] } @@ -491,7 +491,7 @@ extension Scheme: NamedJSONDictionaryConvertible { extension Scheme: JSONEncodable { public func toJSONValue() -> Any { - return [ + [ "build": build.toJSONValue(), "run": run?.toJSONValue(), "test": test?.toJSONValue(), @@ -572,7 +572,7 @@ extension BuildType: JSONPrimitiveConvertible { } public static var all: [BuildType] { - return [.running, .testing, .profiling, .analyzing, .archiving] + [.running, .testing, .profiling, .analyzing, .archiving] } } diff --git a/Sources/ProjectSpec/Settings.swift b/Sources/ProjectSpec/Settings.swift index 52e0bed5..6ac0328c 100644 --- a/Sources/ProjectSpec/Settings.swift +++ b/Sources/ProjectSpec/Settings.swift @@ -37,7 +37,7 @@ public struct Settings: Equatable, JSONObjectConvertible, CustomStringConvertibl } public static func == (lhs: Settings, rhs: Settings) -> Bool { - return NSDictionary(dictionary: lhs.buildSettings).isEqual(to: rhs.buildSettings) && + NSDictionary(dictionary: lhs.buildSettings).isEqual(to: rhs.buildSettings) && lhs.configSettings == rhs.configSettings && lhs.groups == rhs.groups } @@ -97,7 +97,7 @@ extension Dictionary where Key == String, Value: Any { } public func equals(_ dictionary: BuildSettings) -> Bool { - return NSDictionary(dictionary: self).isEqual(to: dictionary) + NSDictionary(dictionary: self).isEqual(to: dictionary) } } diff --git a/Sources/ProjectSpec/SpecFile.swift b/Sources/ProjectSpec/SpecFile.swift index f5a87777..fec8af98 100644 --- a/Sources/ProjectSpec/SpecFile.swift +++ b/Sources/ProjectSpec/SpecFile.swift @@ -86,7 +86,7 @@ public struct SpecFile { } public func resolvedDictionary(variables: [String: String] = [:]) -> JSONDictionary { - return resolvedDictionaryWithUniqueTargets().expand(variables: variables) + resolvedDictionaryWithUniqueTargets().expand(variables: variables) } private func resolvedDictionaryWithUniqueTargets() -> JSONDictionary { diff --git a/Sources/ProjectSpec/SpecLoader.swift b/Sources/ProjectSpec/SpecLoader.swift index 54c4cf53..b4fc4675 100644 --- a/Sources/ProjectSpec/SpecLoader.swift +++ b/Sources/ProjectSpec/SpecLoader.swift @@ -53,7 +53,7 @@ private extension Dictionary where Key == String, Value: Any { } func hasValueContaining(_ needle: String) -> Bool { - return values.contains { value in + values.contains { value in switch value { case let dictionary as JSONDictionary: return dictionary.hasValueContaining(needle) diff --git a/Sources/ProjectSpec/SpecOptions.swift b/Sources/ProjectSpec/SpecOptions.swift index 1b2081b9..24d124ec 100644 --- a/Sources/ProjectSpec/SpecOptions.swift +++ b/Sources/ProjectSpec/SpecOptions.swift @@ -176,7 +176,7 @@ extension SpecOptions: JSONEncodable { extension SpecOptions: PathContainer { static var pathProperties: [PathProperty] { - return [ + [ .string("carthageBuildPath"), ] } diff --git a/Sources/ProjectSpec/Target.swift b/Sources/ProjectSpec/Target.swift index c49254d6..e28e33c3 100644 --- a/Sources/ProjectSpec/Target.swift +++ b/Sources/ProjectSpec/Target.swift @@ -47,7 +47,7 @@ public struct Target: ProjectTarget { public var productName: String public var isLegacy: Bool { - return legacy != nil + legacy != nil } public var filename: String { @@ -108,14 +108,14 @@ public struct Target: ProjectTarget { extension Target: CustomStringConvertible { public var description: String { - return "\(name): \(platform.rawValue) \(type)" + "\(name): \(platform.rawValue) \(type)" } } extension Target: PathContainer { static var pathProperties: [PathProperty] { - return [ + [ .dictionary([ .string("sources"), .object("sources", TargetSource.pathProperties), @@ -188,7 +188,7 @@ extension Target { extension Target: Equatable { public static func == (lhs: Target, rhs: Target) -> Bool { - return lhs.name == rhs.name && + lhs.name == rhs.name && lhs.type == rhs.type && lhs.platform == rhs.platform && lhs.deploymentTarget == rhs.deploymentTarget && diff --git a/Sources/ProjectSpec/TargetReference.swift b/Sources/ProjectSpec/TargetReference.swift index f7de4b7e..1a64e258 100644 --- a/Sources/ProjectSpec/TargetReference.swift +++ b/Sources/ProjectSpec/TargetReference.swift @@ -32,7 +32,7 @@ extension TargetReference { } public static func local(_ name: String) -> TargetReference { - return TargetReference(name: name, location: .local) + TargetReference(name: name, location: .local) } } @@ -52,6 +52,6 @@ extension TargetReference: CustomStringConvertible { } public var description: String { - return reference + reference } } diff --git a/Sources/ProjectSpec/TargetSource.swift b/Sources/ProjectSpec/TargetSource.swift index ce9d9795..60d3f669 100644 --- a/Sources/ProjectSpec/TargetSource.swift +++ b/Sources/ProjectSpec/TargetSource.swift @@ -267,7 +267,7 @@ extension TargetSource.BuildPhase.CopyFilesSettings: JSONObjectConvertible { extension TargetSource.BuildPhase.CopyFilesSettings: JSONEncodable { public func toJSONValue() -> Any { - return [ + [ "destination": destination.rawValue, "subpath": subpath, ] @@ -277,7 +277,7 @@ extension TargetSource.BuildPhase.CopyFilesSettings: JSONEncodable { extension TargetSource: PathContainer { static var pathProperties: [PathProperty] { - return [ + [ .string("path"), ] } diff --git a/Sources/ProjectSpec/Template.swift b/Sources/ProjectSpec/Template.swift index 91956356..71f16b1f 100644 --- a/Sources/ProjectSpec/Template.swift +++ b/Sources/ProjectSpec/Template.swift @@ -9,19 +9,19 @@ struct TemplateStructure { extension Target { static func resolveTargetTemplates(jsonDictionary: JSONDictionary) -> JSONDictionary { - return resolveTemplates(jsonDictionary: jsonDictionary, - templateStructure: TemplateStructure(baseKey: "targets", - templatesKey: "targetTemplates", - nameToReplace: "target_name")) + resolveTemplates(jsonDictionary: jsonDictionary, + templateStructure: TemplateStructure(baseKey: "targets", + templatesKey: "targetTemplates", + nameToReplace: "target_name")) } } extension Scheme { static func resolveSchemeTemplates(jsonDictionary: JSONDictionary) -> JSONDictionary { - return resolveTemplates(jsonDictionary: jsonDictionary, - templateStructure: TemplateStructure(baseKey: "schemes", - templatesKey: "schemeTemplates", - nameToReplace: "scheme_name")) + resolveTemplates(jsonDictionary: jsonDictionary, + templateStructure: TemplateStructure(baseKey: "schemes", + templatesKey: "schemeTemplates", + nameToReplace: "scheme_name")) } } diff --git a/Sources/ProjectSpec/Version.swift b/Sources/ProjectSpec/Version.swift index 3d56f2b4..cfd2914c 100644 --- a/Sources/ProjectSpec/Version.swift +++ b/Sources/ProjectSpec/Version.swift @@ -38,23 +38,23 @@ public struct Version: CustomStringConvertible, Equatable, Comparable, Expressib } public var string: String { - return "\(major).\(minor).\(patch)" + "\(major).\(minor).\(patch)" } public var description: String { - return string + string } public func bumpingMajor() -> Version { - return Version(major: major + 1, minor: 0, patch: 0) + Version(major: major + 1, minor: 0, patch: 0) } public func bumpingMinor() -> Version { - return Version(major: major, minor: minor + 1, patch: 0) + Version(major: major, minor: minor + 1, patch: 0) } public func bumpingPatch() -> Version { - return Version(major: major, minor: minor, patch: patch + 1) + Version(major: major, minor: minor, patch: patch + 1) } public static func < (lhs: Version, rhs: Version) -> Bool { diff --git a/Sources/ProjectSpec/XCProjExtensions.swift b/Sources/ProjectSpec/XCProjExtensions.swift index 94a876e1..7d90a723 100644 --- a/Sources/ProjectSpec/XCProjExtensions.swift +++ b/Sources/ProjectSpec/XCProjExtensions.swift @@ -15,31 +15,31 @@ extension PBXProductType { } public var isFramework: Bool { - return self == .framework || self == .staticFramework + self == .framework || self == .staticFramework } public var isLibrary: Bool { - return self == .staticLibrary || self == .dynamicLibrary + self == .staticLibrary || self == .dynamicLibrary } public var isExtension: Bool { - return fileExtension == "appex" + fileExtension == "appex" } public var isApp: Bool { - return fileExtension == "app" + fileExtension == "app" } public var isTest: Bool { - return fileExtension == "xctest" + fileExtension == "xctest" } public var isExecutable: Bool { - return isApp || isExtension || isTest || self == .commandLineTool + isApp || isExtension || isTest || self == .commandLineTool } public var name: String { - return rawValue.replacingOccurrences(of: "com.apple.product-type.", with: "") + rawValue.replacingOccurrences(of: "com.apple.product-type.", with: "") } } diff --git a/Sources/TestSupport/TestHelpers.swift b/Sources/TestSupport/TestHelpers.swift index 88f2c9d4..bb3bf7bc 100644 --- a/Sources/TestSupport/TestHelpers.swift +++ b/Sources/TestSupport/TestHelpers.swift @@ -50,7 +50,7 @@ open class ArrayExpectation: ExpectationType { let function: String open var to: ArrayExpectation { - return self + self } init(file: String, line: Int, function: String, expression: @escaping () throws -> ValueType?) { @@ -61,12 +61,12 @@ open class ArrayExpectation: ExpectationType { } open func failure(_ reason: String) -> FailureType { - return ExpectationFailure(reason: reason, file: file, line: line, function: function) + ExpectationFailure(reason: reason, file: file, line: line, function: function) } } public func expect(_ expression: @autoclosure @escaping () throws -> [T]?, file: String = #file, line: Int = #line, function: String = #function) -> ArrayExpectation { - return ArrayExpectation(file: file, line: line, function: function, expression: expression) + ArrayExpectation(file: file, line: line, function: function, expression: expression) } extension ArrayExpectation { diff --git a/Sources/XcodeGenCLI/Arguments.swift b/Sources/XcodeGenCLI/Arguments.swift index dc995b04..29b90853 100644 --- a/Sources/XcodeGenCLI/Arguments.swift +++ b/Sources/XcodeGenCLI/Arguments.swift @@ -5,6 +5,6 @@ import SwiftCLI extension Path: ConvertibleFromString { public static func convert(from: String) -> Path? { - return Path(from) + Path(from) } } diff --git a/Sources/XcodeGenCLI/Commands/DumpCommand.swift b/Sources/XcodeGenCLI/Commands/DumpCommand.swift index 0cc075c4..e6a78d3f 100644 --- a/Sources/XcodeGenCLI/Commands/DumpCommand.swift +++ b/Sources/XcodeGenCLI/Commands/DumpCommand.swift @@ -23,8 +23,7 @@ class DumpCommand: ProjectCommand { init(version: Version) { super.init(version: version, name: "dump", - shortDescription: "Dumps the resolved project spec to stdout or a file" - ) + shortDescription: "Dumps the resolved project spec to stdout or a file") } override func execute(specLoader: SpecLoader, projectSpecPath: Path, project: Project) throws { diff --git a/Sources/XcodeGenCLI/Commands/GenerateCommand.swift b/Sources/XcodeGenCLI/Commands/GenerateCommand.swift index e3e6a690..251368e9 100644 --- a/Sources/XcodeGenCLI/Commands/GenerateCommand.swift +++ b/Sources/XcodeGenCLI/Commands/GenerateCommand.swift @@ -35,8 +35,7 @@ class GenerateCommand: ProjectCommand { init(version: Version) { super.init(version: version, name: "generate", - shortDescription: "Generate an Xcode project from a spec" - ) + shortDescription: "Generate an Xcode project from a spec") } override func execute(specLoader: SpecLoader, projectSpecPath: Path, project: Project) throws { diff --git a/Sources/XcodeGenCLI/GenerationError.swift b/Sources/XcodeGenCLI/GenerationError.swift index d3949ce5..985246bd 100644 --- a/Sources/XcodeGenCLI/GenerationError.swift +++ b/Sources/XcodeGenCLI/GenerationError.swift @@ -30,10 +30,10 @@ enum GenerationError: Error, CustomStringConvertible, ProcessError { } var message: String? { - return description.red + description.red } var exitStatus: Int32 { - return 1 + 1 } } diff --git a/Sources/XcodeGenKit/CarthageDependencyResolver.swift b/Sources/XcodeGenKit/CarthageDependencyResolver.swift index 686ff32b..e5d00cf4 100644 --- a/Sources/XcodeGenKit/CarthageDependencyResolver.swift +++ b/Sources/XcodeGenKit/CarthageDependencyResolver.swift @@ -14,13 +14,13 @@ public class CarthageDependencyResolver { /// Carthage's base build path as specified by the /// project's `SpecOptions`, or `Carthage/Build` by default var buildPath: String { - return project.options.carthageBuildPath ?? "Carthage/Build" + project.options.carthageBuildPath ?? "Carthage/Build" } /// Carthage's executable path as specified by the /// project's `SpecOptions`, or `carthage` by default var executable: String { - return project.options.carthageExecutablePath ?? "carthage" + project.options.carthageExecutablePath ?? "carthage" } private let project: Project diff --git a/Sources/XcodeGenKit/CarthageVersionLoader.swift b/Sources/XcodeGenKit/CarthageVersionLoader.swift index 73a34b27..644415c0 100644 --- a/Sources/XcodeGenKit/CarthageVersionLoader.swift +++ b/Sources/XcodeGenKit/CarthageVersionLoader.swift @@ -52,12 +52,12 @@ struct CarthageVersionFile: Decodable { extension Platform: CodingKey { public var stringValue: String { - return carthageName + carthageName } } extension CarthageVersionFile { func frameworks(for platform: Platform) -> [String] { - return data[platform] ?? [] + data[platform] ?? [] } } diff --git a/Sources/XcodeGenKit/PBXProjGenerator.swift b/Sources/XcodeGenKit/PBXProjGenerator.swift index cd54dc4f..212ee2ff 100644 --- a/Sources/XcodeGenKit/PBXProjGenerator.swift +++ b/Sources/XcodeGenKit/PBXProjGenerator.swift @@ -615,7 +615,7 @@ public class PBXProjGenerator { let fileReference = self.sourceGenerator.getFileReference(path: frameworkPath, inPath: platformPath) self.carthageFrameworksByPlatform[target.platform.carthageName, default: []].insert(fileReference) - + if dependency.link ?? (target.type != .staticLibrary) { let buildFile = self.addObject( PBXBuildFile(file: fileReference, settings: getDependencyFrameworkSettings(dependency: dependency)) @@ -651,7 +651,7 @@ public class PBXProjGenerator { } for dependency in carthageDependencies { - + let embed = dependency.embed ?? target.shouldEmbedCarthageDependencies var platformPath = Path(carthageResolver.buildPath(for: target.platform, linkType: dependency.carthageLinkType ?? .default)) @@ -681,7 +681,7 @@ public class PBXProjGenerator { var buildPhases: [PBXBuildPhase] = [] func getBuildFilesForSourceFiles(_ sourceFiles: [SourceFile]) -> [PBXBuildFile] { - return sourceFiles + sourceFiles .reduce(into: [SourceFile]()) { output, sourceFile in if !output.contains(where: { $0.fileReference === sourceFile.fileReference }) { output.append(sourceFile) @@ -993,7 +993,7 @@ public class PBXProjGenerator { } func getInfoPlist(_ sources: [TargetSource]) -> Path? { - return sources + sources .lazy .map { self.project.basePath + $0.path } .compactMap { (path) -> Path? in @@ -1060,11 +1060,11 @@ public class PBXProjGenerator { extension Target { var shouldEmbedDependencies: Bool { - return type.isApp || type.isTest + type.isApp || type.isTest } var shouldEmbedCarthageDependencies: Bool { - return (type.isApp && platform != .watchOS) + (type.isApp && platform != .watchOS) || type == .watch2Extension || type.isTest } diff --git a/Sources/XcodeGenKit/SchemeGenerator.swift b/Sources/XcodeGenKit/SchemeGenerator.swift index 8891d245..d98754ac 100644 --- a/Sources/XcodeGenKit/SchemeGenerator.swift +++ b/Sources/XcodeGenKit/SchemeGenerator.swift @@ -16,11 +16,11 @@ public class SchemeGenerator { let pbxProj: PBXProj var defaultDebugConfig: Config { - return project.configs.first { $0.type == .debug }! + project.configs.first { $0.type == .debug }! } var defaultReleaseConfig: Config { - return project.configs.first { $0.type == .release }! + project.configs.first { $0.type == .release }! } public init(project: Project, pbxProj: PBXProj) { diff --git a/Sources/XcodeGenKit/SettingsBuilder.swift b/Sources/XcodeGenKit/SettingsBuilder.swift index 8d21f9e8..6a5b07bb 100644 --- a/Sources/XcodeGenKit/SettingsBuilder.swift +++ b/Sources/XcodeGenKit/SettingsBuilder.swift @@ -115,7 +115,7 @@ extension Project { } public func targetHasBuildSetting(_ setting: String, target: Target, config: Config) -> Bool { - return getCombinedBuildSetting(setting, target: target, config: config) != nil + getCombinedBuildSetting(setting, target: target, config: config) != nil } /// Removes values from build settings if they are defined in an xcconfig file diff --git a/Sources/XcodeGenKit/SourceGenerator.swift b/Sources/XcodeGenKit/SourceGenerator.swift index 0b6e96c9..a041fd42 100644 --- a/Sources/XcodeGenKit/SourceGenerator.swift +++ b/Sources/XcodeGenKit/SourceGenerator.swift @@ -72,7 +72,7 @@ class SourceGenerator { } func getAllSourceFiles(targetType: PBXProductType, sources: [TargetSource]) throws -> [SourceFile] { - return try sources.flatMap { try getSourceFiles(targetType: targetType, targetSource: $0, path: project.basePath + $0.path) } + try sources.flatMap { try getSourceFiles(targetType: targetType, targetSource: $0, path: project.basePath + $0.path) } } // get groups without build files. Use for Project.fileGroups @@ -354,7 +354,7 @@ class SourceGenerator { /// Checks whether the path is not in any default or TargetSource excludes func isIncludedPath(_ path: Path, excludePaths: Set, includePaths: Set) -> Bool { - return !defaultExcludedFiles.contains(where: { path.lastComponent.contains($0) }) + !defaultExcludedFiles.contains(where: { path.lastComponent.contains($0) }) && !(path.extension.map(defaultExcludedExtensions.contains) ?? false) && !excludePaths.contains(path) // If includes is empty, it's included. If it's not empty, the path either needs to match exactly, or it needs to be a direct parent of an included path. @@ -366,7 +366,7 @@ class SourceGenerator { /// Gets all the children paths that aren't excluded private func getSourceChildren(targetSource: TargetSource, dirPath: Path, excludePaths: Set, includePaths: Set) throws -> [Path] { - return try dirPath.children() + try dirPath.children() .filter { if $0.isDirectory { let children = try $0.children() @@ -432,7 +432,7 @@ class SourceGenerator { // find the base localised directory let baseLocalisedDirectory: Path? = { func findLocalisedDirectory(by languageId: String) -> Path? { - return localisedDirectories.first { $0.lastComponent == "\(languageId).lproj" } + localisedDirectories.first { $0.lastComponent == "\(languageId).lproj" } } return findLocalisedDirectory(by: "Base") ?? findLocalisedDirectory(by: NSLocale.canonicalLanguageIdentifier(from: project.options.developmentLanguage ?? "en")) diff --git a/Sources/XcodeGenKit/Version.swift b/Sources/XcodeGenKit/Version.swift index a7871c0c..ca0e6a39 100644 --- a/Sources/XcodeGenKit/Version.swift +++ b/Sources/XcodeGenKit/Version.swift @@ -4,19 +4,19 @@ import ProjectSpec extension Project { var xcodeVersion: String { - return XCodeVersion.parse(options.xcodeVersion ?? "10.2") + XCodeVersion.parse(options.xcodeVersion ?? "10.2") } var schemeVersion: String { - return "1.3" + "1.3" } var compatibilityVersion: String { - return "Xcode 10.0" + "Xcode 10.0" } var objectVersion: UInt { - return 51 + 51 } } diff --git a/Sources/XcodeGenKit/XCProjExtensions.swift b/Sources/XcodeGenKit/XCProjExtensions.swift index d056f249..8c2ac6ce 100644 --- a/Sources/XcodeGenKit/XCProjExtensions.swift +++ b/Sources/XcodeGenKit/XCProjExtensions.swift @@ -5,7 +5,7 @@ import XcodeProj extension PBXFileElement { public var nameOrPath: String { - return name ?? path ?? "" + name ?? path ?? "" } } @@ -39,7 +39,7 @@ extension PBXProj { extension Dictionary { public var valueArray: [Value] { - return Array(values) + Array(values) } } diff --git a/Tests/CoreTests/PathExtensionsTests.swift b/Tests/CoreTests/PathExtensionsTests.swift index ddbd17d2..83d2da39 100644 --- a/Tests/CoreTests/PathExtensionsTests.swift +++ b/Tests/CoreTests/PathExtensionsTests.swift @@ -8,7 +8,7 @@ class PathExtensionsTests: XCTestCase { func testPathRelativeToPath() { func relativePath(to path: String, from base: String) throws -> String { - return try Path(path).relativePath(from: Path(base)).string + try Path(path).relativePath(from: Path(base)).string } // These are based on ruby's tests for Pathname#relative_path_from: diff --git a/Tests/Fixtures/SPM/SPM/AppDelegate.swift b/Tests/Fixtures/SPM/SPM/AppDelegate.swift index 56fe2e7e..e5ea3598 100644 --- a/Tests/Fixtures/SPM/SPM/AppDelegate.swift +++ b/Tests/Fixtures/SPM/SPM/AppDelegate.swift @@ -14,7 +14,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate { func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { // Override point for customization after application launch. - return true + true } } diff --git a/Tests/Fixtures/TestProject/NestedFiles/Foo/Nested.swift b/Tests/Fixtures/TestProject/NestedFiles/Foo/Nested.swift index 70552f80..75c4994c 100644 --- a/Tests/Fixtures/TestProject/NestedFiles/Foo/Nested.swift +++ b/Tests/Fixtures/TestProject/NestedFiles/Foo/Nested.swift @@ -1,3 +1,3 @@ func nested() -> String { - return "Nested" + "Nested" } diff --git a/Tests/Fixtures/TestProject/StandaloneFiles/Standalone.swift b/Tests/Fixtures/TestProject/StandaloneFiles/Standalone.swift index 6a9da937..0631e70f 100644 --- a/Tests/Fixtures/TestProject/StandaloneFiles/Standalone.swift +++ b/Tests/Fixtures/TestProject/StandaloneFiles/Standalone.swift @@ -1,3 +1,3 @@ func standaloneHello() -> String { - return "Hello" + "Hello" } diff --git a/Tests/Fixtures/TestProject/StaticLibrary_Swift/StaticLibrary.swift b/Tests/Fixtures/TestProject/StaticLibrary_Swift/StaticLibrary.swift index b1c0199c..d4836f7b 100644 --- a/Tests/Fixtures/TestProject/StaticLibrary_Swift/StaticLibrary.swift +++ b/Tests/Fixtures/TestProject/StaticLibrary_Swift/StaticLibrary.swift @@ -1,6 +1,6 @@ public struct SLSwift { public func description() -> String { - return "Hello, World!" + "Hello, World!" } } diff --git a/Tests/XcodeGenKitTests/CarthageDependencyResolverTests.swift b/Tests/XcodeGenKitTests/CarthageDependencyResolverTests.swift index 3ac09893..32f376d2 100644 --- a/Tests/XcodeGenKitTests/CarthageDependencyResolverTests.swift +++ b/Tests/XcodeGenKitTests/CarthageDependencyResolverTests.swift @@ -142,6 +142,6 @@ class CarthageDependencyResolverTests: XCTestCase { } private func makeTestProject(with targets: [Target] = [], options: SpecOptions = SpecOptions()) -> Project { - return Project(name: "Test Project", targets: targets, options: options) + Project(name: "Test Project", targets: targets, options: options) } diff --git a/Tests/XcodeGenKitTests/GeneratorHelpers.swift b/Tests/XcodeGenKitTests/GeneratorHelpers.swift index 595f1524..5edb1a5b 100644 --- a/Tests/XcodeGenKitTests/GeneratorHelpers.swift +++ b/Tests/XcodeGenKitTests/GeneratorHelpers.swift @@ -10,7 +10,7 @@ import TestSupport extension Project { func generateXcodeProject(validate: Bool = true, file: String = #file, line: Int = #line) throws -> XcodeProj { - return try doThrowing(file: file, line: line) { + try doThrowing(file: file, line: line) { if validate { try self.validate() } @@ -20,7 +20,7 @@ extension Project { } func generatePbxProj(specValidate: Bool = true, projectValidate: Bool = true, file: String = #file, line: Int = #line) throws -> PBXProj { - return try doThrowing(file: file, line: line) { + try doThrowing(file: file, line: line) { let xcodeProject = try generateXcodeProject(validate: specValidate).pbxproj if projectValidate { try xcodeProject.validate() diff --git a/Tests/XcodeGenKitTests/ProjectGeneratorTests.swift b/Tests/XcodeGenKitTests/ProjectGeneratorTests.swift index 49d3dce1..e77b66c8 100644 --- a/Tests/XcodeGenKitTests/ProjectGeneratorTests.swift +++ b/Tests/XcodeGenKitTests/ProjectGeneratorTests.swift @@ -1004,7 +1004,7 @@ class ProjectGeneratorTests: XCTestCase { // generated plist should not be in buildsettings try expect(targetConfig.buildSettings["INFOPLIST_FILE"] as? String) == predefinedPlistPath } - + describe("Carthage dependencies") { $0.context("with static dependency") { $0.it("should set dependencies") { @@ -1018,7 +1018,7 @@ class ProjectGeneratorTests: XCTestCase { ) let project = Project(name: "test", targets: [app]) let pbxProject = try project.generatePbxProj() - + let target = pbxProject.nativeTargets.first! let configuration = target.buildConfigurationList!.buildConfigurations.first! try expect(configuration.buildSettings["FRAMEWORK_SEARCH_PATHS"] as? [String]) == ["$(inherited)", "$(PROJECT_DIR)/Carthage/Build/iOS/Static"] @@ -1027,11 +1027,11 @@ class ProjectGeneratorTests: XCTestCase { return XCTFail("frameworkBuildPhase should have files") } try expect(file.file?.nameOrPath) == "MyStaticFramework.framework" - + try expect(target.carthageCopyFrameworkBuildPhase).beNil() } } - + $0.context("with mixed dependencies") { $0.it("should set dependencies") { let app = Target( @@ -1045,7 +1045,7 @@ class ProjectGeneratorTests: XCTestCase { ) let project = Project(name: "test", targets: [app]) let pbxProject = try project.generatePbxProj() - + let target = pbxProject.nativeTargets.first! let configuration = target.buildConfigurationList!.buildConfigurations.first! try expect(configuration.buildSettings["FRAMEWORK_SEARCH_PATHS"] as? [String]) == ["$(inherited)", "$(PROJECT_DIR)/Carthage/Build/iOS/Static", "$(PROJECT_DIR)/Carthage/Build/iOS"] @@ -1059,7 +1059,7 @@ class ProjectGeneratorTests: XCTestCase { guard let _ = files.first(where: { $0.file?.nameOrPath == "MyStaticFramework.framework" }) else { return XCTFail("Framework Build Phase should have Static Framework") } - + guard let copyCarthagePhase = target.carthageCopyFrameworkBuildPhase else { return XCTFail("Carthage Build Phase should be exist") } @@ -1144,7 +1144,7 @@ class ProjectGeneratorTests: XCTestCase { } } } - + describe("Carthage dependencies") { $0.context("with static dependency") { $0.it("should set dependencies") { @@ -1158,7 +1158,7 @@ class ProjectGeneratorTests: XCTestCase { ) let project = Project(name: "test", targets: [app]) let pbxProject = try project.generatePbxProj() - + let target = pbxProject.nativeTargets.first! let configuration = target.buildConfigurationList!.buildConfigurations.first! try expect(configuration.buildSettings["FRAMEWORK_SEARCH_PATHS"] as? [String]) == ["$(inherited)", "$(PROJECT_DIR)/Carthage/Build/iOS/Static"] @@ -1167,11 +1167,11 @@ class ProjectGeneratorTests: XCTestCase { return XCTFail("frameworkBuildPhase should have files") } try expect(file.file?.nameOrPath) == "MyStaticFramework.framework" - + try expect(target.carthageCopyFrameworkBuildPhase).beNil() } } - + $0.context("with mixed dependencies") { $0.it("should set dependencies") { let app = Target( @@ -1185,7 +1185,7 @@ class ProjectGeneratorTests: XCTestCase { ) let project = Project(name: "test", targets: [app]) let pbxProject = try project.generatePbxProj() - + let target = pbxProject.nativeTargets.first! let configuration = target.buildConfigurationList!.buildConfigurations.first! try expect(configuration.buildSettings["FRAMEWORK_SEARCH_PATHS"] as? [String]) == ["$(inherited)", "$(PROJECT_DIR)/Carthage/Build/iOS/Static", "$(PROJECT_DIR)/Carthage/Build/iOS"] @@ -1199,7 +1199,7 @@ class ProjectGeneratorTests: XCTestCase { guard let _ = files.first(where: { $0.file?.nameOrPath == "MyStaticFramework.framework" }) else { return XCTFail("Framework Build Phase should have Static Framework") } - + guard let copyCarthagePhase = target.carthageCopyFrameworkBuildPhase else { return XCTFail("Carthage Build Phase should be exist") } @@ -1214,6 +1214,6 @@ class ProjectGeneratorTests: XCTestCase { private extension PBXTarget { var carthageCopyFrameworkBuildPhase: PBXShellScriptBuildPhase? { - return buildPhases.first(where: { $0.name() == "Carthage" }) as? PBXShellScriptBuildPhase + buildPhases.first(where: { $0.name() == "Carthage" }) as? PBXShellScriptBuildPhase } } diff --git a/Tests/XcodeGenKitTests/SourceGeneratorTests.swift b/Tests/XcodeGenKitTests/SourceGeneratorTests.swift index 294fb272..7775dbd4 100644 --- a/Tests/XcodeGenKitTests/SourceGeneratorTests.swift +++ b/Tests/XcodeGenKitTests/SourceGeneratorTests.swift @@ -142,11 +142,11 @@ class SourceGeneratorTests: XCTestCase { let pbxProj = try project.generatePbxProj() func getFileReferences(_ path: String) -> [PBXFileReference] { - return pbxProj.fileReferences.filter { $0.path == path } + pbxProj.fileReferences.filter { $0.path == path } } func getVariableGroups(_ name: String?) -> [PBXVariantGroup] { - return pbxProj.variantGroups.filter { $0.name == name } + pbxProj.variantGroups.filter { $0.name == name } } let resourceName = "LocalizedStoryboard.storyboard" @@ -199,11 +199,11 @@ class SourceGeneratorTests: XCTestCase { let pbxProj = inputXcodeProj.pbxproj func getFileReferences(_ path: String) -> [PBXFileReference] { - return pbxProj.fileReferences.filter { $0.path == path } + pbxProj.fileReferences.filter { $0.path == path } } func getVariableGroups(_ name: String?) -> [PBXVariantGroup] { - return pbxProj.variantGroups.filter { $0.name == name } + pbxProj.variantGroups.filter { $0.name == name } } let stringsResourceName = "Localizable.strings"