Skip to content

Commit

Permalink
SwiftLint Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
cocojoe committed Nov 24, 2016
1 parent 303ec02 commit b07692b
Show file tree
Hide file tree
Showing 47 changed files with 217 additions and 160 deletions.
54 changes: 54 additions & 0 deletions .swiftlint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
disabled_rules: # rule identifiers to exclude from running
- colon
- comma
- control_statement
- missing_docs
- force_cast
- variable_name
- cyclomatic_complexity
- function_body_length
- todo
opt_in_rules: # some rules are only opt-in
- empty_count
# Find all the available rules by running:
# swiftlint rules
included: # paths to include during linting. `--path` is ignored if present.
- Lock
excluded: # paths to ignore during linting. Takes precedence over `included`.
- Carthage
- Pods
- Source/ExcludedFolder
- Source/ExcludedFile.swift

# configurable rules can be customized from this configuration file
# binary rules can set their severity level
force_cast: warning # implicitly
force_try:
severity: warning # explicitly
# rules that have both warning and error levels, can set just the warning level
# implicitly
line_length: 300
# they can set both implicitly with an array
type_body_length:
- 300 # warning
- 400 # error
# or they can set both explicitly
file_length:
warning: 500
error: 1200
# naming rules can set warnings/errors for min_length and max_length
# additionally they can set excluded names
type_name:
min_length: 4 # only warning
max_length: # warning and error
warning: 40
error: 50
excluded: iPhone # excluded via string
variable_name:
min_length: # only min_length
error: 4 # only error
excluded: # excluded via string array
- id
- URL
- GlobalAPIKey
reporter: "xcode" # reporter type (xcode, json, csv, checkstyle, junit)
14 changes: 14 additions & 0 deletions Lock.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -735,6 +735,7 @@
5FEAE1C21D1A5154005C0028 /* Frameworks */,
5FEAE1C31D1A5154005C0028 /* Headers */,
5FEAE1C41D1A5154005C0028 /* Resources */,
5B73CCAE1DE742F60050963E /* ShellScript */,
);
buildRules = (
);
Expand Down Expand Up @@ -870,6 +871,19 @@
/* End PBXResourcesBuildPhase section */

