From 2dcc72722be2e6254f9831bd323cbb086c2d8d9d Mon Sep 17 00:00:00 2001 From: Danny Moesch Date: Sat, 4 Jul 2020 22:28:40 +0200 Subject: [PATCH] Enable SwiftLint rule 'empty_string' and fix all violations --- .swiftlint.yml | 2 +- pass/Controllers/PasswordEditorTableViewController.swift | 2 +- pass/Controllers/PasswordsViewController.swift | 2 +- pass/Views/LabelTableViewCell.swift | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.swiftlint.yml b/.swiftlint.yml index e162c7a..bf650ac 100644 --- a/.swiftlint.yml +++ b/.swiftlint.yml @@ -42,7 +42,7 @@ whitelist_rules: - empty_enum_arguments - empty_parameters - empty_parentheses_with_trailing_closure -# - empty_string + - empty_string # - empty_xctest_method - enum_case_associated_values_count - expiring_todo diff --git a/pass/Controllers/PasswordEditorTableViewController.swift b/pass/Controllers/PasswordEditorTableViewController.swift index a726ca1..d0aad9d 100644 --- a/pass/Controllers/PasswordEditorTableViewController.swift +++ b/pass/Controllers/PasswordEditorTableViewController.swift @@ -315,7 +315,7 @@ class PasswordEditorTableViewController: UITableViewController { private func insertScannedOTPFields(_ otpauth: String) { // update tableData var additionsString = "" - if let additionsPlainText = (tableData[additionsSection][0][PasswordEditorCellKey.content] as? String)?.trimmed, additionsPlainText != "" { + if let additionsPlainText = (tableData[additionsSection][0][PasswordEditorCellKey.content] as? String)?.trimmed, !additionsPlainText.isEmpty { additionsString = additionsPlainText + "\n" + otpauth } else { additionsString = otpauth diff --git a/pass/Controllers/PasswordsViewController.swift b/pass/Controllers/PasswordsViewController.swift index 7221d53..3249f28 100644 --- a/pass/Controllers/PasswordsViewController.swift +++ b/pass/Controllers/PasswordsViewController.swift @@ -580,7 +580,7 @@ class PasswordsViewController: UIViewController, UITableViewDataSource, UITableV func filterContentForSearchText(searchText: String, scope: SearchBarScope = .all) { var entries: [PasswordTableEntry] = scope == .all ? passwordsTableAllEntries : passwordsTableEntries - if searchController.isActive, searchController.searchBar.text != "" { + if searchController.isActive, let searchBarText = searchController.searchBar.text, !searchBarText.isEmpty { entries = entries.filter { $0.match(searchText) } } reloadTableView(data: entries) diff --git a/pass/Views/LabelTableViewCell.swift b/pass/Views/LabelTableViewCell.swift index 972349b..5ffeba2 100644 --- a/pass/Views/LabelTableViewCell.swift +++ b/pass/Views/LabelTableViewCell.swift @@ -43,7 +43,7 @@ class LabelTableViewCell: UITableViewCell { if isReveal { contentLabel.attributedText = Utils.attributedPassword(plainPassword: content) } else { - if content == "" { + if content.isEmpty { contentLabel.text = "" } else { contentLabel.text = Globals.passwordDots @@ -163,7 +163,7 @@ class LabelTableViewCell: UITableViewCell { switch type { case .password: - if let content = cellData?.content, content != "" { + if let content = cellData?.content, !content.isEmpty { // password button passwordDisplayButton = UIButton(type: .system) passwordDisplayButton!.frame = CGRect(x: 0, y: 0, width: width, height: height)