Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Project and SwiftLint warning fixes #657

Merged
merged 2 commits into from
Feb 22, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call, thanks.

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