[#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 [#<issue number>]:` to not trigger this rule.
- Updated TODOs and FIXMEs which had issue number in different format in
  the code.
This commit is contained in:
Michal Fousek 2022-09-26 17:30:07 +02:00 committed by GitHub
parent cc7b767a5a
commit 6bf65b1d4d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
17 changed files with 51 additions and 41 deletions

View File

@ -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:

View File

@ -18,7 +18,7 @@ struct DeeplinkHandler {
func resolveDeeplinkURL(_ url: URL, derivationTool: WrappedDerivationTool) throws -> Deeplink {
// simplified format zcash:<address>
// 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) {

View File

@ -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
}

View File

@ -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)
}
}

View File

@ -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

View File

@ -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."),

View File

@ -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):

View File

@ -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

View File

@ -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
}

View File

@ -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
}

View File

@ -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)

View File

@ -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")
}

View File

@ -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,

View File

@ -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 {

View File

@ -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 {

View File

@ -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(

View File

@ -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)
}
}