Fix Swiftlint warnings

pull/2221/head
Hwee-Boon Yar 4 years ago
parent 24a1b42dd7
commit ab5eb4af76
  1. 4
      AlphaWallet/Activities/Coordinators/ActivitiesCoordinator.swift
  2. 16
      AlphaWallet/Activities/ViewModels/DefaultActivityCellViewModel.swift
  3. 2
      AlphaWallet/AppDelegate.swift
  4. 2
      AlphaWallet/TokenScriptClient/Models/SolidityType.swift
  5. 2
      AlphaWallet/TokenScriptClient/Models/TokenScriptFilterParser.swift
  6. 2
      AlphaWallet/TokenScriptClient/Models/XMLHandler.swift
  7. 3
      AlphaWallet/Tokens/Helpers/CallSmartContractFunction.swift
  8. 4
      AlphaWallet/Tokens/Models/WalletFilter.swift
  9. 1
      AlphaWallet/Tokens/ViewControllers/TokenInstanceActionViewController.swift
  10. 2
      AlphaWallet/Transactions/Coordinators/TokensCardCoordinator.swift
  11. 2
      AlphaWallet/Transfer/Controllers/ConfirmationTransitionController.swift
  12. 2
      AlphaWallet/Transfer/Controllers/TransactionConfigurator.swift
  13. 1
      AlphaWallet/UI/TokenImageView.swift
  14. 1
      AlphaWallet/Wallet/ViewControllers/CreateInitialWalletViewController.swift

