Skip to content

Commit

Permalink
Project and SwiftLint warning fixes (#657)
Browse files Browse the repository at this point in the history
* Fix project and SwiftLint warnings

* Kickstart CI

Co-authored-by: Rita Zerrizuela <zeta@widcket.com>
  • Loading branch information
ejensen and Widcket authored Feb 22, 2021
1 parent 3402c16 commit 93a01af
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 15 deletions.
1 change: 0 additions & 1 deletion .swiftlint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
4 changes: 3 additions & 1 deletion Lock.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -993,7 +993,7 @@
isa = PBXProject;
attributes = {
LastSwiftUpdateCheck = 0830;
LastUpgradeCheck = 0930;
LastUpgradeCheck = 1240;
ORGANIZATIONNAME = Auth0;
TargetAttributes = {
5BEDE1391EC0A9750007300D = {
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
7 changes: 4 additions & 3 deletions Lock/ClassicRouter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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]
Expand Down Expand Up @@ -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))
Expand Down
2 changes: 1 addition & 1 deletion Lock/DatabaseInteractor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down
2 changes: 1 addition & 1 deletion Lock/DatabasePresenter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
Expand Down
12 changes: 6 additions & 6 deletions Lock/OfflineConnections.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
4 changes: 2 additions & 2 deletions Lock/PasswordlessPresenter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}

Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 93a01af

Please sign in to comment.