Skip to content

Commit cdedff0

Browse files
authored
Use SwiftFormat version 0.49.x and enable some new rules (#527)
1 parent b62c5fa commit cdedff0

32 files changed

+139
-126
lines changed

.swiftformat

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,16 @@
1010
## Enabled rules
1111

1212
--rules \
13+
acronyms, \
1314
andOperator, \
1415
anyObjectProtocol, \
16+
assertionFailures, \
1517
blankLinesAroundMark, \
1618
blankLinesAtEndOfScope, \
1719
blankLinesAtStartOfScope, \
20+
# blankLinesBetweenImports, \
1821
blankLinesBetweenScopes, \
22+
blockComments, \
1923
braces, \
2024
consecutiveBlankLines, \
2125
consecutiveSpaces, \
@@ -36,9 +40,11 @@
3640
# markTypes, \
3741
numberFormatting, \
3842
# organizeDeclarations, \
43+
preferDouble, \
3944
preferKeyPath, \
4045
redundantBackticks, \
4146
redundantBreak, \
47+
redundantClosure, \
4248
redundantExtensionACL, \
4349
redundantFileprivate, \
4450
redundantGet, \
@@ -81,13 +87,18 @@
8187
wrap, \
8288
wrapArguments, \
8389
wrapAttributes, \
90+
wrapConditionalBodies, \
8491
# wrapEnumCases, \
8592
# wrapMultilineStatementBraces, \
8693
# wrapSwitchCases, \
8794
yodaConditions
8895

8996
## Formatting options
9097

98+
### Acronyms to auto-capitalize. Defaults to "ID,URL,UUID".
99+
100+
--acronyms "GPG, HTTP, HTTPS, ID, PGP, SSH, URI, URL, UUID"
101+
91102
### Use allman indentation style: "true" or "false" (default)
92103

93104
--allman false
@@ -272,6 +283,14 @@
272283

273284
--wrapreturntype preserve
274285

286+
### Wrap ternary operators: "default", "before-operators"
287+
288+
--wrapternary before-operators
289+
290+
### Wrap typealiases: "before-first", "after-first", "preserve"
291+
292+
--wraptypealiases preserve
293+
275294
### Xcode indent guard/enum: "enabled" or "disabled" (default)
276295

277296
--xcodeindentation disabled

pass.xcodeproj/project.pbxproj

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -180,14 +180,14 @@
180180
DC4914961E434301007FF592 /* LabelTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = DC4914941E434301007FF592 /* LabelTableViewCell.swift */; };
181181
DC4914991E434600007FF592 /* PasswordDetailTableViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = DC4914981E434600007FF592 /* PasswordDetailTableViewController.swift */; };
182182
DC5F385B1E56AADB00C69ACA /* PGPKeyArmorImportTableViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = DC5F385A1E56AADB00C69ACA /* PGPKeyArmorImportTableViewController.swift */; };
183-
DC8963C01E38EEB900828B09 /* SSHKeyUrlImportTableViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = DC8963BF1E38EEB900828B09 /* SSHKeyUrlImportTableViewController.swift */; };
183+
DC8963C01E38EEB900828B09 /* SSHKeyURLImportTableViewController..swift in Sources */ = {isa = PBXBuildFile; fileRef = DC8963BF1E38EEB900828B09 /* SSHKeyURLImportTableViewController..swift */; };
184184
DC917BD71E2E8231000FDF54 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = DC917BD61E2E8231000FDF54 /* AppDelegate.swift */; };
185185
DC917BDC1E2E8231000FDF54 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = DC917BDA1E2E8231000FDF54 /* Main.storyboard */; };
186186
DC917BDE1E2E8231000FDF54 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = DC917BDD1E2E8231000FDF54 /* Assets.xcassets */; };
187187
DC917BE11E2E8231000FDF54 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = DC917BDF1E2E8231000FDF54 /* LaunchScreen.storyboard */; };
188188
DC962CDF1E4B62C10033B5D8 /* AboutTableViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = DC962CDE1E4B62C10033B5D8 /* AboutTableViewController.swift */; };
189189
DCA0499A1E335CC800522E8F /* GitRepositorySettingsTableViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = DCA049991E335CC800522E8F /* GitRepositorySettingsTableViewController.swift */; };
190-
DCA0499C1E3362F400522E8F /* PGPKeyUrlImportTableViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = DCA0499B1E3362F400522E8F /* PGPKeyUrlImportTableViewController.swift */; };
190+
DCA0499C1E3362F400522E8F /* PGPKeyURLImportTableViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = DCA0499B1E3362F400522E8F /* PGPKeyURLImportTableViewController.swift */; };
191191
DCAAF7451E2FA66800AB94BC /* SettingsTableViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = DCAAF7441E2FA66800AB94BC /* SettingsTableViewController.swift */; };
192192
DCC441521E8F6C06008A90C4 /* RawPasswordViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = DCC441511E8F6C06008A90C4 /* RawPasswordViewController.swift */; };
193193
DCC441541E916382008A90C4 /* SSHKeyArmorImportTableViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = DCC441531E916382008A90C4 /* SSHKeyArmorImportTableViewController.swift */; };
@@ -463,7 +463,7 @@
463463
DC4914941E434301007FF592 /* LabelTableViewCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LabelTableViewCell.swift; sourceTree = "<group>"; };
464464
DC4914981E434600007FF592 /* PasswordDetailTableViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PasswordDetailTableViewController.swift; sourceTree = "<group>"; };
465465
DC5F385A1E56AADB00C69ACA /* PGPKeyArmorImportTableViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PGPKeyArmorImportTableViewController.swift; sourceTree = "<group>"; };
466-
DC8963BF1E38EEB900828B09 /* SSHKeyUrlImportTableViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SSHKeyUrlImportTableViewController.swift; sourceTree = "<group>"; };
466+
DC8963BF1E38EEB900828B09 /* SSHKeyURLImportTableViewController..swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SSHKeyURLImportTableViewController..swift; sourceTree = "<group>"; };
467467
DC917BD31E2E8231000FDF54 /* Pass.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Pass.app; sourceTree = BUILT_PRODUCTS_DIR; };
468468
DC917BD61E2E8231000FDF54 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
469469
DC917BDB1E2E8231000FDF54 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = "<group>"; };
@@ -472,7 +472,7 @@
472472
DC917BE21E2E8231000FDF54 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
473473
DC962CDE1E4B62C10033B5D8 /* AboutTableViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AboutTableViewController.swift; sourceTree = "<group>"; };
474474
DCA049991E335CC800522E8F /* GitRepositorySettingsTableViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GitRepositorySettingsTableViewController.swift; sourceTree = "<group>"; };
475-
DCA0499B1E3362F400522E8F /* PGPKeyUrlImportTableViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PGPKeyUrlImportTableViewController.swift; sourceTree = "<group>"; };
475+
DCA0499B1E3362F400522E8F /* PGPKeyURLImportTableViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PGPKeyURLImportTableViewController.swift; sourceTree = "<group>"; };
476476
DCAAF7441E2FA66800AB94BC /* SettingsTableViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SettingsTableViewController.swift; sourceTree = "<group>"; };
477477
DCC441511E8F6C06008A90C4 /* RawPasswordViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RawPasswordViewController.swift; sourceTree = "<group>"; };
478478
DCC441531E916382008A90C4 /* SSHKeyArmorImportTableViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SSHKeyArmorImportTableViewController.swift; sourceTree = "<group>"; };
@@ -916,15 +916,15 @@
916916
DC5F385A1E56AADB00C69ACA /* PGPKeyArmorImportTableViewController.swift */,
917917
302269B223E634B000F843A3 /* PGPKeyFIleImportTableViewController.swift */,
918918
3066AD6723EE0D6500F65535 /* PGPKeyImporter.swift */,
919-
DCA0499B1E3362F400522E8F /* PGPKeyUrlImportTableViewController.swift */,
919+
DCA0499B1E3362F400522E8F /* PGPKeyURLImportTableViewController.swift */,
920920
A2A7813E1E97DBD9001311F5 /* QRScannerController.swift */,
921921
DCC441511E8F6C06008A90C4 /* RawPasswordViewController.swift */,
922922
DCD3C65D1EFB9BB400CBE842 /* SettingsSplitViewController.swift */,
923923
DCAAF7441E2FA66800AB94BC /* SettingsTableViewController.swift */,
924924
DC037CA91E4B8EAE00609409 /* SpecialThanksTableViewController.swift */,
925925
DCC441531E916382008A90C4 /* SSHKeyArmorImportTableViewController.swift */,
926926
30650E7023F82AF8005CCD5E /* SSHKeyFileImportTableViewController.swift */,
927-
DC8963BF1E38EEB900828B09 /* SSHKeyUrlImportTableViewController.swift */,
927+
DC8963BF1E38EEB900828B09 /* SSHKeyURLImportTableViewController..swift */,
928928
);
929929
path = Controllers;
930930
sourceTree = "<group>";
@@ -1604,15 +1604,15 @@
16041604
DCC441541E916382008A90C4 /* SSHKeyArmorImportTableViewController.swift in Sources */,
16051605
306D970E24091CDD006C0E2E /* SwitchTableViewCell.swift in Sources */,
16061606
A2A61C201EEFABAD00CFE063 /* UtilsExtension.swift in Sources */,
1607-
DC8963C01E38EEB900828B09 /* SSHKeyUrlImportTableViewController.swift in Sources */,
1607+
DC8963C01E38EEB900828B09 /* SSHKeyURLImportTableViewController..swift in Sources */,
16081608
9AFC87F025B514AD008D6060 /* PasswordDecryptor.swift in Sources */,
16091609
3066AD6823EE0D6500F65535 /* PGPKeyImporter.swift in Sources */,
16101610
9AFC87E225B3B5C6008D6060 /* PasswordNavigationDataSource.swift in Sources */,
16111611
30650E7123F82AF8005CCD5E /* SSHKeyFileImportTableViewController.swift in Sources */,
16121612
DC193FFA1E49B4430077E0A3 /* AdvancedSettingsTableViewController.swift in Sources */,
16131613
DCFB77AB1E503729008DE471 /* ContentProvider.swift in Sources */,
16141614
9AFC880025B51EC3008D6060 /* PasswordEncryptor.swift in Sources */,
1615-
DCA0499C1E3362F400522E8F /* PGPKeyUrlImportTableViewController.swift in Sources */,
1615+
DCA0499C1E3362F400522E8F /* PGPKeyURLImportTableViewController.swift in Sources */,
16161616
DC4914961E434301007FF592 /* LabelTableViewCell.swift in Sources */,
16171617
DC5F385B1E56AADB00C69ACA /* PGPKeyArmorImportTableViewController.swift in Sources */,
16181618
DCAAF7451E2FA66800AB94BC /* SettingsTableViewController.swift in Sources */,

