From 6bf65b1d4daa7de897205177f0504f2c6b651f8d Mon Sep 17 00:00:00 2001 From: Michal Fousek Date: Mon, 26 Sep 2022 17:30:07 +0200 Subject: [PATCH] [#25] Add swiftlint rule to detect TODO without issue number (#425) Closes #25 - Add `todos` swiftlint rule which detects `TODO:` or `FIXME:` without ticket number. - Use `TODO [#]:` to not trigger this rule. - Updated TODOs and FIXMEs which had issue number in different format in the code. --- .swiftlint.yml | 11 +++++++++- secant/Dependencies/DeeplinkHandler.swift | 2 +- secant/Dependencies/WalletStorage.swift | 2 +- secant/Features/App/AppStore.swift | 22 +++++++++---------- secant/Features/Home/HomeStore.swift | 6 ++--- .../ImportWallet/ImportWalletStore.swift | 4 ++-- .../RecoveryPhraseDisplayStore.swift | 4 ++-- .../RecoveryPhraseValidationFlowStore.swift | 3 ++- secant/Features/Scan/ScanStore.swift | 4 ++-- secant/Features/Settings/SettingsStore.swift | 2 +- .../Views/TransactionRowView.swift | 6 ++--- secant/Models/WalletEvent.swift | 8 +++---- .../CurrencySelectionStore.swift | 2 +- .../TransactionAmountTextFieldStore.swift | 2 +- secant/Utils/DebugMenu.swift | 2 +- secantTests/AppTests/AppTests.swift | 4 ++-- .../UtilTests/WalletStorageTests.swift | 8 +++---- 17 files changed, 51 insertions(+), 41 deletions(-) diff --git a/.swiftlint.yml b/.swiftlint.yml index 7bd9828..e43d47d 100644 --- a/.swiftlint.yml +++ b/.swiftlint.yml @@ -59,7 +59,7 @@ opt_in_rules: - vertical_whitespace_opening_braces - weak_delegate - yoda_condition - + - todos custom_rules: array_constructor: @@ -93,6 +93,15 @@ custom_rules: message: "The swift NSLog function should not be used." severity: error + todos: + included: ".*\\.swift" + name: "TODO" + regex: "(TODO|FIXME)\ {0,}:" + message: "TODO or FIXME without issue number." + severity: warning + match_kinds: + - comment + attributes: always_on_same_line: diff --git a/secant/Dependencies/DeeplinkHandler.swift b/secant/Dependencies/DeeplinkHandler.swift index 35a3a31..a1d5e54 100644 --- a/secant/Dependencies/DeeplinkHandler.swift +++ b/secant/Dependencies/DeeplinkHandler.swift @@ -18,7 +18,7 @@ struct DeeplinkHandler { func resolveDeeplinkURL(_ url: URL, derivationTool: WrappedDerivationTool) throws -> Deeplink { // simplified format zcash:
- // TODO: simplified for now until ZIP-321 is implememnted, issue 109 (https://github.com/zcash/secant-ios-wallet/issues/109) + // TODO [#109]: simplified for now until ZIP-321 is implememnted (https://github.com/zcash/secant-ios-wallet/issues/109) let address = url.absoluteString.replacingOccurrences(of: "zcash:", with: "") do { if try derivationTool.isValidZcashAddress(address) { diff --git a/secant/Dependencies/WalletStorage.swift b/secant/Dependencies/WalletStorage.swift index ef64e76..b2fb911 100644 --- a/secant/Dependencies/WalletStorage.swift +++ b/secant/Dependencies/WalletStorage.swift @@ -94,7 +94,7 @@ struct WalletStorage { do { _ = try exportWallet() } catch { - // TODO: - report & log error.localizedDescription [Issue #219, https://github.com/zcash/secant-ios-wallet/issues/219] + // TODO [#219]: - report & log error.localizedDescription, https://github.com/zcash/secant-ios-wallet/issues/219] throw error } diff --git a/secant/Features/App/AppStore.swift b/secant/Features/App/AppStore.swift index 626a0e3..ca0776f 100644 --- a/secant/Features/App/AppStore.swift +++ b/secant/Features/App/AppStore.swift @@ -142,10 +142,10 @@ extension AppReducer { case .respondToWalletInitializationState(let walletState): switch walletState { case .failed: - // TODO: error we need to handle, issue #221 (https://github.com/zcash/secant-ios-wallet/issues/221) + // TODO [#221]: error we need to handle (https://github.com/zcash/secant-ios-wallet/issues/221) state.appInitializationState = .failed case .keysMissing: - // TODO: error we need to handle, issue #221 (https://github.com/zcash/secant-ios-wallet/issues/221) + // TODO [#221]: error we need to handle (https://github.com/zcash/secant-ios-wallet/issues/221) state.appInitializationState = .keysMissing case .initialized, .filesMissing: if walletState == .filesMissing { @@ -173,7 +173,7 @@ extension AppReducer { guard let storedWallet = state.storedWallet else { state.appInitializationState = .failed - // TODO: fatal error we need to handle, issue #221 (https://github.com/zcash/secant-ios-wallet/issues/221) + // TODO [#221]: fatal error we need to handle (https://github.com/zcash/secant-ios-wallet/issues/221) return .none } @@ -190,14 +190,14 @@ extension AppReducer { try environment.SDKSynchronizer.start() } catch { state.appInitializationState = .failed - // TODO: error we need to handle, issue #221 (https://github.com/zcash/secant-ios-wallet/issues/221) + // TODO [#221]: error we need to handle (https://github.com/zcash/secant-ios-wallet/issues/221) } return .none case .checkBackupPhraseValidation: guard let storedWallet = state.storedWallet else { state.appInitializationState = .failed - // TODO: fatal error we need to handle, issue #221 (https://github.com/zcash/secant-ios-wallet/issues/221) + // TODO [#221]: fatal error we need to handle (https://github.com/zcash/secant-ios-wallet/issues/221) return .none } @@ -212,7 +212,7 @@ extension AppReducer { state.phraseValidationState = environment.recoveryPhraseRandomizer.random(recoveryPhrase) landingRoute = .phraseDisplay } catch { - // TODO: - merge with issue 201 (https://github.com/zcash/secant-ios-wallet/issues/201) and its Error States + // TODO [#201]: - merge with issue 201 (https://github.com/zcash/secant-ios-wallet/issues/201) and its Error States return .none } } @@ -244,7 +244,7 @@ extension AppReducer { Effect(value: .phraseValidation(.displayBackedUpPhrase)) ) } catch { - // TODO: - merge with issue 201 (https://github.com/zcash/secant-ios-wallet/issues/201) and its Error States + // TODO [#201]: - merge with issue 201 (https://github.com/zcash/secant-ios-wallet/issues/201) and its Error States } return .none @@ -253,7 +253,7 @@ extension AppReducer { do { try environment.walletStorage.markUserPassedPhraseBackupTest() } catch { - // TODO: error we need to handle, issue #221 (https://github.com/zcash/secant-ios-wallet/issues/221) + // TODO [#221]: error we need to handle, issue #221 (https://github.com/zcash/secant-ios-wallet/issues/221) } return .none @@ -262,7 +262,7 @@ extension AppReducer { do { try environment.databaseFiles.nukeDbFilesFor(environment.zcashSDKEnvironment.network) } catch { - // TODO: error we need to handle, issue #221 (https://github.com/zcash/secant-ios-wallet/issues/221) + // TODO [#221]: error we need to handle, issue #221 (https://github.com/zcash/secant-ios-wallet/issues/221) } return .none @@ -319,7 +319,7 @@ extension AppReducer { // process the deeplink only if app is initialized and synchronizer synced guard state.appInitializationState == .initialized && synchronizerStatus == .synced else { - // TODO: There are many different states and edge cases we need to handle here, issue 370 + // TODO [#370]: There are many different states and edge cases we need to handle here // (https://github.com/zcash/secant-ios-wallet/issues/370) return .none } @@ -327,7 +327,7 @@ extension AppReducer { do { await send(try await process(url: url, with: environment)) } catch { - // TODO: error we need to handle, issue #221 (https://github.com/zcash/secant-ios-wallet/issues/221) + // TODO [#221]: error we need to handle (https://github.com/zcash/secant-ios-wallet/issues/221) } } diff --git a/secant/Features/Home/HomeStore.swift b/secant/Features/Home/HomeStore.swift index 373cae4..083ab5b 100644 --- a/secant/Features/Home/HomeStore.swift +++ b/secant/Features/Home/HomeStore.swift @@ -32,7 +32,7 @@ struct HomeState: Equatable { var shieldedBalance: WalletBalance var synchronizerStatusSnapshot: SyncStatusSnapshot var walletEventsState: WalletEventsFlowState - // TODO: - Get the ZEC price from the SDK, issue 311, https://github.com/zcash/secant-ios-wallet/issues/311 + // TODO [#311]: - Get the ZEC price from the SDK, https://github.com/zcash/secant-ios-wallet/issues/311 var zecPrice = Decimal(140.0) var totalCurrencyBalance: Zatoshi { @@ -166,7 +166,7 @@ extension HomeReducer { do { try environment.SDKSynchronizer.rewind(.quick) } catch { - // TODO: error we need to handle, issue #221 (https://github.com/zcash/secant-ios-wallet/issues/221) + // TODO [#221]: error we need to handle (https://github.com/zcash/secant-ios-wallet/issues/221) } state.route = nil return .none @@ -175,7 +175,7 @@ extension HomeReducer { do { try environment.SDKSynchronizer.rewind(.birthday) } catch { - // TODO: error we need to handle, issue #221 (https://github.com/zcash/secant-ios-wallet/issues/221) + // TODO [#221]: error we need to handle (https://github.com/zcash/secant-ios-wallet/issues/221) } state.route = nil return .none diff --git a/secant/Features/ImportWallet/ImportWalletStore.swift b/secant/Features/ImportWallet/ImportWalletStore.swift index 559b716..c9af8e5 100644 --- a/secant/Features/ImportWallet/ImportWalletStore.swift +++ b/secant/Features/ImportWallet/ImportWalletStore.swift @@ -123,7 +123,7 @@ extension ImportWalletReducer { try environment.walletStorage.markUserPassedPhraseBackupTest() // notify user - // TODO: Proper Error/Success handling, issue 221 (https://github.com/zcash/secant-ios-wallet/issues/221) + // TODO [#221]: Proper Error/Success handling (https://github.com/zcash/secant-ios-wallet/issues/221) state.alert = AlertState( title: TextState("Success"), message: TextState("The wallet has been successfully recovered."), @@ -135,7 +135,7 @@ extension ImportWalletReducer { return Effect(value: .initializeSDK) } catch { - // TODO: Proper Error/Success handling, issue 221 (https://github.com/zcash/secant-ios-wallet/issues/221) + // TODO [#221]: Proper Error/Success handling (https://github.com/zcash/secant-ios-wallet/issues/221) state.alert = AlertState( title: TextState("Wrong Seed Phrase"), message: TextState("The seed phrase must be 24 words separated by space."), diff --git a/secant/Features/RecoveryPhraseDisplay/RecoveryPhraseDisplayStore.swift b/secant/Features/RecoveryPhraseDisplay/RecoveryPhraseDisplayStore.swift index 8daeff9..61ec75d 100644 --- a/secant/Features/RecoveryPhraseDisplay/RecoveryPhraseDisplayStore.swift +++ b/secant/Features/RecoveryPhraseDisplay/RecoveryPhraseDisplayStore.swift @@ -56,7 +56,7 @@ extension RecoveryPhraseDisplayReducer { do { await send(.phraseResponse(try await environment.newPhrase())) } catch { - // TODO: remove this when feature is implemented in https://github.com/zcash/secant-ios-wallet/issues/129 + // TODO [#129]: remove this when feature is implemented in https://github.com/zcash/secant-ios-wallet/issues/129 } } @@ -67,7 +67,7 @@ extension RecoveryPhraseDisplayReducer { return .none case .finishedPressed: - // TODO: remove this when feature is implemented in https://github.com/zcash/secant-ios-wallet/issues/47 + // TODO [#47]: remove this when feature is implemented in https://github.com/zcash/secant-ios-wallet/issues/47 return .none case let .phraseResponse(phrase): diff --git a/secant/Features/RecoveryPhraseValidationFlow/RecoveryPhraseValidationFlowStore.swift b/secant/Features/RecoveryPhraseValidationFlow/RecoveryPhraseValidationFlowStore.swift index 74affbf..1d66ee9 100644 --- a/secant/Features/RecoveryPhraseValidationFlow/RecoveryPhraseValidationFlowStore.swift +++ b/secant/Features/RecoveryPhraseValidationFlow/RecoveryPhraseValidationFlowStore.swift @@ -141,7 +141,8 @@ extension RecoveryPhraseValidationFlowReducer { case .reset: state = environment.recoveryPhraseRandomizer.random(state.phrase) state.route = .validation - // FIXME: Resetting causes route to be nil = preamble screen, hence setting the .validation. The transition back is not animated though (issue 186) + // FIXME [#186]: Resetting causes route to be nil = preamble screen, hence setting the .validation. The transition back is not animated + // though case let .move(wordChip, group): guard diff --git a/secant/Features/Scan/ScanStore.swift b/secant/Features/Scan/ScanStore.swift index bd4e8f1..32f2731 100644 --- a/secant/Features/Scan/ScanStore.swift +++ b/secant/Features/Scan/ScanStore.swift @@ -70,7 +70,7 @@ extension ScanReducer { do { state.isTorchAvailable = try environment.captureDevice.isTorchAvailable() } catch { - // TODO: handle torch errors, issue #322 (https://github.com/zcash/secant-ios-wallet/issues/322) + // TODO [#322]: handle torch errors (https://github.com/zcash/secant-ios-wallet/issues/322) } return .none @@ -114,7 +114,7 @@ extension ScanReducer { try environment.captureDevice.torch(!state.isTorchOn) state.isTorchOn.toggle() } catch { - // TODO: handle torch errors, issue #322 (https://github.com/zcash/secant-ios-wallet/issues/322) + // TODO [#322]: handle torch errors (https://github.com/zcash/secant-ios-wallet/issues/322) } return .none } diff --git a/secant/Features/Settings/SettingsStore.swift b/secant/Features/Settings/SettingsStore.swift index 9e42a10..39e0987 100644 --- a/secant/Features/Settings/SettingsStore.swift +++ b/secant/Features/Settings/SettingsStore.swift @@ -67,7 +67,7 @@ extension SettingsReducer { state.phraseDisplayState.phrase = recoveryPhrase return Effect(value: .updateRoute(.backupPhrase)) } catch { - // TODO: - merge with issue 201 (https://github.com/zcash/secant-ios-wallet/issues/201) and its Error States + // TODO [#201]: - merge with issue 201 (https://github.com/zcash/secant-ios-wallet/issues/201) and its Error States return .none } diff --git a/secant/Features/WalletEventsFlow/Views/TransactionRowView.swift b/secant/Features/WalletEventsFlow/Views/TransactionRowView.swift index 649ae4c..ae1dd19 100644 --- a/secant/Features/WalletEventsFlow/Views/TransactionRowView.swift +++ b/secant/Features/WalletEventsFlow/Views/TransactionRowView.swift @@ -39,7 +39,7 @@ struct TransactionRowView: View { Spacer(minLength: 80) - // TODO: - Get the ZEC price from the SDK, issue 311, https://github.com/zcash/secant-ios-wallet/issues/311 + // TODO [#311]: - Get the ZEC price from the SDK, https://github.com/zcash/secant-ios-wallet/issues/311 } .padding(.trailing, 15) } @@ -66,7 +66,7 @@ extension TransactionRowView { case .received: return "Unknown paid you" case .failed: - // TODO: final text to be provided, issue 392 (https://github.com/zcash/secant-ios-wallet/issues/392) + // TODO [#392]: final text to be provided (https://github.com/zcash/secant-ios-wallet/issues/392) return "Transaction failed" case .pending: return "You are sending to" @@ -81,7 +81,7 @@ extension TransactionRowView { .resizable() .frame(width: 60, height: 60) case .failed: - // TODO: final icon to be provided, issue 392 (https://github.com/zcash/secant-ios-wallet/issues/392) + // TODO [#392]: final icon to be provided (https://github.com/zcash/secant-ios-wallet/issues/392) Circle() .frame(width: 30, height: 30) .foregroundColor(Color.red) diff --git a/secant/Models/WalletEvent.swift b/secant/Models/WalletEvent.swift index 70d21f4..159135a 100644 --- a/secant/Models/WalletEvent.swift +++ b/secant/Models/WalletEvent.swift @@ -38,11 +38,11 @@ extension WalletEvent { .failed(let transaction): TransactionRowView(transaction: transaction) case .shielded(let zatoshi): - // TODO: implement design once shielding is supported, issue 390 + // TODO [#390]: implement design once shielding is supported // https://github.com/zcash/secant-ios-wallet/issues/390 Text("shielded wallet event \(zatoshi.decimalString())") case .walletImport: - // TODO: implement design once shielding is supported, issue 391 + // TODO [#391]: implement design once shielding is supported // https://github.com/zcash/secant-ios-wallet/issues/391 Text("wallet import wallet event") } @@ -60,11 +60,11 @@ extension WalletEvent { .failed(let transaction): TransactionDetailView(transaction: transaction, store: store) case .shielded(let zatoshi): - // TODO: implement design once shielding is supported, issue 390 + // TODO [#390]: implement design once shielding is supported // https://github.com/zcash/secant-ios-wallet/issues/390 Text("shielded \(zatoshi.decimalString()) detail") case .walletImport: - // TODO: implement design once shielding is supported, issue 391 + // TODO [#391]: implement design once shielding is supported // https://github.com/zcash/secant-ios-wallet/issues/391 Text("wallet import wallet event") } diff --git a/secant/UI Components/TextFields/Components/CurrencySelection/CurrencySelectionStore.swift b/secant/UI Components/TextFields/Components/CurrencySelection/CurrencySelectionStore.swift index 448fee0..e936cda 100644 --- a/secant/UI Components/TextFields/Components/CurrencySelection/CurrencySelectionStore.swift +++ b/secant/UI Components/TextFields/Components/CurrencySelection/CurrencySelectionStore.swift @@ -7,7 +7,7 @@ import ComposableArchitecture -// TODO: Reimplement this into multicurrency supporter, issue #315 (https://github.com/zcash/secant-ios-wallet/issues/315) +// TODO [#315]: Reimplement this into multicurrency supporter (https://github.com/zcash/secant-ios-wallet/issues/315) typealias CurrencySelectionReducer = Reducer< CurrencySelectionState, diff --git a/secant/UI Components/TextFields/TransactionAmount/TransactionAmountTextFieldStore.swift b/secant/UI Components/TextFields/TransactionAmount/TransactionAmountTextFieldStore.swift index ead7316..a1ee143 100644 --- a/secant/UI Components/TextFields/TransactionAmount/TransactionAmountTextFieldStore.swift +++ b/secant/UI Components/TextFields/TransactionAmount/TransactionAmountTextFieldStore.swift @@ -22,7 +22,7 @@ struct TransactionAmountTextFieldState: Equatable { var currencySelectionState: CurrencySelectionState var maxValue: Int64 = 0 var textFieldState: TCATextFieldState - // TODO: - Get the ZEC price from the SDK, issue 311, https://github.com/zcash/secant-ios-wallet/issues/311 + // TODO [#311]: - Get the ZEC price from the SDK, https://github.com/zcash/secant-ios-wallet/issues/311 var zecPrice = Decimal(140.0) var isMax: Bool { diff --git a/secant/Utils/DebugMenu.swift b/secant/Utils/DebugMenu.swift index 728e864..1b55ed6 100644 --- a/secant/Utils/DebugMenu.swift +++ b/secant/Utils/DebugMenu.swift @@ -7,7 +7,7 @@ import SwiftUI -// TODO: Make sure this code will never be in the production (app store) build, issue 273 (https://github.com/zcash/secant-ios-wallet/issues/273) +// TODO [#273]: Make sure this code will never be in the production (app store) build (https://github.com/zcash/secant-ios-wallet/issues/273) // swiftlint:disable:next private_over_fileprivate strict_fileprivate fileprivate struct DebugMenuModifier: ViewModifier { diff --git a/secantTests/AppTests/AppTests.swift b/secantTests/AppTests/AppTests.swift index 971b153..f1afce3 100644 --- a/secantTests/AppTests/AppTests.swift +++ b/secantTests/AppTests/AppTests.swift @@ -98,9 +98,9 @@ class AppTests: XCTestCase { XCTAssertEqual(walletState, .uninitialized) } - // TODO: - Implement testWalletInitializationState_FilesMissing when WalletStorage mock is available, issue 231 (https://github.com/zcash/secant-ios-wallet/issues/231) + // TODO [#231]: - Implement testWalletInitializationState_FilesMissing when WalletStorage mock is available (https://github.com/zcash/secant-ios-wallet/issues/231) - // TODO: - Implement testWalletInitializationState_Initialized when WalletStorage mock is available, issue 231 (https://github.com/zcash/secant-ios-wallet/issues/231) + // TODO [#231]: - Implement testWalletInitializationState_Initialized when WalletStorage mock is available (https://github.com/zcash/secant-ios-wallet/issues/231) func testRespondToWalletInitializationState_Uninitialized() throws { let store = TestStore( diff --git a/secantTests/UtilTests/WalletStorageTests.swift b/secantTests/UtilTests/WalletStorageTests.swift index 34743bc..4187d81 100644 --- a/secantTests/UtilTests/WalletStorageTests.swift +++ b/secantTests/UtilTests/WalletStorageTests.swift @@ -291,7 +291,7 @@ private extension WalletStorageTests { var query = storage.baseQuery(forAccount: account, andKey: forKey) query[kSecValueData as String] = data as AnyObject - // TODO: - Mock the Keychain and write unit tests, issue 231 (https://github.com/zcash/secant-ios-wallet/issues/231) + // TODO [#231]: - Mock the Keychain and write unit tests (https://github.com/zcash/secant-ios-wallet/issues/231) SecItemAdd(query as CFDictionary, nil) } @@ -302,7 +302,7 @@ private extension WalletStorageTests { let query = storage.restoreQuery(forAccount: account, andKey: forKey) var result: AnyObject? - // TODO: - Mock the Keychain and write unit tests, issue 231 (https://github.com/zcash/secant-ios-wallet/issues/231) + // TODO [#231]: - Mock the Keychain and write unit tests (https://github.com/zcash/secant-ios-wallet/issues/231) _ = SecItemCopyMatching(query as CFDictionary, &result) return result as? Data @@ -315,7 +315,7 @@ private extension WalletStorageTests { ) -> Bool { let query = storage.baseQuery(forAccount: account, andKey: forKey) - // TODO: - Mock the Keychain and write unit tests, issue 231 (https://github.com/zcash/secant-ios-wallet/issues/231) + // TODO [#231]: - Mock the Keychain and write unit tests (https://github.com/zcash/secant-ios-wallet/issues/231) let status = SecItemDelete(query as CFDictionary) return status == noErr @@ -332,7 +332,7 @@ private extension WalletStorageTests { kSecValueData as String: data as AnyObject ] - // TODO: - Mock the Keychain and write unit tests, issue 231 (https://github.com/zcash/secant-ios-wallet/issues/231) + // TODO [#231]: - Mock the Keychain and write unit tests (https://github.com/zcash/secant-ios-wallet/issues/231) _ = SecItemUpdate(query as CFDictionary, attributes as CFDictionary) } }