Skip to content

Commit

Permalink
make format_code
Browse files Browse the repository at this point in the history
  • Loading branch information
yonaskolb committed Sep 1, 2019
1 parent 777b15f commit d921d14
Show file tree
Hide file tree
Showing 25 changed files with 97 additions and 105 deletions.
2 changes: 1 addition & 1 deletion Sources/ProjectSpec/AggregateTarget.swift
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ extension AggregateTarget: JSONEncodable {
"configFiles": configFiles,
"attributes": attributes,
"buildScripts": buildScripts.map { $0.toJSONValue() },
"scheme": scheme?.toJSONValue()
"scheme": scheme?.toJSONValue(),
] as [String: Any?]
}
}
Expand Down
2 changes: 1 addition & 1 deletion Sources/ProjectSpec/BuildRule.swift
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ extension BuildRule: JSONEncodable {
var dict: [String: Any?] = [
"outputFiles": outputFiles,
"outputFilesCompilerFlags": outputFilesCompilerFlags,
"name": name
"name": name,
]

switch fileType {
Expand Down
3 changes: 2 additions & 1 deletion Sources/ProjectSpec/BuildScript.swift
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ extension BuildScript: JSONObjectConvertible {
showEnvVars = jsonDictionary.json(atKeyPath: "showEnvVars") ?? BuildScript.showEnvVarsDefault
}
}

extension BuildScript: JSONEncodable {
public func toJSONValue() -> Any {
var dict: [String: Any?] = [
Expand All @@ -72,7 +73,7 @@ extension BuildScript: JSONEncodable {
"outputFileLists": outputFileLists,
"runOnlyWhenInstalling": runOnlyWhenInstalling,
"name": name,
"shell": shell
"shell": shell,
]

if showEnvVars != BuildScript.showEnvVarsDefault {
Expand Down
2 changes: 1 addition & 1 deletion Sources/ProjectSpec/Dependency.swift
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ extension Dependency: JSONEncodable {
var dict: [String: Any?] = [
"embed": embed,
"codeSign": codeSign,
"link": link
"link": link,
]

if removeHeaders != Dependency.removeHeadersDefault {
Expand Down
2 changes: 1 addition & 1 deletion Sources/ProjectSpec/Plist.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ extension Plist: JSONEncodable {
public func toJSONValue() -> Any {
return [
"path": path,
"properties": properties
"properties": properties,
]
}
}
Expand Down
2 changes: 1 addition & 1 deletion Sources/ProjectSpec/Project.swift
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ extension Project: JSONEncodable {
"configs": Dictionary(uniqueKeysWithValues: configsPairs),
"aggregateTargets": Dictionary(uniqueKeysWithValues: aggregateTargetsPairs),
"schemes": Dictionary(uniqueKeysWithValues: schemesPairs),
"settingGroups": settingGroups.mapValues { $0.toJSONValue() }
"settingGroups": settingGroups.mapValues { $0.toJSONValue() },
]
}
}
16 changes: 8 additions & 8 deletions Sources/ProjectSpec/Scheme.swift
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ public struct Scheme: Equatable {

public struct Archive: BuildAction {
public static let revealArchiveInOrganizerDefault = true

public var config: String?
public var customArchiveName: String?
public var revealArchiveInOrganizer: Bool
Expand Down Expand Up @@ -247,7 +247,7 @@ extension Scheme.ExecutionAction: JSONEncodable {
return [
"script": script,
"name": name,
"settingsTarget": settingsTarget
"settingsTarget": settingsTarget,
]
}
}
Expand All @@ -271,7 +271,7 @@ extension Scheme.Run: JSONEncodable {
"preActions": preActions.map { $0.toJSONValue() },
"postActions": postActions.map { $0.toJSONValue() },
"environmentVariables": environmentVariables.map { $0.toJSONValue() },
"config": config
"config": config,
]

if disableMainThreadChecker != Scheme.Run.disableMainThreadCheckerDefault {
Expand Down Expand Up @@ -316,7 +316,7 @@ extension Scheme.Test: JSONEncodable {
"preActions": preActions.map { $0.toJSONValue() },
"postActions": postActions.map { $0.toJSONValue() },
"environmentVariables": environmentVariables.map { $0.toJSONValue() },
"config": config
"config": config,
]

if gatherCoverageData != Scheme.Test.gatherCoverageDataDefault {
Expand Down Expand Up @@ -348,7 +348,7 @@ extension Scheme.Test.TestTarget: JSONEncodable {
}

var dict: JSONDictionary = [
"name": name
"name": name,
]

if randomExecutionOrder != Scheme.Test.TestTarget.randomExecutionOrderDefault {
Expand Down Expand Up @@ -380,7 +380,7 @@ extension Scheme.Profile: JSONEncodable {
"preActions": preActions.map { $0.toJSONValue() },
"postActions": postActions.map { $0.toJSONValue() },
"environmentVariables": environmentVariables.map { $0.toJSONValue() },
"config": config
"config": config,
] as [String: Any?]
}
}
Expand All @@ -395,7 +395,7 @@ extension Scheme.Analyze: JSONObjectConvertible {
extension Scheme.Analyze: JSONEncodable {
public func toJSONValue() -> Any {
return [
"config": config
"config": config,
]
}
}
Expand Down Expand Up @@ -581,7 +581,7 @@ extension XCScheme.EnvironmentVariable: JSONEncodable {
public func toJSONValue() -> Any {
var dict: [String: Any] = [
"variable": variable,
"value": value
"value": value,
]

if enabled != XCScheme.EnvironmentVariable.enabledDefault {
Expand Down
2 changes: 1 addition & 1 deletion Sources/ProjectSpec/Settings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ extension Settings: JSONEncodable {
return [
"base": buildSettings,
"groups": groups,
"configs": configSettings.mapValues { $0.toJSONValue() }
"configs": configSettings.mapValues { $0.toJSONValue() },
]
}
return buildSettings
Expand Down
20 changes: 10 additions & 10 deletions Sources/ProjectSpec/SpecFile.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public struct SpecFile {
public let subSpecs: [SpecFile]

private let filename: String

fileprivate struct Include {
let path: Path
let relativePaths: Bool
Expand Down Expand Up @@ -92,27 +92,27 @@ public struct SpecFile {

private func resolvedDictionaryWithUniqueTargets() -> JSONDictionary {
let resolvedSpec = resolvingPaths()

var value = Set<String>()
return resolvedSpec.mergedDictionary(set: &value)
}

private func substitute(variables: [String: String], in mergedDictionary: JSONDictionary) -> JSONDictionary {
var resolvedSpec = mergedDictionary

for (key, value) in variables {
resolvedSpec = resolvedSpec.replaceString("${\(key)}", with: value)
}

return resolvedSpec
}

func mergedDictionary(set mergedTargets: inout Set<String>) -> JSONDictionary {
let name = (basePath + relativePath + Path(filename)).description

guard !mergedTargets.contains(name) else { return [:] }
mergedTargets.insert(name)

return jsonDictionary.merged(onto:
subSpecs
.map { $0.mergedDictionary(set: &mergedTargets) }
Expand All @@ -137,14 +137,14 @@ public struct SpecFile {

extension Dictionary where Key == String, Value: Any {

func merged(onto other: Dictionary<Key, Value>) -> Dictionary<Key, Value> {
func merged(onto other: [Key: Value]) -> [Key: Value] {
var merged = other

for (key, value) in self {
if key.hasSuffix(":REPLACE") {
let newKey = key[key.startIndex..<key.index(key.endIndex, offsetBy: -8)]
merged[Key(newKey)] = value
} else if let dictionary = value as? Dictionary<Key, Value>, let base = merged[key] as? Dictionary<Key, Value> {
} else if let dictionary = value as? [Key: Value], let base = merged[key] as? [Key: Value] {
merged[key] = dictionary.merged(onto: base) as? Value
} else if let array = value as? [Any], let base = merged[key] as? [Any] {
merged[key] = (base + array) as? Value
Expand Down
9 changes: 4 additions & 5 deletions Sources/ProjectSpec/Target.swift
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,6 @@ extension Target: NamedJSONDictionaryConvertible {
}
}


extension Target: JSONEncodable {
public func toJSONValue() -> Any {
var dict: [String: Any?] = [
Expand All @@ -372,10 +371,10 @@ extension Target: JSONEncodable {
"attributes": attributes,
"sources": sources.map { $0.toJSONValue() },
"dependencies": dependencies.map { $0.toJSONValue() },
"postCompileScripts": postCompileScripts.map{ $0.toJSONValue() },
"prebuildScripts": preBuildScripts.map{ $0.toJSONValue() },
"postbuildScripts": postBuildScripts.map{ $0.toJSONValue() },
"buildRules": buildRules.map{ $0.toJSONValue() },
"postCompileScripts": postCompileScripts.map { $0.toJSONValue() },
"prebuildScripts": preBuildScripts.map { $0.toJSONValue() },
"postbuildScripts": postBuildScripts.map { $0.toJSONValue() },
"buildRules": buildRules.map { $0.toJSONValue() },
"deploymentTarget": deploymentTarget?.deploymentTarget,
"info": info?.toJSONValue(),
"entitlements": entitlements?.toJSONValue(),
Expand Down
2 changes: 1 addition & 1 deletion Sources/ProjectSpec/TargetScheme.swift
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ extension TargetScheme: JSONEncodable {
"preActions": preActions.map { $0.toJSONValue() },
"postActions": postActions.map { $0.toJSONValue() },
]

if gatherCoverageData != TargetScheme.gatherCoverageDataDefault {
dict["gatherCoverageData"] = gatherCoverageData
}
Expand Down
2 changes: 1 addition & 1 deletion Sources/ProjectSpec/TargetSource.swift
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ extension TargetSource.BuildPhase.CopyFilesSettings: JSONEncodable {
public func toJSONValue() -> Any {
return [
"destination": destination.rawValue,
"subpath": subpath
"subpath": subpath,
]
}
}
Expand Down
8 changes: 2 additions & 6 deletions Sources/XcodeGenKit/Glob.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,8 @@
// Adapted from https://gist.github.com/blakemerryman/76312e1cbf8aec248167
// Adapted from https://gist.github.com/efirestone/ce01ae109e08772647eb061b3bb387c3


import Foundation


public let GlobBehaviorBashV3 = Glob.Behavior(
supportsGlobstar: false,
includesFilesFromRootOfGlobstar: false,
Expand All @@ -29,7 +27,6 @@ public let GlobBehaviorGradle = Glob.Behavior(
includesFilesInResultsIfTrailingSlash: true
)


/**
Finds files on the file system using pattern matching.
*/
Expand Down Expand Up @@ -66,7 +63,7 @@ public class Glob: Collection {
public let blacklistedDirectories: [String]
var paths = [String]()
public var startIndex: Int { return paths.startIndex }
public var endIndex: Int { return paths.endIndex }
public var endIndex: Int { return paths.endIndex }

/// Initialize a glob
///
Expand Down Expand Up @@ -126,7 +123,7 @@ public class Glob: Collection {
private var globalFlags = GLOB_TILDE | GLOB_BRACE | GLOB_MARK

private func executeGlob(pattern: UnsafePointer<CChar>, gt: UnsafeMutablePointer<glob_t>) -> Bool {
return 0 == glob(pattern, globalFlags, nil, gt)
return glob(pattern, globalFlags, nil, gt) == 0
}

private func expandGlobstar(pattern: String) -> [String] {
Expand Down Expand Up @@ -234,4 +231,3 @@ private extension Sequence {
return Array(self)
}
}

20 changes: 8 additions & 12 deletions Sources/XcodeGenKit/MD5.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ extension String {
public var md5: String {
if let data = data(using: .utf8, allowLossyConversion: true) {
let message = data.withUnsafeBytes { (bytes: UnsafeRawBufferPointer) -> [UInt8] in
return Array(bytes)
Array(bytes)
}

let MD5Calculator = MD5(message)
Expand Down Expand Up @@ -80,14 +80,14 @@ extension NSMutableData {
}

protocol HashProtocol {
var message: Array<UInt8> { get }
var message: [UInt8] { get }

/** Common part for hash calculation. Prepare header data. */
func prepare(_ len: Int) -> Array<UInt8>
func prepare(_ len: Int) -> [UInt8]
}

extension HashProtocol {
func prepare(_ len: Int) -> Array<UInt8> {
func prepare(_ len: Int) -> [UInt8] {
var tmpMessage = message

// Step 1. Append Padding Bits
Expand All @@ -102,13 +102,13 @@ extension HashProtocol {
msgLength += 1
}

tmpMessage += Array<UInt8>(repeating: 0, count: counter)
tmpMessage += [UInt8](repeating: 0, count: counter)
return tmpMessage
}
}

func toUInt32Array(_ slice: ArraySlice<UInt8>) -> Array<UInt32> {
var result = Array<UInt32>()
func toUInt32Array(_ slice: ArraySlice<UInt8>) -> [UInt32] {
var result = [UInt32]()
result.reserveCapacity(16)

for idx in stride(from: slice.startIndex, to: slice.endIndex, by: MemoryLayout<UInt32>.size) {
Expand Down Expand Up @@ -230,26 +230,22 @@ class MD5: HashProtocol {
case 0...15:
F = (B & C) | ((~B) & D)
g = j
break
case 16...31:
F = (D & B) | (~D & C)
g = (5 * j + 1) % 16
break
case 32...47:
F = B ^ C ^ D
g = (3 * j + 5) % 16
break
case 48...63:
F = C ^ (B | (~D))
g = (7 * j) % 16
break
default:
break
}
dTemp = D
D = C
C = B
B = B &+ rotateLeft((A &+ F &+ sines[j] &+ M[g]), bits: shifts[j])
B = B &+ rotateLeft(A &+ F &+ sines[j] &+ M[g], bits: shifts[j])
A = dTemp
}

Expand Down
2 changes: 1 addition & 1 deletion Sources/XcodeGenKit/PBXProjGenerator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -999,7 +999,7 @@ extension Target {
var shouldEmbedDependencies: Bool {
return type.isApp || type.isTest
}

var shouldEmbedCarthageDependencies: Bool {
return (type.isApp && platform != .watchOS)
|| type == .watch2Extension
Expand Down
2 changes: 1 addition & 1 deletion Sources/XcodeGenKit/SchemeGenerator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ public class SchemeGenerator {
func getExecutionAction(_ action: Scheme.ExecutionAction) -> XCScheme.ExecutionAction {
// ExecutionActions can require the use of build settings. Xcode allows the settings to come from a build or test target.
let environmentBuildable = action.settingsTarget.flatMap { settingsTarget in
return (buildActionEntries + testBuildTargetEntries)
(buildActionEntries + testBuildTargetEntries)
.first { settingsTarget == $0.buildableReference.blueprintName }?
.buildableReference
}
Expand Down
2 changes: 1 addition & 1 deletion Sources/XcodeGenKit/XCProjExtensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ extension PBXProj {

extension Dictionary {

public var valueArray: Array<Value> {
public var valueArray: [Value] {
return Array(values)
}
}
Expand Down
Loading

0 comments on commit d921d14

Please sign in to comment.