Skip to content

Commit

Permalink
[Project] Enable more swiftlint rules
Browse files Browse the repository at this point in the history
  • Loading branch information
Hugo Tunius committed Jul 25, 2017
1 parent d41fa3b commit 1e2626e
Show file tree
Hide file tree
Showing 8 changed files with 62 additions and 51 deletions.
17 changes: 14 additions & 3 deletions .swiftlint.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,19 @@
disabled_rules:
opt_in_rules:
- closure_end_indentation
- closure_spacing
- conditional_returns_on_newline
- empty_count
- explicit_type_interface
- first_where
- implicit_return
- let_var_whitespace
- multiline_parameters
- number_separator
- operator_usage_whitespace
included:
- ../Sources
- .
- Package.swift
- ../Sources
- .
- Package.swift
excluded:

Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
styles.placeholderFont = .systemFont(ofSize: 14, weight: 0.1)

// Line
styles.lineHeight = 2
styles.lineHeight = 2
styles.lineColor = .brown

// Selected line
Expand All @@ -66,11 +66,11 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
iconStyles.selectedIconColor = .orange

// Icon font
iconStyles.iconFont = UIFont(name: "FontAwesome", size: 15)
iconStyles.iconFont = UIFont(name: "FontAwesome", size: 15)

// Icon margins
iconStyles.iconMarginLeft = 5
iconStyles.iconMarginBottom = 5
iconStyles.iconMarginLeft = 5
iconStyles.iconMarginBottom = 5
}