/* Begin PBXShellScriptBuildPhase section */
5B73CCAE1DE742F60050963E /* ShellScript */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
);
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "if which swiftlint >/dev/null; then\nswiftlint\nelse\necho \"warning: SwiftLint not installed, download from https://github.com/realm/SwiftLint\"\nfi";
};
5FC4348D1D1E02EF005188BC /* Auth0 */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
Expand Down
10 changes: 5 additions & 5 deletions Lock/AuthButton.swift
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public class AuthButton: UIView {

public var onPress: (AuthButton) -> () = { _ in }

// MARK:- Style
// MARK: - Style

public var size: Size {
didSet {
Expand All @@ -94,7 +94,7 @@ public class AuthButton: UIView {
case big
}

// MARK:- Initialisers
// MARK: - Initialisers

public init(size: Size) {
self.size = size
Expand All @@ -114,7 +114,7 @@ public class AuthButton: UIView {
self.layout(size: self.size)
}

// MARK:- Layout
// MARK: - Layout

private func layout(size: Size) {

Expand Down Expand Up @@ -182,14 +182,14 @@ public class AuthButton: UIView {
}
}

// MARK:- Event
// MARK: - Event

func buttonPressed(_ sender: Any) {
self.onPress(self)
}
}

// MARK:- Color Util
// MARK: - Color Util
extension UIColor {
func a0_darker(_ percentage: CGFloat) -> UIColor {
guard percentage >= 0 && percentage <= 1 else { return self }
Expand Down
5 changes: 2 additions & 3 deletions Lock/AuthCollectionView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class AuthCollectionView: UIView, View {
case compact
}

// MARK:- Initialisers
// MARK: - Initialisers

init(connections: [OAuth2Connection], mode: Mode, insets: UIEdgeInsets, customStyle: [String: AuthStyle], onAction: @escaping (String) -> ()) {
self.connections = connections
Expand All @@ -49,7 +49,7 @@ class AuthCollectionView: UIView, View {
fatalError("init(coder:) has not been implemented")
}

// MARK:- Layout
// MARK: - Layout

var height: CGFloat {
guard !connections.isEmpty else { return 0 }
Expand Down Expand Up @@ -137,7 +137,6 @@ class AuthCollectionView: UIView, View {
}

func apply(style: Style) {

}
}

Expand Down
4 changes: 2 additions & 2 deletions Lock/AuthStyle.swift
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public class AuthStyle {
}
}

// MARK:- First class social connection styles
// MARK: - First class social connection styles

public extension AuthStyle {

Expand Down Expand Up @@ -264,7 +264,7 @@ public extension AuthStyle {
}
}

// MARK:- AuthStyle from Strategy & Connection
// MARK: - AuthStyle from Strategy & Connection

extension AuthStyle {

Expand Down
6 changes: 3 additions & 3 deletions Lock/CDNLoaderInteractor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ struct CDNLoaderInteractor: RemoteConnectionLoader, Loggable {
self.logger.error("Failed to parse \(jsonp) with error \(e)")
return callback(nil)
}
})
})
task.resume()
}
}
Expand All @@ -114,7 +114,7 @@ private struct ClientInfo {
var auth0: StrategyInfo? { return strategies.filter({ $0.name == "auth0" }).first }

var oauth2: [StrategyInfo] { return strategies.filter { $0.name != "auth0" && !passwordlessStrategyNames.contains($0.name) && !enterpriseStrategyNames.contains($0.name) } }

var enterprise: [StrategyInfo] { return strategies.filter { $0.name != "auth0" && !passwordlessStrategyNames.contains($0.name) && enterpriseStrategyNames.contains($0.name) } }

let passwordlessStrategyNames = [
Expand All @@ -136,7 +136,7 @@ private struct ClientInfo {
"custom",
"sharepoint",
]

let enterpriseCredentialAuthNames = [
"waad",
"adfs",
Expand Down
5 changes: 2 additions & 3 deletions Lock/Colors.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,15 @@ extension UIColor {

let hexString: String = string.substring(from: string.characters.index(string.startIndex, offsetBy: 1))
var hexValue: UInt32 = 0

guard Scanner(string: hexString).scanHexInt32(&hexValue) else {
return defaultColor
}

let divisor = CGFloat(255)
let red = CGFloat((hexValue & 0xFF0000) >> 16) / divisor
let green = CGFloat((hexValue & 0x00FF00) >> 8) / divisor
let blue = CGFloat(hexValue & 0x0000FF) / divisor
return UIColor(red: red, green: green, blue: blue, alpha: 1)
}
}

3 changes: 1 addition & 2 deletions Lock/ConnectionBuildable.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@

import Foundation


/**
* Allows to specify Lock connections
*/
Expand Down Expand Up @@ -55,7 +54,7 @@ public protocol ConnectionBuildable: Connections {
- seeAlso: AuthStyle
*/
mutating func oauth2(name: String, style: AuthStyle)

/**
Adds a new enterprise connection
Expand Down
6 changes: 3 additions & 3 deletions Lock/CredentialView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public class CredentialView: UIView, Form {
self.passwordField.needsToUpdateState()
}

// MARK:- Initialisers
// MARK: - Initialisers

public convenience init() {
self.init(frame: CGRect.zero)
Expand All @@ -68,7 +68,7 @@ public class CredentialView: UIView, Form {
self.layoutForm()
}

// MARK:- Layout
// MARK: - Layout

private func layoutForm() {

Expand All @@ -92,5 +92,5 @@ public class CredentialView: UIView, Form {
identifier.type = .email
password.type = .password
}

}
5 changes: 2 additions & 3 deletions Lock/DatabaseConstants.swift
Original file line number Diff line number Diff line change
Expand Up @@ -38,16 +38,15 @@ public enum DatabaseScreen: Int, Equatable {
case resetPassword
}


public struct DatabaseIdentifierStyle: OptionSet {
public let rawValue: Int

public init(rawValue: Int) { self.rawValue = rawValue }

public static let Username = DatabaseIdentifierStyle(rawValue: 1 << 0)
public static let Email = DatabaseIdentifierStyle(rawValue: 1 << 1)
}

public func ==(lhs: DatabaseScreen, rhs: DatabaseScreen) -> Bool {
public func == (lhs: DatabaseScreen, rhs: DatabaseScreen) -> Bool {
return lhs.rawValue == rhs.rawValue
}
3 changes: 1 addition & 2 deletions Lock/DatabaseForgotPasswordPresenter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,8 @@ class DatabaseForgotPasswordPresenter: Presentable, Loggable {
self.database = connections.database! // FIXME: Avoid the force unwrap
}


var messagePresenter: MessagePresenter?

var view: View {
let email = self.interactor.validEmail ? self.interactor.email : nil
let view = DatabaseForgotPasswordView(email: email)
Expand Down
6 changes: 3 additions & 3 deletions Lock/DatabaseModeSwitcher.swift
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public class DatabaseModeSwitcher: UIView {
}
}

// MARK:- Initialisers
// MARK: - Initialisers

public convenience init() {
self.init(frame: CGRect.zero)
Expand All @@ -71,7 +71,7 @@ public class DatabaseModeSwitcher: UIView {
self.layoutSwitcher()
}

// MARK:- Layout
// MARK: - Layout

private func layoutSwitcher() {
let segmented = UISegmentedControl(items: [Mode.login.title, Mode.signup.title])
Expand Down Expand Up @@ -113,7 +113,7 @@ public class DatabaseModeSwitcher: UIView {
return CGSize(width: UIViewNoIntrinsicMetric, height: 55)
}

// MARK:- Internal
// MARK: - Internal

func selectedIndex(_ sender: UISegmentedControl) {
self.onSelectionChange(self)
Expand Down
Loading

0 comments on commit b07692b

Please sign in to comment.