Skip to content

Commit 32b7c9b

Browse files
authored
Some cleanup especially regarding method references (#516)
* Remove superfluous method arguments in method references * Use 'Self' for internal static access * Convert static to instance field in singleton class * Remove class name prefix in references to local methods * Remove nested frameworks in all extensions and frameworks
1 parent e1cbcb5 commit 32b7c9b

18 files changed

+57
-57
lines changed

pass.xcodeproj/project.pbxproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1463,7 +1463,7 @@
14631463
);
14641464
runOnlyForDeploymentPostprocessing = 0;
14651465
shellPath = /bin/sh;
1466-
shellScript = "# Type a script or drag a script file from your workspace to insert its path.\nset -xe\nrm -rf ${BUILT_PRODUCTS_DIR}/passKit.framework/Frameworks\nfind -L ${BUILT_PRODUCTS_DIR}/OneTimePassword_*.framework -type d -name \"Frameworks\" | xargs rm -rf\nfind -L ${BUILT_PRODUCTS_DIR}/passAutoFillExtension.appex -type d -name \"Frameworks\" | xargs rm -rf\nfind -L ${BUILT_PRODUCTS_DIR}/passShortcuts.appex -type d -name \"Frameworks\" | xargs rm -rf\n\n";
1466+
shellScript = "set -xe\n\nfind -L \"${BUILT_PRODUCTS_DIR}\" -type d -path \"*.appex/Frameworks\" -o -path \"*.framework/Frameworks\" -maxdepth 2 | xargs rm -rf\n";
14671467
};
14681468
/* End PBXShellScriptBuildPhase section */
14691469

pass/Controllers/AboutRepositoryTableViewController.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ class AboutRepositoryTableViewController: BasicStaticTableViewController {
100100
if let numberOfCommits = passwordStore.numberOfCommits {
101101
return String(numberOfCommits)
102102
}
103-
return AboutRepositoryTableViewController.VALUE_NOT_AVAILABLE
103+
return Self.VALUE_NOT_AVAILABLE
104104
}
105105

106106
@objc