pass/AppDelegate.swift

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -111,12 +111,10 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
111111
// MARK: - Core Data stack
112112

113113
lazy var persistentContainer: NSPersistentContainer = {
114-
/*
115-
The persistent container for the application. This implementation
116-
creates and returns a container, having loaded the store for the
117-
application to it. This property is optional since there are legitimate
118-
error conditions that could cause the creation of the store to fail.
119-
*/
114+
// The persistent container for the application. This implementation
115+
// creates and returns a container, having loaded the store for the
116+
// application to it. This property is optional since there are legitimate
117+
// error conditions that could cause the creation of the store to fail.
120118
let modelURL = Bundle(identifier: Globals.passKitBundleIdentifier)!.url(forResource: "pass", withExtension: "momd")!
121119
let managedObjectModel = NSManagedObjectModel(contentsOf: modelURL)
122120
let container = NSPersistentContainer(name: "pass", managedObjectModel: managedObjectModel!)
@@ -129,14 +127,14 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
129127
// Replace this implementation with code to handle the error appropriately.
130128
// fatalError() causes the application to generate a crash log and terminate. You should not use this function in a shipping application, although it may be useful during development.
131129

132-
/*
133-
Typical reasons for an error here include:
134-
* The parent directory does not exist, cannot be created, or disallows writing.
135-
* The persistent store is not accessible, due to permissions or data protection when the device is locked.
136-
* The device is out of space.
137-
* The store could not be migrated to the current model version.
138-
Check the error message to determine what the actual problem was.
139-
*/
130+
// Typical reasons for an error here include:
131+
//
132+
// * The parent directory does not exist, cannot be created, or disallows writing.
133+
// * The persistent store is not accessible, due to permissions or data protection when the device is locked.
134+
// * The device is out of space.
135+
// * The store could not be migrated to the current model version.
136+
//
137+
// Check the error message to determine what the actual problem was.
140138
fatalError("UnresolvedError".localize("\(error), \(error.userInfo)"))
141139
}
142140
}

