Enable SwiftLint rule 'empty_string' and fix all violations

This commit is contained in:
Danny Moesch 2020-07-04 22:28:40 +02:00 committed by Mingshen Sun
parent bb9e85ddc8
commit 2dcc72722b
4 changed files with 5 additions and 5 deletions

View file

@ -42,7 +42,7 @@ whitelist_rules:
- empty_enum_arguments - empty_enum_arguments
- empty_parameters - empty_parameters
- empty_parentheses_with_trailing_closure - empty_parentheses_with_trailing_closure
# - empty_string - empty_string
# - empty_xctest_method # - empty_xctest_method
- enum_case_associated_values_count - enum_case_associated_values_count
- expiring_todo - expiring_todo

View file

@ -315,7 +315,7 @@ class PasswordEditorTableViewController: UITableViewController {
private func insertScannedOTPFields(_ otpauth: String) { private func insertScannedOTPFields(_ otpauth: String) {
// update tableData // update tableData
var additionsString = "" 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 additionsString = additionsPlainText + "\n" + otpauth
} else { } else {
additionsString = otpauth additionsString = otpauth

View file

@ -580,7 +580,7 @@ class PasswordsViewController: UIViewController, UITableViewDataSource, UITableV
func filterContentForSearchText(searchText: String, scope: SearchBarScope = .all) { func filterContentForSearchText(searchText: String, scope: SearchBarScope = .all) {
var entries: [PasswordTableEntry] = scope == .all ? passwordsTableAllEntries : passwordsTableEntries 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) } entries = entries.filter { $0.match(searchText) }
} }
reloadTableView(data: entries) reloadTableView(data: entries)

View file

@ -43,7 +43,7 @@ class LabelTableViewCell: UITableViewCell {
if isReveal { if isReveal {
contentLabel.attributedText = Utils.attributedPassword(plainPassword: content) contentLabel.attributedText = Utils.attributedPassword(plainPassword: content)
} else { } else {
if content == "" { if content.isEmpty {
contentLabel.text = "" contentLabel.text = ""
} else { } else {
contentLabel.text = Globals.passwordDots contentLabel.text = Globals.passwordDots
@ -163,7 +163,7 @@ class LabelTableViewCell: UITableViewCell {
switch type { switch type {
case .password: case .password:
if let content = cellData?.content, content != "" { if let content = cellData?.content, !content.isEmpty {
// password button // password button
passwordDisplayButton = UIButton(type: .system) passwordDisplayButton = UIButton(type: .system)
passwordDisplayButton!.frame = CGRect(x: 0, y: 0, width: width, height: height) passwordDisplayButton!.frame = CGRect(x: 0, y: 0, width: width, height: height)