@ -22,7 +22,7 @@ class ActivitiesCoordinator: Coordinator {
private var activities: [Activity] = .init()
private var transactions: [Transaction] = .init()
private var tokensAndTokenHolders: [AlphaWallet.Address: (tokenObject: TokenObject, tokenHolders: [TokenHolder])] = .init()
weak private var activityViewController: ActivityViewController?
weak private var activityViewController: ActivityViewController?
private var rateLimitedUpdater: RateLimiter?
private var rateLimitedViewControllerReloader: RateLimiter?
private var hasLoadedActivitiesTheFirstTime = false
@ -121,7 +121,7 @@ class ActivitiesCoordinator: Coordinator {
let eachServer = each.server
let xmlHandler = XMLHandler(token: each, assetDefinitionStore: assetDefinitionStore)
guard xmlHandler.hasAssetDefinition else { return nil }
guard (xmlHandler.server?.matches(server: eachServer) ?? false) else { return nil }
guard xmlHandler.server?.matches(server: eachServer) ?? false else { return nil }
return (contract: eachContract, server: eachServer, xmlHandler: xmlHandler)
}

@ -31,23 +31,23 @@ struct DefaultActivityCellViewModel {
switch activity.nativeViewType {
case .erc20Sent, .erc721Sent, .nativeCryptoSent:
let string = NSMutableAttributedString(string: "\(R.string.localizable.transactionCellSentTitle()) \(symbol)")
string.addAttribute(.font, value: Fonts.regular(size: 17)! , range: NSRange(location: 0, length: string.length))
string.addAttribute(.font, value: Fonts.semibold(size: 17)! , range: NSRange(location: string.length - symbol.count, length: symbol.count))
string.addAttribute(.font, value: Fonts.regular(size: 17)!, range: NSRange(location: 0, length: string.length))
string.addAttribute(.font, value: Fonts.semibold(size: 17)!, range: NSRange(location: string.length - symbol.count, length: symbol.count))
return string
case .erc20Received, .erc721Received, .nativeCryptoReceived:
let string = NSMutableAttributedString(string: "\(R.string.localizable.transactionCellReceivedTitle()) \(symbol)")
string.addAttribute(.font, value: Fonts.regular(size: 17)! , range: NSRange(location: 0, length: string.length))
string.addAttribute(.font, value: Fonts.semibold(size: 17)! , range: NSRange(location: string.length - symbol.count, length: symbol.count))
string.addAttribute(.font, value: Fonts.regular(size: 17)!, range: NSRange(location: 0, length: string.length))
string.addAttribute(.font, value: Fonts.semibold(size: 17)!, range: NSRange(location: string.length - symbol.count, length: symbol.count))
return string
case .erc20OwnerApproved, .erc721OwnerApproved:
let string = NSMutableAttributedString(string: R.string.localizable.activityOwnerApproved(symbol))
string.addAttribute(.font, value: Fonts.regular(size: 17)! , range: NSRange(location: 0, length: string.length))
string.addAttribute(.font, value: Fonts.semibold(size: 17)! , range: NSRange(location: string.length - symbol.count, length: symbol.count))
string.addAttribute(.font, value: Fonts.regular(size: 17)!, range: NSRange(location: 0, length: string.length))
string.addAttribute(.font, value: Fonts.semibold(size: 17)!, range: NSRange(location: string.length - symbol.count, length: symbol.count))
return string
case .erc20ApprovalObtained, .erc721ApprovalObtained:
let string = NSMutableAttributedString(string: R.string.localizable.activityApprovalObtained(symbol))
string.addAttribute(.font, value: Fonts.regular(size: 17)! , range: NSRange(location: 0, length: string.length))
string.addAttribute(.font, value: Fonts.semibold(size: 17)! , range: NSRange(location: string.length - symbol.count, length: symbol.count))
string.addAttribute(.font, value: Fonts.regular(size: 17)!, range: NSRange(location: 0, length: string.length))
string.addAttribute(.font, value: Fonts.semibold(size: 17)!, range: NSRange(location: string.length - symbol.count, length: symbol.count))
return string
case .none:
return .init()

@ -43,7 +43,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UISplitViewControllerDele
return true
}
func application(_ application: UIApplication, performActionFor shortcutItem: UIApplicationShortcutItem, completionHandler: @escaping (Bool) -> ()) {
func application(_ application: UIApplication, performActionFor shortcutItem: UIApplicationShortcutItem, completionHandler: @escaping (Bool) -> Void) {
if shortcutItem.type == Constants.launchShortcutKey {
appCoordinator.launchUniversalScanner()
}

@ -29,7 +29,7 @@ enum SolidityType: String {
return nil
case .string:
return coerceAsString(originalValue)
case .int, .int8, .int16, .int24, .int32, .int40, .int48, .int56, .int64, .int72, .int80, .int88, .int96, .int104, .int112, .int120, .int128, .int136, .int144, .int152, .int160, .int168, .int176, .int184, .int192, .int200, .int208, .int216, .int224, .int232, .int240, .int248, .int256:
case .int, .int8, .int16, .int24, .int32, .int40, .int48, .int56, .int64, .int72, .int80, .int88, .int96, .int104, .int112, .int120, .int128, .int136, .int144, .int152, .int160, .int168, .int176, .int184, .int192, .int200, .int208, .int216, .int224, .int232, .int240, .int248, .int256:
return coerceAsInt(originalValue)
case .void:
return nil

@ -194,7 +194,7 @@ struct TokenScriptFilterParser {
var buffer: [Character] = []
var escapeBuffer: [Character]? = nil
var wasPreviousEscapedCharacter = false
for (_, c) in expression.enumerated() {
for c in expression {
let previous = buffer.last.flatMap { String($0) }
if c == escape && escapeBuffer == nil {
//start new escape

@ -1,4 +1,3 @@
//
// XMLHandler.swift
// AlphaWallet
//
@ -425,7 +424,6 @@ private class PrivateXMLHandler {
)
}
func resolveAttributesBypassingCache(withTokenIdOrEvent tokenIdOrEvent: TokenIdOrEvent, server: RPCServer, account: Wallet) -> [AttributeId: AssetAttributeSyntaxValue] {
fields.resolve(withTokenIdOrEvent: tokenIdOrEvent, userEntryValues: .init(), server: server, account: account, additionalValues: .init(), localRefs: .init())
}

@ -7,9 +7,10 @@ import web3swift
//TODO time to wrap `callSmartContract` with a class
//TODO wrap callSmartContract() and cache into a type
// swiftlint:disable private_over_fileprivate
fileprivate var smartContractCallsCache = [String: (promise: Promise<[String: Any]>, timestamp: Date)]()
fileprivate var web3s = [RPCServer: [TimeInterval: web3]]()
// swiftlint:enable private_over_fileprivate
func getCachedWeb3(forServer server: RPCServer, timeout: TimeInterval) throws -> web3 {
if let result = web3s[server]?[timeout] {

@ -25,8 +25,8 @@ func == (lhs: WalletFilter, rhs: WalletFilter) -> Bool {
return keyword1 == keyword2
case (.keyword, .all), (.keyword, .currencyOnly), (.keyword, .assetsOnly), (.keyword, .collectiblesOnly), (.collectiblesOnly, .all), (.collectiblesOnly, .currencyOnly), (.collectiblesOnly, .assetsOnly), (.collectiblesOnly, .keyword), (.assetsOnly, .all), (.assetsOnly, .currencyOnly), (.assetsOnly, .collectiblesOnly), (.assetsOnly, .keyword), (.currencyOnly, .all), (.currencyOnly, .assetsOnly), (.currencyOnly, .collectiblesOnly), (.currencyOnly, .keyword), (.all, .currencyOnly), (.all, .assetsOnly), (.all, .collectiblesOnly), (.all, .keyword):
return false
case (.type(_), _), (_, .type(_)):
case (.type, _), (_, .type):
return true
}
}
}

@ -28,7 +28,6 @@ class TokenInstanceActionViewController: UIViewController, TokenVerifiableStatus
return webView
}()
//TODO might have to change the number of buttons? if the action type change or should we just go back since the flow may be broken if we remain in this screen
private let buttonsBar = ButtonsBar(configuration: .green(buttons: 1))
private var isFungible: Bool {

@ -17,6 +17,7 @@ protocol TokensCardCoordinatorDelegate: class, CanOpenURL {
func didPostTokenScriptTransaction(_ transaction: SentTransaction, in coordinator: TokensCardCoordinator)
}
// swiftlint:disable type_body_length
class TokensCardCoordinator: NSObject, Coordinator {
private let keystore: Keystore
private let token: TokenObject
@ -427,6 +428,7 @@ class TokensCardCoordinator: NSObject, Coordinator {
viewController.navigationController?.pushViewController(vc, animated: true)
}
}
// swiftlint:enable type_body_length
extension TokensCardCoordinator: TokensCardViewControllerDelegate {
func didPressRedeem(token: TokenObject, tokenHolder: TokenHolder, in viewController: TokensCardViewController) {

@ -24,7 +24,7 @@ extension UINavigationController: UpdatablePreferredContentSizeContainer {
class ConfirmationTransitionController: NSObject {
//NOTE: Need to retain self until dismissal because UIKit won't.
private var selfRetainer: ConfirmationTransitionController? = nil
private var selfRetainer: ConfirmationTransitionController?
private let sourceViewController: UIViewController
private let destinationViewController: UIViewController
private let presenter = Presenter()

@ -87,7 +87,7 @@ class TransactionConfigurator {
switch transaction.transferType {
case .nativeCryptocurrency, .dapp, .ERC875TokenOrder: return transaction.value
case .ERC20Token, .ERC721Token, .ERC721ForTicketToken, .ERC875Token:
return 0;
return 0
}
}()
let request = EstimateGasRequest(

@ -38,7 +38,6 @@ class TokenImageView: UIView {
}
}
override init(frame: CGRect) {
super.init(frame: frame)

@ -20,7 +20,6 @@ class CreateInitialWalletViewController: UIViewController {
private let haveWalletLabel = UILabel()
private let buttonsBar = ButtonsBar(configuration: .white(buttons: 2))
private var imageViewDimension: CGFloat {
if ScreenChecker().isNarrowScreen {
return 60

Loading…
Cancel
Save