Skip to content

Commit

Permalink
convert optional bindings to shorthand
Browse files Browse the repository at this point in the history
  • Loading branch information
avbangar committed Feb 2, 2023
1 parent 289872e commit fa1bc75
Show file tree
Hide file tree
Showing 10 changed files with 18 additions and 18 deletions.
4 changes: 2 additions & 2 deletions Sources/XCDiffCommand/CommandRunner.swift
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public final class CommandRunner {
}

private func complete(commandType: ParsableCommand.Type, withError error: Error? = nil) -> Int32 {
guard let error = error else {
guard let error else {
return ExitCode.success.rawValue
}

Expand Down Expand Up @@ -141,7 +141,7 @@ public final class CommandRunner {
}

private func getPaths(_ path1Arg: String?, _ path2Arg: String?) throws -> (Path, Path) {
if let path1Arg = path1Arg, let path2Arg = path2Arg {
if let path1Arg, let path2Arg {
let path1 = Path(path1Arg)
let path2 = Path(path2Arg)
guard path1.exists else {
Expand Down
4 changes: 2 additions & 2 deletions Sources/XCDiffCore/Comparator/CopyFilesComparator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,12 @@ final class CopyFilesComparator: Comparator {
private func compare(_ first: CopyFilesBuildPhaseDescriptor?,
_ second: CopyFilesBuildPhaseDescriptor?,
context: [String]) throws -> CompareResult {
guard let first = first else {
guard let first else {
return result(context: context,
description: "The build phase does not exist in the first project",
onlyInSecond: ["Duplicated build phase name"])
}
guard let second = second else {
guard let second else {
return result(context: context,
description: "The build phase does not exist in the second project",
onlyInFirst: ["Duplicated build phase name"])
Expand Down
8 changes: 4 additions & 4 deletions Sources/XCDiffCore/Comparator/DependenciesComparator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ private struct DependencyDescriptor {
}

private func string(from proxyType: PBXContainerItemProxy.ProxyType?) -> String? {
guard let proxyType = proxyType else {
guard let proxyType else {
return nil
}
switch proxyType {
Expand Down Expand Up @@ -123,15 +123,15 @@ private struct DependencyDescriptor {

// name
if case let .target(target) = context {
if let name = name, name != target {
if let name, name != target {
result.append("name=\(name)")
}
} else if let name = name {
} else if let name {
result.append("name=\(name)")
}

// product name
if let productName = productName {
if let productName {
result.append("product_name=\(productName.description)")
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,11 @@ final class ResolvedSettingsComparator: Comparator {
path,
]

if let target = target {
if let target {
arguments.append(contentsOf: ["-target", target])
}

if let config = config {
if let config {
arguments.append(contentsOf: ["-config", config])
}

Expand Down
4 changes: 2 additions & 2 deletions Sources/XCDiffCore/Comparator/RunScriptComparator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,12 @@ final class RunScriptComparator: Comparator {
private func compare(_ first: RunScriptBuildPhaseDescriptor?,
_ second: RunScriptBuildPhaseDescriptor?,
context: [String]) throws -> CompareResult {
guard let first = first else {
guard let first else {
return result(context: context,
description: "The build phase does not exist in the first project",
onlyInSecond: ["Duplicated build phase name"])
}
guard let second = second else {
guard let second else {
return result(context: context,
description: "The build phase does not exist in the second project",
onlyInFirst: ["Duplicated build phase name"])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ struct SwiftPackageDescriptor: Hashable, CustomStringConvertible, Comparable {
}

func difference(from other: SwiftPackageDescriptor?) -> String? {
guard let other = other else {
guard let other else {
return description
}
guard other != self else {
Expand Down
4 changes: 2 additions & 2 deletions Sources/XCDiffCore/Library/SettingValueComparator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class SettingValueComparator: ValueComparator {
// MARK: - Lifecycle

init(firstProjectName: String?, secondProjectName: String?) {
guard let firstProjectName = firstProjectName, let secondProjectName = secondProjectName else {
guard let firstProjectName, let secondProjectName else {
projectNameDifference = nil
return
}
Expand All @@ -51,7 +51,7 @@ class SettingValueComparator: ValueComparator {
guard lha != rha else {
return true
}
guard let projectNameDifference = projectNameDifference else {
guard let projectNameDifference else {
return lha == rha
}
let settingValuesDifference = stringDiff.diff(lha, rha)
Expand Down
2 changes: 1 addition & 1 deletion Sources/XCDiffCore/Library/SettingsHelper.swift
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ class SettingsHelper {

private func stringFromBuildSetting(_ buildSetting: Any?) throws -> String {
// try to unwrap
guard let buildSetting = buildSetting else {
guard let buildSetting else {
return "nil"
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ final class HTMLRenderer: Renderer {

private func tag(_ name: String, _ cssClass: CSSClass? = nil, _ content: () -> Void) {
let cssClassString: String
if let cssClass = cssClass {
if let cssClass {
cssClassString = " class=\"\(cssClass.rawValue)\""
} else {
cssClassString = ""
Expand Down
2 changes: 1 addition & 1 deletion Tests/XCDiffCoreTests/Helpers/PBXBuildFileBuilder.swift
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ final class PBXBuildFileBuilder {
buildFile.platformFilter = platformFilter
var objects: [PBXObject?] = [buildFile, fileReference]

if let packageProduct = packageProduct {
if let packageProduct {
let packageReference = packageProduct.package.map {
XCRemoteSwiftPackageReference(
repositoryURL: $0.url,
Expand Down

0 comments on commit fa1bc75

Please sign in to comment.