return true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ class ShowcaseExampleViewController: UIViewController, UITextFieldDelegate {
@IBOutlet weak var emailField: SkyFloatingLabelTextField!
@IBOutlet weak var submitButton: UIButton!

var textFields: [SkyFloatingLabelTextField]!
var textFields: [SkyFloatingLabelTextField] = []

let lightGreyColor = UIColor(red: 197/255, green: 205/255, blue: 205/255, alpha: 1.0)
let darkGreyColor = UIColor(red: 52/255, green: 42/255, blue: 61/255, alpha: 1.0)
let overcastBlueColor = UIColor(red: 0, green: 187/255, blue: 204/255, alpha: 1.0)
let lightGreyColor: UIColor = UIColor(red: 197 / 255, green: 205 / 255, blue: 205 / 255, alpha: 1.0)
let darkGreyColor: UIColor = UIColor(red: 52 / 255, green: 42 / 255, blue: 61 / 255, alpha: 1.0)
let overcastBlueColor: UIColor = UIColor(red: 0, green: 187 / 255, blue: 204 / 255, alpha: 1.0)

override func viewDidLoad() {
super.viewDidLoad()
Expand Down Expand Up @@ -189,9 +189,9 @@ class ShowcaseExampleViewController: UIViewController, UITextFieldDelegate {

// MARK: - Validating the fields when "submit" is pressed

var isSubmitButtonPressed = false
var isSubmitButtonPressed: Bool = false

var showingTitleInProgress = false
var showingTitleInProgress: Bool = false

@IBAction func submitButtonDown(_ sender: AnyObject) {
self.isSubmitButtonPressed = true
Expand Down Expand Up @@ -261,7 +261,7 @@ class ShowcaseExampleViewController: UIViewController, UITextFieldDelegate {
return
}

if email.characters.count == 0 {
if email.characters.isEmpty {
emailField.errorMessage = nil
} else if !validateEmail(email) {
emailField.errorMessage = NSLocalizedString(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class SubclassingViewController: UIViewController {
super.viewDidLoad()

// SkyFloatingLabelTextField will inherit it's superview's `tintColor`.
self.view.tintColor = UIColor(red: 0.0, green: 221.0/256.0, blue: 238.0/256.0, alpha: 1.0)
self.view.tintColor = UIColor(red: 0.0, green: 221.0 / 256.0, blue: 238.0 / 256.0, alpha: 1.0)
textField?.placeholder = NSLocalizedString("Placeholder", tableName: "SkyFloatingLabelTextField", comment: "")
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,37 +22,37 @@ class SkyFloatingLabelTextFieldAppearanceTests: XCTestCase {
let styles = SkyFloatingLabelTextField.appearance()

// Text-, placeholder- and tintcolor
styles.textColor = UIColor.brown
styles.tintColor = UIColor.brown
styles.placeholderColor = UIColor.darkGray
styles.textColor = UIColor.brown
styles.tintColor = UIColor.brown
styles.placeholderColor = UIColor.darkGray
styles.selectedTitleColor = UIColor.orange
styles.errorColor = UIColor.purple
styles.errorColor = UIColor.purple

// Fonts
styles.font = UIFont(name: "HelveticaNeue-Bold", size: 14)!
styles.placeholderFont = UIFont(name: "HelveticaNeue-Medium", size: 14)!
styles.font = UIFont(name: "HelveticaNeue-Bold", size: 14)!
styles.placeholderFont = UIFont(name: "HelveticaNeue-Medium", size: 14)!

// Line
styles.lineHeight = 2
styles.lineColor = UIColor.brown
styles.lineHeight = 2
styles.lineColor = UIColor.brown

// Selected line
styles.selectedLineHeight = 3
styles.selectedLineColor = UIColor.orange
styles.selectedLineColor = UIColor.orange

// Apply icon styles
let iconStyles = SkyFloatingLabelTextFieldWithIcon.appearance()

// Icon colors
iconStyles.iconColor = UIColor.brown
iconStyles.selectedIconColor = UIColor.orange
iconStyles.iconColor = UIColor.brown
iconStyles.selectedIconColor = UIColor.orange

// Icon font
iconStyles.iconFont = UIFont(name: "FontAwesome", size: 15)
iconStyles.iconFont = UIFont(name: "FontAwesome", size: 15)

// Icon margins
iconStyles.iconMarginLeft = 5
iconStyles.iconMarginBottom = 5
iconStyles.iconMarginLeft = 5
iconStyles.iconMarginBottom = 5
}

override func tearDown() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ import XCTest
class SkyFloatingLabelTextFieldTests: XCTestCase { // swiftlint:disable:this type_body_length

var floatingLabelTextField: SkyFloatingLabelTextField!
let customColor = UIColor(red: 125/255, green: 120/255, blue: 50/255, alpha: 1.0)
let textFieldDelegateMock = TextFieldDelegateMock()
let customColor: UIColor = UIColor(red: 125 / 255, green: 120 / 255, blue: 50 / 255, alpha: 1.0)
let textFieldDelegateMock: TextFieldDelegateMock = TextFieldDelegateMock()

override func setUp() {
super.setUp()
Expand Down Expand Up @@ -720,20 +720,20 @@ class SkyFloatingLabelTextFieldTests: XCTestCase { // swiftlint:disable:this typ
}

class TextFieldDelegateMock: NSObject, UITextFieldDelegate {
var textFieldShouldBeginEditing = false
var textFieldShouldEndEditing = false
var textFieldShouldReturn = false
var textFieldShouldClear = false
var shouldChangeCharactersInRange = false

var textFieldChangedInvoked = false
var textFieldShouldBeginEditingInvoked = false
var textFieldShouldEndEditingInvoked = false
var textFieldDidBeginEditingInvoked = false
var textFieldDidEndEditingInvoked = false
var textFieldShouldReturnInvoked = false
var textFieldShouldClearInvoked = false
var shouldChangeCharactersInRangeInvoked = false
var textFieldShouldBeginEditing: Bool = false
var textFieldShouldEndEditing: Bool = false
var textFieldShouldReturn: Bool = false
var textFieldShouldClear: Bool = false
var shouldChangeCharactersInRange: Bool = false

var textFieldChangedInvoked: Bool = false
var textFieldShouldBeginEditingInvoked: Bool = false
var textFieldShouldEndEditingInvoked: Bool = false
var textFieldDidBeginEditingInvoked: Bool = false
var textFieldDidEndEditingInvoked: Bool = false
var textFieldShouldReturnInvoked: Bool = false
var textFieldShouldClearInvoked: Bool = false
var shouldChangeCharactersInRangeInvoked: Bool = false

func textFieldDidBeginEditing(_ textField: UITextField) {
textFieldDidBeginEditingInvoked = true
Expand Down Expand Up @@ -778,7 +778,7 @@ class SkyFloatingLabelTextFieldTests: XCTestCase { // swiftlint:disable:this typ
}

class SkyFloatingLabelTextFieldSpy: SkyFloatingLabelTextField {
var updateColorsInvoked = false
var updateColorsInvoked: Bool = false

override func updateColors() {
updateColorsInvoked = true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import XCTest
class SkyFloatingLabelTextFieldWithIconTests: XCTestCase {

var floatingLabelTextFieldWithIcon: SkyFloatingLabelTextFieldWithIcon!
let customColor = UIColor(red: 125/255, green: 120/255, blue: 50/255, alpha: 1.0)
let customColor: UIColor = UIColor(red: 125 / 255, green: 120 / 255, blue: 50 / 255, alpha: 1.0)

override func setUp() {
super.setUp()
Expand Down
8 changes: 4 additions & 4 deletions Sources/SkyFloatingLabelTextField.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ open class SkyFloatingLabelTextField: UITextField { // swiftlint:disable:this ty
A Boolean value that determines if the language displayed is LTR.
Default value set automatically from the application language settings.
*/
open var isLTRLanguage = UIApplication.shared.userInterfaceLayoutDirection == .leftToRight {
open var isLTRLanguage: Bool = UIApplication.shared.userInterfaceLayoutDirection == .leftToRight {
didSet {
updateTextAligment()
}
Expand Down Expand Up @@ -182,7 +182,7 @@ open class SkyFloatingLabelTextField: UITextField { // swiftlint:disable:this ty
}

/// The backing property for the highlighted property
fileprivate var _highlighted = false
fileprivate var _highlighted: Bool = false

/**
A Boolean value that determines whether the receiver is highlighted.
Expand Down Expand Up @@ -345,7 +345,7 @@ open class SkyFloatingLabelTextField: UITextField { // swiftlint:disable:this ty
*/
@discardableResult
override open func resignFirstResponder() -> Bool {
let result = super.resignFirstResponder()
let result = super.resignFirstResponder()
updateControl(true)
return result
}
Expand Down Expand Up @@ -425,7 +425,7 @@ open class SkyFloatingLabelTextField: UITextField { // swiftlint:disable:this ty
updateTitleVisibility(animated)
}

fileprivate var _titleVisible = false
fileprivate var _titleVisible: Bool = false

/*
* Set this value to make the title visible
Expand Down

0 comments on commit 1e2626e

Please sign in to comment.