Fixed almost all Swiftlint warnings
This commit is contained in:
parent
e994b53573
commit
3b7e548f70
|
@ -11,3 +11,4 @@ disabled_rules:
|
|||
- valid_docs
|
||||
- todo
|
||||
- variable_name_min_length
|
||||
- trailing_whitespace
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
// Created by Kenza Iraki on 2017-03-12.
|
||||
// Copyright © 2017 Goktug Yilmaz. All rights reserved.
|
||||
//
|
||||
// swiftlint:disable line_length
|
||||
|
||||
#if os(iOS) || os(tvOS)
|
||||
|
||||
|
@ -13,7 +14,6 @@ import UIKit
|
|||
@available(iOS 9.0, *)
|
||||
extension UIStackView {
|
||||
|
||||
|
||||
/// EZSwiftExtensions: Convenience initializer in order to directly pass the distribution, alignment, axis and spacing of the stack view.
|
||||
///
|
||||
/// - Parameters:
|
||||
|
|
|
@ -18,7 +18,8 @@ open class BlockSwipe: UISwipeGestureRecognizer {
|
|||
super.init(target: target, action: action)
|
||||
}
|
||||
|
||||
public convenience init (direction: UISwipeGestureRecognizerDirection,
|
||||
public convenience init (
|
||||
direction: UISwipeGestureRecognizerDirection,
|
||||
fingerCount: Int = 1,
|
||||
action: ((UISwipeGestureRecognizer) -> Void)?) {
|
||||
self.init()
|
||||
|
|
|
@ -27,7 +27,6 @@ extension Collection {
|
|||
return res
|
||||
}
|
||||
|
||||
|
||||
/// EZSE : Helper method to get an array of collection indices
|
||||
private func indicesArray() -> [Self.Index] {
|
||||
var indicesArray: [Self.Index] = []
|
||||
|
|
|
@ -119,7 +119,10 @@ extension Dictionary {
|
|||
|
||||
/// EZSE: Unserialize JSON string into Dictionary
|
||||
public static func constructFromJSON (json: String) -> Dictionary? {
|
||||
if let data = (try? JSONSerialization.jsonObject(with: json.data(using: String.Encoding.utf8, allowLossyConversion: true)!, options: JSONSerialization.ReadingOptions.mutableContainers)) as? Dictionary {
|
||||
if let data = (try? JSONSerialization.jsonObject(
|
||||
with: json.data(using: String.Encoding.utf8,
|
||||
allowLossyConversion: true)!,
|
||||
options: JSONSerialization.ReadingOptions.mutableContainers)) as? Dictionary {
|
||||
return data
|
||||
} else {
|
||||
return nil
|
||||
|
|
|
@ -202,7 +202,7 @@ public struct ez {
|
|||
/// EZSE: Calls action when a screen shot is taken
|
||||
public static func detectScreenShot(_ action: @escaping () -> Void) {
|
||||
let mainQueue = OperationQueue.main
|
||||
NotificationCenter.default.addObserver(forName: NSNotification.Name.UIApplicationUserDidTakeScreenshot, object: nil, queue: mainQueue) { notification in
|
||||
NotificationCenter.default.addObserver(forName: NSNotification.Name.UIApplicationUserDidTakeScreenshot, object: nil, queue: mainQueue) { _ in
|
||||
// executes after screenshot
|
||||
action()
|
||||
}
|
||||
|
@ -254,7 +254,10 @@ public struct ez {
|
|||
}
|
||||
|
||||
/// EZSE: Runs every second, to cancel use: timer.invalidate()
|
||||
@discardableResult public static func runThisEvery(seconds: TimeInterval, startAfterSeconds: TimeInterval, handler: @escaping (CFRunLoopTimer?) -> Void) -> Timer {
|
||||
@discardableResult public static func runThisEvery(
|
||||
seconds: TimeInterval,
|
||||
startAfterSeconds: TimeInterval,
|
||||
handler: @escaping (CFRunLoopTimer?) -> Void) -> Timer {
|
||||
let fireDate = startAfterSeconds + CFAbsoluteTimeGetCurrent()
|
||||
let timer = CFRunLoopTimerCreateWithHandler(kCFAllocatorDefault, fireDate, seconds, 0, 0, handler)
|
||||
CFRunLoopAddTimer(CFRunLoopGetCurrent(), timer, CFRunLoopMode.commonModes)
|
||||
|
@ -341,7 +344,7 @@ public struct ez {
|
|||
json = nil
|
||||
}
|
||||
|
||||
if let _ = error {
|
||||
if error != nil {
|
||||
return nil
|
||||
} else {
|
||||
return json
|
||||
|
@ -360,7 +363,7 @@ public struct ez {
|
|||
|
||||
URLSession.shared.dataTask(
|
||||
with: URLRequest(url: requestURL),
|
||||
completionHandler: { data, response, err in
|
||||
completionHandler: { data, _, err in
|
||||
if let e = err {
|
||||
error?(e as NSError)
|
||||
} else {
|
||||
|
|
|
@ -6,7 +6,6 @@
|
|||
// Copyright (c) 2015 Goktug Yilmaz. All rights reserved.
|
||||
//
|
||||
// swiftlint:disable line_length
|
||||
// swiftlint:disable trailing_whitespace
|
||||
|
||||
#if os(OSX)
|
||||
import AppKit
|
||||
|
@ -284,7 +283,7 @@ extension String {
|
|||
|
||||
/// EZSE: Returns if String is a number
|
||||
public func isNumber() -> Bool {
|
||||
if let _ = NumberFormatter().number(from: self) {
|
||||
if NumberFormatter().number(from: self) != nil {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
|
@ -303,8 +302,7 @@ extension String {
|
|||
let text = self
|
||||
|
||||
if let detector = detector {
|
||||
detector.enumerateMatches(in: text, options: [], range: NSRange(location: 0, length: text.characters.count), using: {
|
||||
(result: NSTextCheckingResult?, flags: NSRegularExpression.MatchingFlags, stop: UnsafeMutablePointer<ObjCBool>) -> Void in
|
||||
detector.enumerateMatches(in: text, options: [], range: NSRange(location: 0, length: text.characters.count), using: {(result: NSTextCheckingResult?, _, _) -> Void in
|
||||
if let result = result, let url = result.url {
|
||||
urls.append(url)
|
||||
}
|
||||
|
@ -357,10 +355,8 @@ extension String {
|
|||
|
||||
///EZSE: Returns the first index of the occurency of the character in String
|
||||
public func getIndexOf(_ char: Character) -> Int? {
|
||||
for (index, c) in characters.enumerated() {
|
||||
if c == char {
|
||||
return index
|
||||
}
|
||||
for (index, c) in characters.enumerated() where c == char {
|
||||
return index
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
|
|
@ -33,19 +33,19 @@ public enum FontType: String {
|
|||
|
||||
/// EZSwiftExtensions
|
||||
public enum FontName: String {
|
||||
case HelveticaNeue = "HelveticaNeue"
|
||||
case Helvetica = "Helvetica"
|
||||
case Futura = "Futura"
|
||||
case Menlo = "Menlo"
|
||||
case Avenir = "Avenir"
|
||||
case AvenirNext = "AvenirNext"
|
||||
case Didot = "Didot"
|
||||
case AmericanTypewriter = "AmericanTypewriter"
|
||||
case Baskerville = "Baskerville"
|
||||
case Geneva = "Geneva"
|
||||
case GillSans = "GillSans"
|
||||
case SanFranciscoDisplay = "SanFranciscoDisplay"
|
||||
case Seravek = "Seravek"
|
||||
case HelveticaNeue
|
||||
case Helvetica
|
||||
case Futura
|
||||
case Menlo
|
||||
case Avenir
|
||||
case AvenirNext
|
||||
case Didot
|
||||
case AmericanTypewriter
|
||||
case Baskerville
|
||||
case Geneva
|
||||
case GillSans
|
||||
case SanFranciscoDisplay
|
||||
case Seravek
|
||||
}
|
||||
|
||||
extension UIFont {
|
||||
|
|
|
@ -15,7 +15,7 @@ extension UISlider {
|
|||
public func setValue(_ value: Float, duration: Double) {
|
||||
UIView.animate(withDuration: duration, animations: { () -> Void in
|
||||
self.setValue(self.value, animated: true)
|
||||
}, completion: { (bool) -> Void in
|
||||
}, completion: { (_) -> Void in
|
||||
UIView.animate(withDuration: duration, animations: { () -> Void in
|
||||
self.setValue(value, animated: true)
|
||||
}, completion: nil)
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
// Created by Wang Yu on 6/26/16.
|
||||
// Copyright © 2016 Goktug Yilmaz. All rights reserved.
|
||||
//
|
||||
// swiftlint:disable line_length
|
||||
|
||||
#if os(iOS) || os(tvOS)
|
||||
|
||||
|
@ -14,7 +15,6 @@ extension UITextField {
|
|||
/// EZSE: Regular exp for email
|
||||
static let emailRegex = "(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*|\"(?:[\\x01-\\x08\\x0b\\x0c\\x0e-\\x1f\\x21\\x23-\\x5b\\x5d-\\x7f]|\\\\[\\x01-\\x09\\x0b\\x0c\\x0e-\\x7f])*\")@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\\[(?:(?:(2(5[0-5]|[0-4][0-9])|1[0-9][0-9]|[1-9]?[0-9]))\\.){3}(?:(2(5[0-5]|[0-4][0-9])|1[0-9][0-9]|[1-9]?[0-9])|[a-z0-9-]*[a-z0-9]:(?:[\\x01-\\x08\\x0b\\x0c\\x0e-\\x1f\\x21-\\x5a\\x53-\\x7f]|\\\\[\\x01-\\x09\\x0b\\x0c\\x0e-\\x7f])+)\\])"
|
||||
|
||||
|
||||
/// EZSwiftExtensions: Automatically sets these values: backgroundColor = clearColor, textColor = ThemeNicknameColor, clipsToBounds = true,
|
||||
/// textAlignment = Left, userInteractionEnabled = true, editable = false, scrollEnabled = false, font = ThemeFontName, fontsize = 17
|
||||
public convenience init(x: CGFloat, y: CGFloat, w: CGFloat, h: CGFloat) {
|
||||
|
@ -91,4 +91,4 @@ extension UITextField {
|
|||
return digitsTest.evaluate(with: self.text)
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
//
|
||||
// Created by Goktug Yilmaz on 15/07/15.
|
||||
// Copyright (c) 2015 Goktug Yilmaz. All rights reserved.
|
||||
// swiftlint:disable trailing_whitespace
|
||||
|
||||
#if os(iOS) || os(tvOS)
|
||||
|
||||
|
@ -231,7 +230,7 @@ extension UIViewController {
|
|||
}
|
||||
|
||||
/// EZSE: Hide or show navigation bar
|
||||
public var isNavBarHidden:Bool {
|
||||
public var isNavBarHidden: Bool {
|
||||
get {
|
||||
return (navigationController?.isNavigationBarHidden)!
|
||||
}
|
||||
|
|
|
@ -447,9 +447,9 @@ extension UIView {
|
|||
//EZSE: Reverse pop, good for button animations
|
||||
public func reversePop() {
|
||||
setScale(x: 0.9, y: 0.9)
|
||||
UIView.animate(withDuration: 0.05, delay: 0, options: UIViewAnimationOptions.allowUserInteraction, animations: { [weak self] Void in
|
||||
UIView.animate(withDuration: 0.05, delay: 0, options: UIViewAnimationOptions.allowUserInteraction, animations: { [weak self] _ in
|
||||
self?.setScale(x: 1, y: 1)
|
||||
}) { (bool) in }
|
||||
}) { (_) in }
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
// Copyright (c) 2016 Goktug Yilmaz. All rights reserved.
|
||||
//
|
||||
// swiftlint:disable line_length
|
||||
// swiftlint:disable trailing_whitespace
|
||||
|
||||
#if os(iOS) || os(tvOS)
|
||||
|
||||
|
@ -33,7 +32,7 @@ extension URL {
|
|||
let request = NSMutableURLRequest(url: self, cachePolicy: NSURLRequest.CachePolicy.reloadIgnoringLocalAndRemoteCacheData, timeoutInterval: timeoutInterval)
|
||||
request.httpMethod = "HEAD"
|
||||
request.setValue("", forHTTPHeaderField: "Accept-Encoding")
|
||||
URLSession.shared.dataTask(with: request as URLRequest) { (data, response, error) in
|
||||
URLSession.shared.dataTask(with: request as URLRequest) { (_, response, _) in
|
||||
let contentLength: Int64 = response?.expectedContentLength ?? NSURLSessionTransferSizeUnknown
|
||||
DispatchQueue.global(qos: .default).async(execute: {
|
||||
completionHandler(contentLength)
|
||||
|
|
Loading…
Reference in New Issue