pass/Controllers/AdvancedSettingsTableViewController.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class AdvancedSettingsTableViewController: UITableViewController {
2121
let uiSwitch = UISwitch()
2222
uiSwitch.onTintColor = Colors.systemBlue
2323
uiSwitch.sizeToFit()
24-
uiSwitch.addTarget(self, action: #selector(encryptInASCIIArmoredAction(_:)), for: UIControl.Event.valueChanged)
24+
uiSwitch.addTarget(self, action: #selector(encryptInASCIIArmoredAction), for: UIControl.Event.valueChanged)
2525
return uiSwitch
2626
}()
2727

pass/Controllers/GeneralSettingsTableViewController.swift

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,31 +16,31 @@ class GeneralSettingsTableViewController: BasicStaticTableViewController {
1616
let uiSwitch = UISwitch()
1717
uiSwitch.onTintColor = Colors.systemBlue
1818
uiSwitch.sizeToFit()
19-
uiSwitch.addTarget(self, action: #selector(hideUnknownSwitchAction(_:)), for: UIControl.Event.valueChanged)
19+
uiSwitch.addTarget(self, action: #selector(hideUnknownSwitchAction), for: UIControl.Event.valueChanged)
2020
return uiSwitch
2121
}()
2222

2323
let hideOTPSwitch: UISwitch = {
2424
let uiSwitch = UISwitch()
2525
uiSwitch.onTintColor = Colors.systemBlue
2626
uiSwitch.sizeToFit()
27-
uiSwitch.addTarget(self, action: #selector(hideOTPSwitchAction(_:)), for: UIControl.Event.valueChanged)
27+
uiSwitch.addTarget(self, action: #selector(hideOTPSwitchAction), for: UIControl.Event.valueChanged)
2828
return uiSwitch
2929
}()
3030

3131
let autoCopyOTPSwitch: UISwitch = {
3232
let uiSwitch = UISwitch()
3333
uiSwitch.onTintColor = Colors.systemBlue
3434
uiSwitch.sizeToFit()
35-
uiSwitch.addTarget(self, action: #selector(autoCopyOTPSwitchAction(_:)), for: UIControl.Event.valueChanged)
35+
uiSwitch.addTarget(self, action: #selector(autoCopyOTPSwitchAction), for: UIControl.Event.valueChanged)
3636
return uiSwitch
3737
}()
3838

3939
let rememberPGPPassphraseSwitch: UISwitch = {
4040
let uiSwitch = UISwitch()
4141
uiSwitch.onTintColor = Colors.systemBlue
4242
uiSwitch.sizeToFit()
43-
uiSwitch.addTarget(self, action: #selector(rememberPGPPassphraseSwitchAction(_:)), for: UIControl.Event.valueChanged)
43+
uiSwitch.addTarget(self, action: #selector(rememberPGPPassphraseSwitchAction), for: UIControl.Event.valueChanged)
4444
uiSwitch.isOn = Defaults.isRememberPGPPassphraseOn
4545
return uiSwitch
4646
}()
@@ -49,7 +49,7 @@ class GeneralSettingsTableViewController: BasicStaticTableViewController {
4949
let uiSwitch = UISwitch()
5050
uiSwitch.onTintColor = Colors.systemBlue
5151
uiSwitch.sizeToFit()
52-
uiSwitch.addTarget(self, action: #selector(rememberGitCredentialPassphraseSwitchAction(_:)), for: UIControl.Event.valueChanged)
52+
uiSwitch.addTarget(self, action: #selector(rememberGitCredentialPassphraseSwitchAction), for: UIControl.Event.valueChanged)
5353
uiSwitch.isOn = Defaults.isRememberGitCredentialPassphraseOn
5454
return uiSwitch
5555
}()
@@ -58,7 +58,7 @@ class GeneralSettingsTableViewController: BasicStaticTableViewController {
5858
let uiSwitch = UISwitch()
5959
uiSwitch.onTintColor = Colors.systemBlue
6060
uiSwitch.sizeToFit()
61-
uiSwitch.addTarget(self, action: #selector(enableGPGIDSwitchAction(_:)), for: UIControl.Event.valueChanged)
61+
uiSwitch.addTarget(self, action: #selector(enableGPGIDSwitchAction), for: UIControl.Event.valueChanged)
6262
uiSwitch.isOn = Defaults.isEnableGPGIDOn
6363
return uiSwitch
6464
}()
@@ -67,7 +67,7 @@ class GeneralSettingsTableViewController: BasicStaticTableViewController {
6767
let uiSwitch = UISwitch()
6868
uiSwitch.onTintColor = Colors.systemBlue
6969
uiSwitch.sizeToFit()
70-
uiSwitch.addTarget(self, action: #selector(showFolderSwitchAction(_:)), for: UIControl.Event.valueChanged)
70+
uiSwitch.addTarget(self, action: #selector(showFolderSwitchAction), for: UIControl.Event.valueChanged)
7171
uiSwitch.isOn = Defaults.isShowFolderOn
7272
return uiSwitch
7373
}()
@@ -76,7 +76,7 @@ class GeneralSettingsTableViewController: BasicStaticTableViewController {
7676
let uiSwitch = UISwitch()
7777
uiSwitch.onTintColor = Colors.systemBlue
7878
uiSwitch.sizeToFit()
79-
uiSwitch.addTarget(self, action: #selector(hidePasswordImagesSwitchAction(_:)), for: UIControl.Event.valueChanged)
79+
uiSwitch.addTarget(self, action: #selector(hidePasswordImagesSwitchAction), for: UIControl.Event.valueChanged)
8080
uiSwitch.isOn = Defaults.isHidePasswordImagesOn
8181
return uiSwitch
8282
}()

pass/Controllers/OpenSourceComponentsTableViewController.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ class OpenSourceComponentsTableViewController: BasicStaticTableViewController {
6868
.action: "link",
6969
.link: item[1],
7070
.accessoryType: UITableViewCell.AccessoryType.detailDisclosureButton,
71-
.detailDisclosureAction: #selector(actOnDetailDisclosureButton(_:)),
71+
.detailDisclosureAction: #selector(actOnDetailDisclosureButton),
7272
.detailDisclosureData: item[2],
7373
]
7474
)

pass/Controllers/PasswordDetailTableViewController.swift

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class PasswordDetailTableViewController: UITableViewController, UIGestureRecogni
2121
private let keychain = AppKeychain.shared
2222

2323
private lazy var editUIBarButtonItem: UIBarButtonItem = {
24-
let uiBarButtonItem = UIBarButtonItem(barButtonSystemItem: .edit, target: self, action: #selector(pressEdit(_:)))
24+
let uiBarButtonItem = UIBarButtonItem(barButtonSystemItem: .edit, target: self, action: #selector(pressEdit))
2525
return uiBarButtonItem
2626
}()
2727

@@ -47,7 +47,7 @@ class PasswordDetailTableViewController: UITableViewController, UIGestureRecogni
4747
tableView.register(UINib(nibName: "LabelTableViewCell", bundle: nil), forCellReuseIdentifier: "labelCell")
4848
tableView.register(UINib(nibName: "PasswordDetailTitleTableViewCell", bundle: nil), forCellReuseIdentifier: "passwordDetailTitleTableViewCell")
4949

50-
let tapGesture = UITapGestureRecognizer(target: self, action: #selector(PasswordDetailTableViewController.tapMenu(recognizer:)))
50+
let tapGesture = UITapGestureRecognizer(target: self, action: #selector(tapMenu))
5151
tapGesture.cancelsTouchesInView = false
5252
tableView.addGestureRecognizer(tapGesture)
5353
tapGesture.delegate = self
@@ -326,10 +326,10 @@ class PasswordDetailTableViewController: UITableViewController, UIGestureRecogni
326326
if let tappedCell = tableView.cellForRow(at: tapIndexPath) as? LabelTableViewCell {
327327
tappedCell.becomeFirstResponder()
328328
let menuController = UIMenuController.shared
329-
let revealItem = UIMenuItem(title: "Reveal".localize(), action: #selector(LabelTableViewCell.revealPassword(_:)))
330-
let concealItem = UIMenuItem(title: "Conceal".localize(), action: #selector(LabelTableViewCell.concealPassword(_:)))
331-
let nextHOTPItem = UIMenuItem(title: "NextPassword".localize(), action: #selector(LabelTableViewCell.getNextHOTP(_:)))
332-
let openURLItem = UIMenuItem(title: "CopyAndOpen".localize(), action: #selector(LabelTableViewCell.openLink(_:)))
329+
let revealItem = UIMenuItem(title: "Reveal".localize(), action: #selector(LabelTableViewCell.revealPassword))
330+
let concealItem = UIMenuItem(title: "Conceal".localize(), action: #selector(LabelTableViewCell.concealPassword))
331+
let nextHOTPItem = UIMenuItem(title: "NextPassword".localize(), action: #selector(LabelTableViewCell.getNextHOTP))
332+
let openURLItem = UIMenuItem(title: "CopyAndOpen".localize(), action: #selector(LabelTableViewCell.openLink))
333333
menuController.menuItems = [revealItem, concealItem, nextHOTPItem, openURLItem]
334334
menuController.setTargetRect(tappedCell.contentLabel.frame, in: tappedCell.contentLabel.superview!)
335335
menuController.setMenuVisible(true, animated: true)
@@ -490,7 +490,7 @@ class PasswordDetailTableViewController: UITableViewController, UIGestureRecogni
490490
let section = tableData[indexPath.section]
491491
switch section.type {
492492
case .addition, .main:
493-
return action == #selector(UIResponderStandardEditActions.copy(_:))
493+
return action == #selector(UIResponderStandardEditActions.copy)
494494
default:
495495
return false
496496
}

pass/Controllers/PasswordNavigationViewController.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,10 @@ class PasswordNavigationViewController: UIViewController {
5656
let addPasswordButton = UIButton(type: .system)
5757
let plusImage = UIImage(systemName: "plus.circle", withConfiguration: UIImage.SymbolConfiguration(weight: .regular))
5858
addPasswordButton.setImage(plusImage, for: .normal)
59-
addPasswordButton.addTarget(self, action: #selector(self.addPasswordAction(_:)), for: .touchDown)
59+
addPasswordButton.addTarget(self, action: #selector(self.addPasswordAction), for: .touchDown)
6060
addPasswordUIBarButtonItem.customView = addPasswordButton
6161
} else {
62-
addPasswordUIBarButtonItem = UIBarButtonItem(barButtonSystemItem: .add, target: self, action: #selector(self.addPasswordAction(_:)))
62+
addPasswordUIBarButtonItem = UIBarButtonItem(barButtonSystemItem: .add, target: self, action: #selector(self.addPasswordAction))
6363
}
6464
return addPasswordUIBarButtonItem
6565
}()

pass/Controllers/SettingsTableViewController.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ class SettingsTableViewController: UITableViewController, UITabBarControllerDele
6666

6767
override func viewDidLoad() {
6868
super.viewDidLoad()
69-
NotificationCenter.default.addObserver(self, selector: #selector(SettingsTableViewController.actOnPasswordStoreErasedNotification), name: .passwordStoreErased, object: nil)
69+
NotificationCenter.default.addObserver(self, selector: #selector(actOnPasswordStoreErasedNotification), name: .passwordStoreErased, object: nil)
7070
passwordRepositoryTableViewCell.detailTextLabel?.text = Defaults.gitURL.host
7171
setPGPKeyTableViewCellDetailText()
7272
setPasscodeLockCell()
@@ -243,12 +243,12 @@ class SettingsTableViewController: UITableViewController, UITabBarControllerDele
243243
setPasscodeLockAlert?.addTextField { textField -> Void in
244244
textField.placeholder = "Passcode".localize()
245245
textField.isSecureTextEntry = true
246-
textField.addTarget(self, action: #selector(self.alertTextFieldDidChange(_:)), for: UIControl.Event.editingChanged)
246+
textField.addTarget(self, action: #selector(self.alertTextFieldDidChange), for: UIControl.Event.editingChanged)
247247
}
248248
setPasscodeLockAlert?.addTextField { textField -> Void in
249249
textField.placeholder = "PasswordConfirmation".localize()
250250
textField.isSecureTextEntry = true
251-
textField.addTarget(self, action: #selector(self.alertTextFieldDidChange(_:)), for: UIControl.Event.editingChanged)
251+
textField.addTarget(self, action: #selector(self.alertTextFieldDidChange), for: UIControl.Event.editingChanged)
252252
}
253253

254254
// save action

pass/Views/LabelTableViewCell.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -80,16 +80,16 @@ class LabelTableViewCell: UITableViewCell {
8080
switch type {
8181
case .password:
8282
if isReveal {
83-
return action == #selector(copy(_:)) || action == #selector(concealPassword(_:))
83+
return action == #selector(copy(_:)) || action == #selector(concealPassword)
8484
}
85-
return action == #selector(copy(_:)) || action == #selector(revealPassword(_:))
85+
return action == #selector(copy(_:)) || action == #selector(revealPassword)
8686
case .URL:
87-
return action == #selector(copy(_:)) || action == #selector(openLink(_:))
87+
return action == #selector(copy(_:)) || action == #selector(openLink)
8888
case .HOTP:
8989
if isReveal {
90-
return action == #selector(copy(_:)) || action == #selector(concealPassword(_:)) || action == #selector(getNextHOTP(_:))
90+
return action == #selector(copy(_:)) || action == #selector(concealPassword) || action == #selector(getNextHOTP)
9191
}
92-
return action == #selector(copy(_:)) || action == #selector(revealPassword(_:)) || action == #selector(getNextHOTP(_:))
92+
return action == #selector(copy(_:)) || action == #selector(revealPassword) || action == #selector(getNextHOTP)
9393
default:
9494
return action == #selector(copy(_:))
9595
}

pass/Views/UICodeHighlightingLabel.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,13 @@ class UICodeHighlightingLabel: UILocalizedLabel {
3131
let formattedText = text.splitByNewline()
3232
.map { line -> NSAttributedString in
3333
if line.starts(with: " ") {
34-
return NSAttributedString(string: line, attributes: UICodeHighlightingLabel.CODE_ATTRIBUTES)
34+
return NSAttributedString(string: line, attributes: Self.CODE_ATTRIBUTES)
3535
}
3636
return NSAttributedString(string: line)
3737
}
3838
.reduce(into: NSMutableAttributedString(string: "")) {
3939
$0.append($1)
40-
$0.append(UICodeHighlightingLabel.ATTRIBUTED_NEWLINE)
40+
$0.append(Self.ATTRIBUTED_NEWLINE)
4141
}
4242
formattedText.deleteCharacters(in: NSRange(location: formattedText.length - 1, length: 1))
4343
return formattedText

0 commit comments

Comments
 (0)