pass/Controllers/AdvancedSettingsTableViewController.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ class AdvancedSettingsTableViewController: UITableViewController {
4949
if tableView.cellForRow(at: indexPath) == eraseDataTableViewCell {
5050
let alert = UIAlertController(title: "ErasePasswordStoreData?".localize(), message: "EraseExplanation.".localize(), preferredStyle: UIAlertController.Style.alert)
5151
alert.addAction(
52-
UIAlertAction(title: "ErasePasswordStoreData".localize(), style: UIAlertAction.Style.destructive) { [unowned self] _ -> Void in
52+
UIAlertAction(title: "ErasePasswordStoreData".localize(), style: UIAlertAction.Style.destructive) { [unowned self] _ in
5353
SVProgressHUD.show(withStatus: "Erasing...".localize())
5454
self.passwordStore.erase()
5555
self.navigationController!.popViewController(animated: true)
@@ -62,7 +62,7 @@ class AdvancedSettingsTableViewController: UITableViewController {
6262
} else if tableView.cellForRow(at: indexPath) == discardChangesTableViewCell {
6363
let alert = UIAlertController(title: "DiscardAllLocalChanges?".localize(), message: "DiscardExplanation.".localize(), preferredStyle: UIAlertController.Style.alert)
6464
alert.addAction(
65-
UIAlertAction(title: "DiscardAllLocalChanges".localize(), style: UIAlertAction.Style.destructive) { [unowned self] _ -> Void in
65+
UIAlertAction(title: "DiscardAllLocalChanges".localize(), style: UIAlertAction.Style.destructive) { [unowned self] _ in
6666
SVProgressHUD.show(withStatus: "Resetting...".localize())
6767
do {
6868
let numberDiscarded = try self.passwordStore.reset()

pass/Controllers/GitRepositorySettingsTableViewController.swift

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ class GitRepositorySettingsTableViewController: UITableViewController, PasswordA
4141
}
4242
}
4343

44-
private var gitUrl: URL {
44+
private var gitURL: URL {
4545
get { Defaults.gitURL }
4646
set { Defaults.gitURL = newValue }
4747
}
@@ -60,7 +60,7 @@ class GitRepositorySettingsTableViewController: UITableViewController, PasswordA
6060

6161
override func viewDidLoad() {
6262
super.viewDidLoad()
63-
gitURLTextField.text = gitUrl.absoluteString
63+
gitURLTextField.text = gitURL.absoluteString
6464
usernameTextField.text = gitUsername
6565
branchNameTextField.text = gitBranchName
6666
sshLabel = authSSHKeyCell.subviews[0].subviews[0] as? UILabel
@@ -70,7 +70,7 @@ class GitRepositorySettingsTableViewController: UITableViewController, PasswordA
7070
override func viewWillAppear(_ animated: Bool) {
7171
super.viewWillAppear(animated)
7272
// Grey out ssh option if ssh_key is not present.
73-
sshLabel?.isEnabled = keychain.contains(key: SshKey.PRIVATE.getKeychainKey())
73+
sshLabel?.isEnabled = keychain.contains(key: SSHKey.PRIVATE.getKeychainKey())
7474
updateAuthenticationMethodCheckView(for: gitAuthenticationMethod)
7575
}
7676

@@ -95,7 +95,7 @@ class GitRepositorySettingsTableViewController: UITableViewController, PasswordA
9595
if cell == authPasswordCell {
9696
gitAuthenticationMethod = .password
9797
} else if cell == authSSHKeyCell {
98-
if !keychain.contains(key: SshKey.PRIVATE.getKeychainKey()) {
98+
if !keychain.contains(key: SSHKey.PRIVATE.getKeychainKey()) {
9999
Utils.alert(title: "CannotSelectSshKey".localize(), message: "PleaseSetupSshKeyFirst.".localize(), controller: self)
100100
gitAuthenticationMethod = .password
101101
} else {
@@ -146,7 +146,7 @@ class GitRepositorySettingsTableViewController: UITableViewController, PasswordA
146146
}
147147
}
148148

149-
gitUrl = gitURL
149+
self.gitURL = gitURL
150150
gitBranchName = branchName.trimmed
151151
gitUsername = (gitURL.user ?? usernameTextField.text ?? "git").trimmed
152152

@@ -186,7 +186,7 @@ class GitRepositorySettingsTableViewController: UITableViewController, PasswordA
186186
let options = self.gitCredential.getCredentialOptions(passwordProvider: self.present)
187187

188188
try self.passwordStore.cloneRepository(
189-
remoteRepoURL: self.gitUrl,
189+
remoteRepoURL: self.gitURL,
190190
branchName: self.gitBranchName,
191191
options: options,
192192
transferProgressBlock: transferProgressBlock,
@@ -278,7 +278,7 @@ class GitRepositorySettingsTableViewController: UITableViewController, PasswordA
278278
private func showSSHKeyActionSheet() {
279279
let optionMenu = UIAlertController(title: nil, message: nil, preferredStyle: .actionSheet)
280280
optionMenu.addAction(
281-
UIAlertAction(title: SSHKeyUrlImportTableViewController.menuLabel, style: .default) { _ in
281+
UIAlertAction(title: SSHKeyURLImportTableViewController.menuLabel, style: .default) { _ in
282282
self.performSegue(withIdentifier: "setGitSSHKeyByURLSegue", sender: self)
283283
}
284284
)
@@ -354,10 +354,10 @@ extension GitRepositorySettingsTableViewController: KeyImporter {
354354
static let label = "ITunesFileSharing".localize()
355355

356356
func isReadyToUse() -> Bool {
357-
KeyFileManager.PrivateSsh.doesKeyFileExist()
357+
KeyFileManager.PrivateSSH.doesKeyFileExist()
358358
}
359359

360360
func importKeys() throws {
361-
try KeyFileManager.PrivateSsh.importKeyFromFileSharing()
361+
try KeyFileManager.PrivateSSH.importKeyFromFileSharing()
362362
}
363363
}

pass/Controllers/PGPKeyArmorImportTableViewController.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,8 @@ extension PGPKeyArmorImportTableViewController: PGPKeyImporter {
109109
}
110110

111111
func importKeys() throws {
112-
try KeyFileManager.PublicPgp.importKey(from: armorPublicKey ?? "")
113-
try KeyFileManager.PrivatePgp.importKey(from: armorPrivateKey ?? "")
112+
try KeyFileManager.PublicPGP.importKey(from: armorPublicKey ?? "")
113+
try KeyFileManager.PrivatePGP.importKey(from: armorPrivateKey ?? "")
114114
}
115115

116116
func saveImportedKeys() {

pass/Controllers/PGPKeyFIleImportTableViewController.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,8 @@ extension PGPKeyFileImportTableViewController: PGPKeyImporter {
8888
guard let publicKey = publicKey, let privateKey = privateKey else {
8989
return
9090
}
91-
try KeyFileManager.PublicPgp.importKey(from: publicKey)
92-
try KeyFileManager.PrivatePgp.importKey(from: privateKey)
91+
try KeyFileManager.PublicPGP.importKey(from: publicKey)
92+
try KeyFileManager.PrivatePGP.importKey(from: privateKey)
9393
}
9494

9595
func doAfterImport() {

0 commit comments

Comments
 (0)