Merge pull request #1992 from AlphaWallet/replace-unnecessary_-vars-with-proper-nil-checks

Refactor: replace `if let _ = <something>` with `if <something> != nil`
pull/1998/head
James Sangalli 4 years ago committed by GitHub
commit c39e116bf2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 8
      AlphaWallet/Core/Initializers/MigrationInitializer.swift
  2. 2
      AlphaWallet/TokenScriptClient/Models/AssetAttribute.swift
  3. 2
      AlphaWallet/Transactions/Views/TransactionsEmptyView.swift
  4. 2
      AlphaWallet/Transfer/ViewControllers/SendViewController.swift
  5. 2
      AlphaWallet/UI/EmptyView.swift
  6. 2
      AlphaWallet/UI/FloatLabelCell.swift
  7. 2
      AlphaWallet/UI/Views/AmountTextField.swift

@ -20,7 +20,7 @@ class MigrationInitializer: Initializer {
if oldSchemaVersion < 2 {
//Fix bug created during multi-chain implementation. Where TokenObject instances are created from transfer Transaction instances, with the primaryKey as a empty string; so instead of updating an existing TokenObject, a duplicate TokenObject instead was created but with primaryKey empty
migration.enumerateObjects(ofType: TokenObject.className()) { oldObject, newObject in
guard let _ = oldObject else { return }
guard oldObject != nil else { return }
guard let newObject = newObject else { return }
if let primaryKey = newObject["primaryKey"] as? String, primaryKey.isEmpty {
migration.delete(newObject)
@ -30,9 +30,9 @@ class MigrationInitializer: Initializer {
}
if oldSchemaVersion < 3 {
migration.enumerateObjects(ofType: Transaction.className()) { oldObject, newObject in
guard let _ = oldObject else { return }
guard oldObject != nil else { return }
guard let newObject = newObject else { return }
newObject["isERC20Interaction"] = false
newObject["isERC20Interaction"] = false
}
}
if oldSchemaVersion < 4 {
@ -55,7 +55,7 @@ class MigrationInitializer: Initializer {
}
if oldSchemaVersion < 6 {
migration.enumerateObjects(ofType: TokenObject.className()) { oldObject, newObject in
guard let _ = oldObject else { return }
guard oldObject != nil else { return }
guard let newObject = newObject else { return }
newObject["shouldDisplay"] = true

@ -102,7 +102,7 @@ struct AssetAttribute {
let eventContractName = ethereumEventElement["contract"],
let eventSourceContractElement = XMLHandler.getContractElementByName(contractName: eventContractName, fromRoot: root, xmlContext: xmlContext),
let asnModuleElement = XMLHandler.getAsnModuleElement(fromRoot: root, xmlContext: xmlContext, forTypeName: eventName),
let _ = attribute["name"] {
attribute["name"] != nil {
originFound = Origin(forEthereumEventElement: ethereumEventElement, asnModuleElement: asnModuleElement, sourceContractElement: eventSourceContractElement, xmlContext: xmlContext)
}

@ -42,7 +42,7 @@ class TransactionsEmptyView: UIView {
].asStackView(axis: .vertical, spacing: 30, alignment: .center)
stackView.translatesAutoresizingMaskIntoConstraints = false
if let _ = onRetry {
if onRetry != nil {
stackView.addArrangedSubview(button)
}

@ -454,7 +454,7 @@ extension SendViewController: AmountTextFieldDelegate {
textField.statusLabel.text = viewModel.availableLabelText
textField.availableTextHidden = viewModel.availableTextHidden
guard let _ = viewModel.validatedAmount(value: textField.ethCost, checkIfGreaterThenZero: false) else {
guard viewModel.validatedAmount(value: textField.ethCost, checkIfGreaterThenZero: false) != nil else {
textField.errorState = .error
return
}

@ -43,7 +43,7 @@ class EmptyView: UIView {
].asStackView(axis: .vertical, spacing: 30, alignment: .center)
stackView.translatesAutoresizingMaskIntoConstraints = false
if let _ = onRetry {
if onRetry != nil {
stackView.addArrangedSubview(button)
}

@ -126,7 +126,7 @@ public class _FloatLabelCell<T>: Cell<T>, UITextFieldDelegate, TextFieldCell whe
public func textFieldDidBeginEditing(_ textField: UITextField) {
formViewController()?.beginEditing(of: self)
if let fieldRowConformance = row as? FormatterConformance, let _ = fieldRowConformance.formatter, fieldRowConformance.useFormatterOnDidBeginEditing ?? fieldRowConformance.useFormatterDuringInput {
if let fieldRowConformance = row as? FormatterConformance, fieldRowConformance.formatter != nil, fieldRowConformance.useFormatterOnDidBeginEditing ?? fieldRowConformance.useFormatterDuringInput {
textField.text = displayValue(useFormatter: true)
} else {
textField.text = displayValue(useFormatter: false)

@ -147,7 +147,7 @@ class AmountTextField: UIControl {
var cryptoToDollarRate: Double? = nil {
didSet {
if let _ = cryptoToDollarRate {
if cryptoToDollarRate != nil {
updateAlternatePricingDisplay()
}
updateFiatButtonTitle()

Loading…
Cancel
Save