From 93a01aff8b99be2c2b637b72d7f0ab467ed7a467 Mon Sep 17 00:00:00 2001 From: Eric Jensen Date: Mon, 22 Feb 2021 13:02:20 -0800 Subject: [PATCH] Project and SwiftLint warning fixes (#657) * Fix project and SwiftLint warnings * Kickstart CI Co-authored-by: Rita Zerrizuela --- .swiftlint.yml | 1 - Lock.xcodeproj/project.pbxproj | 4 +++- Lock/ClassicRouter.swift | 7 ++++--- Lock/DatabaseInteractor.swift | 2 +- Lock/DatabasePresenter.swift | 2 +- Lock/OfflineConnections.swift | 12 ++++++------ Lock/PasswordlessPresenter.swift | 4 ++-- 7 files changed, 17 insertions(+), 15 deletions(-) diff --git a/.swiftlint.yml b/.swiftlint.yml index a18a16ee4..369bf12ee 100644 --- a/.swiftlint.yml +++ b/.swiftlint.yml @@ -3,7 +3,6 @@ disabled_rules: # rule identifiers to exclude from running - cyclomatic_complexity - function_body_length - todo - - force_cast opt_in_rules: # some rules are only opt-in - empty_count # Find all the available rules by running: diff --git a/Lock.xcodeproj/project.pbxproj b/Lock.xcodeproj/project.pbxproj index 545bbf1e6..981a3710e 100644 --- a/Lock.xcodeproj/project.pbxproj +++ b/Lock.xcodeproj/project.pbxproj @@ -993,7 +993,7 @@ isa = PBXProject; attributes = { LastSwiftUpdateCheck = 0830; - LastUpgradeCheck = 0930; + LastUpgradeCheck = 1240; ORGANIZATIONNAME = Auth0; TargetAttributes = { 5BEDE1391EC0A9750007300D = { @@ -1474,6 +1474,7 @@ CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; CLANG_WARN_STRICT_PROTOTYPES = YES; CLANG_WARN_SUSPICIOUS_MOVE = YES; @@ -1535,6 +1536,7 @@ CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; CLANG_WARN_STRICT_PROTOTYPES = YES; CLANG_WARN_SUSPICIOUS_MOVE = YES; diff --git a/Lock/ClassicRouter.swift b/Lock/ClassicRouter.swift index 5d4221f5e..d27dfac4c 100644 --- a/Lock/ClassicRouter.swift +++ b/Lock/ClassicRouter.swift @@ -44,7 +44,7 @@ struct ClassicRouter: Router { let interactor = CDNLoaderInteractor(baseURL: baseURL, clientId: self.lock.authentication.clientId) return ConnectionLoadingPresenter(loader: interactor, navigator: self, dispatcher: lock.observerStore, options: self.lock.options) } - let whitelistForActiveAuth = self.lock.options.enterpriseConnectionUsingActiveAuth + let allowListForActiveAuth = self.lock.options.enterpriseConnectionUsingActiveAuth switch (connections.database, connections.oauth2, connections.enterprise) { // Database root @@ -65,11 +65,11 @@ struct ClassicRouter: Router { } return presenter // Single Enterprise with active auth support (e.g. AD) - case (nil, let oauth2, let enterprise) where oauth2.isEmpty && enterprise.hasJustOne(andIn: whitelistForActiveAuth): + case (nil, let oauth2, let enterprise) where oauth2.isEmpty && enterprise.hasJustOne(andIn: allowListForActiveAuth): guard let connection = enterprise.first else { return nil } return enterpriseActiveAuth(connection: connection, domain: connection.domains.first) // Single Enterprise with support for passive auth only (web auth) and some social connections - case (nil, let oauth2, let enterprise) where enterprise.hasJustOne(andNotIn: whitelistForActiveAuth): + case (nil, let oauth2, let enterprise) where enterprise.hasJustOne(andNotIn: allowListForActiveAuth): guard let connection = enterprise.first else { return nil } let authInteractor = Auth0OAuth2Interactor(authentication: self.lock.authentication, dispatcher: lock.observerStore, options: self.lock.options, nativeHandlers: self.lock.nativeHandlers) let connections: [OAuth2Connection] = oauth2 + [connection] @@ -164,6 +164,7 @@ struct ClassicRouter: Router { self.lock.logger.warn("Ignoring navigation \(route)") return } + self.lock.logger.debug("Navigating to \(route)") self.controller?.routes.go(route) self.controller?.present(presentable, title: route.title(withStyle: self.lock.style)) diff --git a/Lock/DatabaseInteractor.swift b/Lock/DatabaseInteractor.swift index 8703458d0..62190b6ce 100644 --- a/Lock/DatabaseInteractor.swift +++ b/Lock/DatabaseInteractor.swift @@ -119,7 +119,7 @@ struct DatabaseInteractor: DatabaseAuthenticatable, DatabaseUserCreator, Loggabl func create(_ callback: @escaping (DatabaseUserCreatorError?, CredentialAuthError?) -> Void) { let databaseName = connection.name - guard let email = self.email, self.validEmail, let password = self.password, self.validPassword else { + guard let email = self.email, self.validEmail, let password = self.password, self.validPassword else { return callback(.nonValidInput, nil) } diff --git a/Lock/DatabasePresenter.swift b/Lock/DatabasePresenter.swift index 0ef06b9e4..dfde6b7dd 100644 --- a/Lock/DatabasePresenter.swift +++ b/Lock/DatabasePresenter.swift @@ -165,7 +165,7 @@ class DatabasePresenter: Presentable, Loggable { view.primaryButton?.onPress = action view.secondaryButton?.title = "Don’t remember your password?".i18n(key: "com.auth0.lock.database.button.forgot_password", comment: "Forgot password") view.secondaryButton?.color = .clear - view.secondaryButton?.onPress = { button in + view.secondaryButton?.onPress = { _ in self.navigator.navigate(.forgotPassword) } } diff --git a/Lock/OfflineConnections.swift b/Lock/OfflineConnections.swift index 58274a0a6..ecd58d1a9 100644 --- a/Lock/OfflineConnections.swift +++ b/Lock/OfflineConnections.swift @@ -69,14 +69,14 @@ struct OfflineConnections: ConnectionBuildable { func select(byNames names: [String]) -> OfflineConnections { var connections = OfflineConnections() - connections.databases = self.databases.filter { isWhitelisted(connectionName: $0.name, inList: names) } - connections.oauth2 = self.oauth2.filter { isWhitelisted(connectionName: $0.name, inList: names) } - connections.enterprise = self.enterprise.filter { isWhitelisted(connectionName: $0.name, inList: names) } - connections.passwordless = self.passwordless.filter { isWhitelisted(connectionName: $0.name, inList: names) } + connections.databases = self.databases.filter { isAllowed(connectionName: $0.name, inList: names) } + connections.oauth2 = self.oauth2.filter { isAllowed(connectionName: $0.name, inList: names) } + connections.enterprise = self.enterprise.filter { isAllowed(connectionName: $0.name, inList: names) } + connections.passwordless = self.passwordless.filter { isAllowed(connectionName: $0.name, inList: names) } return connections } } -private func isWhitelisted(connectionName name: String, inList whitelist: [String]) -> Bool { - return whitelist.isEmpty || whitelist.contains(name) +private func isAllowed(connectionName name: String, inList allowList: [String]) -> Bool { + return allowList.isEmpty || allowList.contains(name) } diff --git a/Lock/PasswordlessPresenter.swift b/Lock/PasswordlessPresenter.swift index 489da9b6f..272bd4d20 100644 --- a/Lock/PasswordlessPresenter.swift +++ b/Lock/PasswordlessPresenter.swift @@ -95,7 +95,7 @@ class PasswordlessPresenter: Presentable, Loggable { guard let button = view.primaryButton else { return } action(button) } - view.secondaryButton?.onPress = { button in + view.secondaryButton?.onPress = { _ in self.navigator.onBack() } @@ -171,7 +171,7 @@ class PasswordlessPresenter: Presentable, Loggable { private func showLinkSent() -> View { let view = PasswordlessView() view.showLinkSent(identifier: self.interactor.identifier, countryCode: self.interactor.countryCode) - view.secondaryButton?.onPress = { button in + view.secondaryButton?.onPress = { _ in self.navigator.onBack() } return view