Permalink
22946 lines (17270 sloc) 326 KB

Rules


AnyObject Protocol

Identifier Enabled by default Supports autocorrection Kind Analyzer Minimum Swift Compiler Version
anyobject_protocol Disabled Yes lint No 4.1.0

Prefer using AnyObject over class for class-only protocols.

Examples

Non Triggering Examples
protocol SomeProtocol {}
protocol SomeClassOnlyProtocol: AnyObject {}
protocol SomeClassOnlyProtocol: AnyObject, SomeInheritedProtocol {}
@objc protocol SomeClassOnlyProtocol: AnyObject, SomeInheritedProtocol {}
Triggering Examples
protocol SomeClassOnlyProtocol: ↓class {}
protocol SomeClassOnlyProtocol: ↓class, SomeInheritedProtocol {}
@objc protocol SomeClassOnlyProtocol: ↓class, SomeInheritedProtocol {}

Array Init

Identifier Enabled by default Supports autocorrection Kind Analyzer Minimum Swift Compiler Version
array_init Disabled No lint No 3.0.0

Prefer using Array(seq) over seq.map { $0 } to convert a sequence into an Array.

Examples

Non Triggering Examples
Array(foo)
foo.map { $0.0 }
foo.map { $1 }
foo.map { $0() }
foo.map { ((), $0) }
foo.map { $0! }
foo.map { $0! /* force unwrap */ }
foo.something { RouteMapper.map($0) }
Triggering Examples
foo.map({ $0 })
foo.map { $0 }
foo.map { return $0 }
foo.map { elem in
   elem
}
foo.map { elem in
   return elem
}
foo.map { (elem: String) in
   elem
}
foo.map { elem -> String in
   elem
}
foo.map { $0 /* a comment */ }

Attributes

Identifier Enabled by default Supports autocorrection Kind Analyzer Minimum Swift Compiler Version
attributes Disabled No style No 3.0.0

Attributes should be on their own lines in functions and types, but on the same line as variables and imports.

Examples

Non Triggering Examples
@objc var x: String
@objc private var x: String
@nonobjc var x: String
@IBOutlet private var label: UILabel
@IBOutlet @objc private var label: UILabel
@NSCopying var name: NSString
@NSManaged var name: String?
@IBInspectable var cornerRadius: CGFloat
@available(iOS 9.0, *)
 let stackView: UIStackView
@NSManaged func addSomeObject(book: SomeObject)
@IBAction func buttonPressed(button: UIButton)
@objc
 @IBAction func buttonPressed(button: UIButton)
@available(iOS 9.0, *)
 func animate(view: UIStackView)
@available(iOS 9.0, *, message="A message")
 func animate(view: UIStackView)
@nonobjc
 final class X
@available(iOS 9.0, *)
 class UIStackView
@NSApplicationMain
 class AppDelegate: NSObject, NSApplicationDelegate
@UIApplicationMain
 class AppDelegate: NSObject, UIApplicationDelegate
@IBDesignable
 class MyCustomView: UIView
@testable import SourceKittenFramework
@objc(foo_x)
 var x: String
@available(iOS 9.0, *)
@objc(abc_stackView)
 let stackView: UIStackView
@objc(abc_addSomeObject:)
 @NSManaged func addSomeObject(book: SomeObject)
@objc(ABCThing)
 @available(iOS 9.0, *)
 class Thing
class Foo: NSObject {
 override var description: String { return "" }
}
class Foo: NSObject {

 override func setUp() {}
}
@objc
class ⽺ {}
extension Property {

 @available(*, unavailable, renamed: "isOptional")
public var optional: Bool { fatalError() }
}
@GKInspectable var maxSpeed: Float
@discardableResult
 func a() -> Int
@objc
 @discardableResult
 func a() -> Int
func increase(f: @autoclosure () -> Int) -> Int
func foo(completionHandler: @escaping () -> Void)
private struct DefaultError: Error {}
@testable import foo

private let bar = 1
import XCTest
@testable import DeleteMe

@available (iOS 11.0, *)
class DeleteMeTests: XCTestCase {
}
Triggering Examples
@objc
 var x: String
@objc

 var x: String
@objc
 private var x: String
@nonobjc
 var x: String
@IBOutlet
 private var label: UILabel
@IBOutlet

 private var label: UILabel
@NSCopying
 var name: NSString
@NSManaged
 var name: String?
@IBInspectable
 var cornerRadius: CGFloat
@available(iOS 9.0, *) let stackView: UIStackView
@NSManaged
 func addSomeObject(book: SomeObject)
@IBAction
 func buttonPressed(button: UIButton)
@IBAction
 @objc
 func buttonPressed(button: UIButton)
@available(iOS 9.0, *) func animate(view: UIStackView)
@nonobjc final class X
@available(iOS 9.0, *) class UIStackView
@available(iOS 9.0, *)
 @objc class UIStackView
@available(iOS 9.0, *) @objc
 class UIStackView
@available(iOS 9.0, *)

 class UIStackView
@UIApplicationMain class AppDelegate: NSObject, UIApplicationDelegate
@IBDesignable class MyCustomView: UIView
@testable
import SourceKittenFramework
@testable


import SourceKittenFramework
@objc(foo_x) var x: String
@available(iOS 9.0, *) @objc(abc_stackView)
 let stackView: UIStackView
@objc(abc_addSomeObject:) @NSManaged
 func addSomeObject(book: SomeObject)
@objc(abc_addSomeObject:)
 @NSManaged
 func addSomeObject(book: SomeObject)
@available(iOS 9.0, *)
 @objc(ABCThing) class Thing
@GKInspectable
 var maxSpeed: Float
@discardableResult func a() -> Int
@objc
 @discardableResult func a() -> Int
@objc

 @discardableResult
 func a() -> Int

Block Based KVO

Identifier Enabled by default Supports autocorrection Kind Analyzer Minimum Swift Compiler Version
block_based_kvo Enabled No idiomatic No 3.0.0

Prefer the new block based KVO API with keypaths when using Swift 3.2 or later.

Examples

Non Triggering Examples
let observer = foo.observe(\.value, options: [.new]) { (foo, change) in
   print(change.newValue)
}
Triggering Examples
class Foo: NSObject {
   override func observeValue(forKeyPath keyPath: String?, of object: Any?,
                               change: [NSKeyValueChangeKey : Any]?,
                               context: UnsafeMutableRawPointer?) {}
}
class Foo: NSObject {
   override func observeValue(forKeyPath keyPath: String?, of object: Any?,
                               change: Dictionary<NSKeyValueChangeKey, Any>?,
                               context: UnsafeMutableRawPointer?) {}
}

Class Delegate Protocol

Identifier Enabled by default Supports autocorrection Kind Analyzer Minimum Swift Compiler Version
class_delegate_protocol Enabled No lint No 3.0.0

Delegate protocols should be class-only so they can be weakly referenced.

Examples

Non Triggering Examples
protocol FooDelegate: class {}
protocol FooDelegate: class, BarDelegate {}
protocol Foo {}
class FooDelegate {}
@objc protocol FooDelegate {}
@objc(MyFooDelegate)
 protocol FooDelegate {}
protocol FooDelegate: BarDelegate {}
protocol FooDelegate: AnyObject {}
protocol FooDelegate: NSObjectProtocol {}
Triggering Examples
protocol FooDelegate {}
protocol FooDelegate: Bar {}

Closing Brace Spacing

Identifier Enabled by default Supports autocorrection Kind Analyzer Minimum Swift Compiler Version
closing_brace Enabled Yes style No 3.0.0

Closing brace with closing parenthesis should not have any whitespaces in the middle.

Examples

Non Triggering Examples
[].map({ })
[].map(
  { }
)
Triggering Examples
[].map({ } )
[].map({ }	)

Closure Body Length

Identifier Enabled by default Supports autocorrection Kind Analyzer Minimum Swift Compiler Version
closure_body_length Disabled No metrics No 4.2.0

Closure bodies should not span too many lines.

Examples

Non Triggering Examples
foo.bar { $0 }
foo.bar { toto in
}
foo.bar { toto in
	let a = 0
	// toto
	// toto
	// toto
	// toto
	// toto
	// toto
	// toto
	// toto
	// toto
	// toto
	
	
	
	
	
	
	
	
	
	
}
foo.bar { toto in
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
}
foo.bar { toto in
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	// toto
	// toto
	// toto
	// toto
	// toto
	// toto
	// toto
	// toto
	// toto
	// toto
	
	
	
	
	
	
	
	
	
	
}
foo.bar({ toto in
})
foo.bar({ toto in
	let a = 0
})
foo.bar({ toto in
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
})
foo.bar(label: { toto in
})
foo.bar(label: { toto in
	let a = 0
})
foo.bar(label: { toto in
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
})
foo.bar(label: { toto in
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
}, anotherLabel: { toto in
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
})
foo.bar(label: { toto in
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
}) { toto in
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
}
let foo: Bar = { toto in
	let bar = Bar()
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	return bar
}()
Triggering Examples
foo.bar { toto in
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
}
foo.bar { toto in
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	// toto
	// toto
	// toto
	// toto
	// toto
	// toto
	// toto
	// toto
	// toto
	// toto
	
	
	
	
	
	
	
	
	
	
}
foo.bar({ toto in
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
})
foo.bar(label: { toto in
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
})
foo.bar(label: { toto in
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
}, anotherLabel: { toto in
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
})
foo.bar(label: { toto in
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
}) { toto in
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
}
let foo: Bar = { toto in
	let bar = Bar()
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	let a = 0
	return bar
}()

Closure End Indentation

Identifier Enabled by default Supports autocorrection Kind Analyzer Minimum Swift Compiler Version
closure_end_indentation Disabled Yes style No 3.0.0

Closure end should have the same indentation as the line that started it.

Examples

Non Triggering Examples
SignalProducer(values: [1, 2, 3])
   .startWithNext { number in
       print(number)
   }
[1, 2].map { $0 + 1 }
return match(pattern: pattern, with: [.comment]).flatMap { range in
   return Command(string: contents, range: range)
}.flatMap { command in
   return command.expand()
}
foo(foo: bar,
    options: baz) { _ in }
someReallyLongProperty.chainingWithAnotherProperty
   .foo { _ in }
foo(abc, 123)
{ _ in }
function(
    closure: { x in
        print(x)
    },
    anotherClosure: { y in
        print(y)
    })
function(parameter: param,
         closure: { x in
    print(x)
})
function(parameter: param, closure: { x in
        print(x)
    },
    anotherClosure: { y in
        print(y)
    })
Triggering Examples
SignalProducer(values: [1, 2, 3])
   .startWithNext { number in
       print(number)
}
return match(pattern: pattern, with: [.comment]).flatMap { range in
   return Command(string: contents, range: range)
   }.flatMap { command in
   return command.expand()
}
function(
    closure: { x in
        print(x)
},
    anotherClosure: { y in
        print(y)
})

Closure Parameter Position

Identifier Enabled by default Supports autocorrection Kind Analyzer Minimum Swift Compiler Version
closure_parameter_position Enabled No style No 3.0.0

Closure parameters should be on the same line as opening brace.

Examples

Non Triggering Examples
[1, 2].map { $0 + 1 }
[1, 2].map({ $0 + 1 })
[1, 2].map { number in
 number + 1 
}
[1, 2].map { number -> Int in
 number + 1 
}
[1, 2].map { (number: Int) -> Int in
 number + 1 
}
[1, 2].map { [weak self] number in
 number + 1 
}
[1, 2].something(closure: { number in
 number + 1 
})
let isEmpty = [1, 2].isEmpty()
rlmConfiguration.migrationBlock.map { rlmMigration in
return { migration, schemaVersion in
rlmMigration(migration.rlmMigration, schemaVersion)
}
}
let mediaView: UIView = { [weak self] index in
   return UIView()
}(index)
Triggering Examples
[1, 2].map {
 number in
 number + 1 
}
[1, 2].map {
 number -> Int in
 number + 1 
}
[1, 2].map {
 (number: Int) -> Int in
 number + 1 
}
[1, 2].map {
 [weak self] number in
 number + 1 
}
[1, 2].map { [weak self]
 number in
 number + 1 
}
[1, 2].map({
 number in
 number + 1 
})
[1, 2].something(closure: {
 number in
 number + 1 
})
[1, 2].reduce(0) {
 sum, number in
 number + sum 
}

Closure Spacing

Identifier Enabled by default Supports autocorrection Kind Analyzer Minimum Swift Compiler Version
closure_spacing Disabled Yes style No 3.0.0

Closure expressions should have a single space inside each brace.

Examples

Non Triggering Examples
[].map ({ $0.description })
[].filter { $0.contains(location) }
extension UITableViewCell: ReusableView { }
extension UITableViewCell: ReusableView {}
Triggering Examples
[].filter({$0.contains(location)})
[].map({$0})
({each in return result.contains(where: {e in return e}) }).count
filter { sorted { $0 < $1}}

Collection Element Alignment

Identifier Enabled by default Supports autocorrection Kind Analyzer Minimum Swift Compiler Version
collection_alignment Disabled No style No 3.0.0

All elements in a collection literal should be vertically aligned

Examples

Non Triggering Examples
doThings(arg: [
    "foo": 1,
    "bar": 2,
    "fizz": 2,
    "buzz": 2
])
let abc = [
    "alpha": "a",
    "beta": "b",
    "gamma": "g",
    "delta": "d",
    "epsilon": "e"
]
let meals = [
                "breakfast": "oatmeal",
                "lunch": "sandwich",
                "dinner": "burger"
]
let coordinates = [
    CLLocationCoordinate2D(latitude: 0, longitude: 33),
    CLLocationCoordinate2D(latitude: 0, longitude: 66),
    CLLocationCoordinate2D(latitude: 0, longitude: 99)
]
var evenNumbers: Set<Int> = [
    2,
    4,
    6
]
let abc = [1, 2, 3, 4]
let abc = [
    1, 2, 3, 4
]
let abc = [
    "foo": "bar", "fizz": "buzz"
]
Triggering Examples
doThings(arg: [
    "foo": 1,
    "bar": 2,
   "fizz": 2,
   "buzz": 2
])
let abc = [
    "alpha": "a",
     "beta": "b",
    "gamma": "g",
    "delta": "d",
  "epsilon": "e"
]
let meals = [
                "breakfast": "oatmeal",
                "lunch": "sandwich",
    "dinner": "burger"
]
let coordinates = [
    CLLocationCoordinate2D(latitude: 0, longitude: 33),
        CLLocationCoordinate2D(latitude: 0, longitude: 66),
    CLLocationCoordinate2D(latitude: 0, longitude: 99)
]
var evenNumbers: Set<Int> = [
    2,
  4,
    6
]

Colon

Identifier Enabled by default Supports autocorrection Kind Analyzer Minimum Swift Compiler Version
colon Enabled Yes style No 3.0.0

Colons should be next to the identifier when specifying a type and next to the key in dictionary literals.

Examples

Non Triggering Examples
let abc: Void
let abc: [Void: Void]
let abc: (Void, Void)
let abc: ([Void], String, Int)
let abc: [([Void], String, Int)]
let abc: String="def"
let abc: Int=0
let abc: Enum=Enum.Value
func abc(def: Void) {}
func abc(def: Void, ghi: Void) {}
// 周斌佳年周斌佳
let abc: String = "abc:"
let abc = [Void: Void]()
let abc = [1: [3: 2], 3: 4]
let abc = ["string": "string"]
let abc = ["string:string": "string"]
let abc: [String: Int]
func foo(bar: [String: Int]) {}
func foo() -> [String: Int] { return [:] }
let abc: Any
let abc: [Any: Int]
let abc: [String: Any]
class Foo: Bar {}
class Foo<T: Equatable> {}
switch foo {
case .bar:
    _ = something()
}
object.method(x: 5, y: "string")
object.method(x: 5, y:
              "string")
object.method(5, y: "string")
func abc() { def(ghi: jkl) }
func abc(def: Void) { ghi(jkl: mno) }
class ABC { let def = ghi(jkl: mno) } }
func foo() { let dict = [1: 1] }
Triggering Examples
let abc:Void
let abc:  Void
let abc :Void
let abc : Void
let abc : [Void: Void]
let abc : (Void, String, Int)
let abc : ([Void], String, Int)
let abc : [([Void], String, Int)]
let abc:  (Void, String, Int)
let abc:  ([Void], String, Int)
let abc:  [([Void], String, Int)]
let abc :String="def"
let abc :Int=0
let abc :Int = 0
let abc:Int=0
let abc:Int = 0
let abc:Enum=Enum.Value
func abc(↓def:Void) {}
func abc(↓def:  Void) {}
func abc(↓def :Void) {}
func abc(↓def : Void) {}
func abc(def: Void, ↓ghi :Void) {}
let abc = [Void:Void]()
let abc = [Void : Void]()
let abc = [Void:  Void]()
let abc = [Void :  Void]()
let abc = [1: [3 : 2], 3: 4]
let abc = [1: [3 : 2], 3:  4]
let abc: [String : Int]
let abc: [String:Int]
func foo(bar: [↓String : Int]) {}
func foo(bar: [↓String:Int]) {}
func foo() -> [↓String : Int] { return [:] }
func foo() -> [↓String:Int] { return [:] }
let abc : Any
let abc: [Any : Int]
let abc: [String : Any]
class Foo : Bar {}
class Foo:Bar {}
class Foo<↓T:Equatable> {}
class Foo<↓T : Equatable> {}
object.method(x: 5, y : "string")
object.method(x:5, y: "string")
object.method(x:  5, y: "string")
func abc() { def(ghi:jkl) }
func abc(def: Void) { ghi(jkl:mno) }
class ABC { let def = ghi(jkl:mno) } }
func foo() { let dict = [1 : 1] }

Comma Spacing

Identifier Enabled by default Supports autocorrection Kind Analyzer Minimum Swift Compiler Version
comma Enabled Yes style No 3.0.0

There should be no space before and one after any comma.

Examples

Non Triggering Examples
func abc(a: String, b: String) { }
abc(a: "string", b: "string"
enum a { case a, b, c }
func abc(
  a: String,  // comment
  bcd: String // comment
) {
}
func abc(
  a: String,
  bcd: String
) {
}
#imageLiteral(resourceName: "foo,bar,baz")
Triggering Examples
func abc(a: String↓ ,b: String) { }
func abc(a: String↓ ,b: String↓ ,c: String↓ ,d: String) { }
abc(a: "string",b: "string"
enum a { case a ,b }
let result = plus(
    first: 3 , // #683
    second: 4
)

Compiler Protocol Init

Identifier Enabled by default Supports autocorrection Kind Analyzer Minimum Swift Compiler Version
compiler_protocol_init Enabled No lint No 3.0.0

The initializers declared in compiler protocols such as ExpressibleByArrayLiteral shouldn't be called directly.

Examples

Non Triggering Examples
let set: Set<Int> = [1, 2]
let set = Set(array)
Triggering Examples
let set = Set(arrayLiteral: 1, 2)
let set = Set.init(arrayLiteral: 1, 2)

Conditional Returns on Newline

Identifier Enabled by default Supports autocorrection Kind Analyzer Minimum Swift Compiler Version
conditional_returns_on_newline Disabled No style No 3.0.0

Conditional statements should always return on the next line

Examples

Non Triggering Examples
guard true else {
 return true
}
guard true,
 let x = true else {
 return true
}
if true else {
 return true
}
if true,
 let x = true else {
 return true
}
if textField.returnKeyType == .Next {
if true { // return }
/*if true { */ return }
Triggering Examples
guard true else { return }
if true { return }
if true { break } else { return }
if true { break } else {       return }
if true { return "YES" } else { return "NO" }

Contains over first not nil

Identifier Enabled by default Supports autocorrection Kind Analyzer Minimum Swift Compiler Version
contains_over_first_not_nil Disabled No performance No 3.0.0

Prefer contains over first(where:) != nil

Examples

Non Triggering Examples
let first = myList.first(where: { $0 % 2 == 0 })
let first = myList.first { $0 % 2 == 0 }
Triggering Examples
myList.first { $0 % 2 == 0 } != nil
myList.first(where: { $0 % 2 == 0 }) != nil
myList.map { $0 + 1 }.first(where: { $0 % 2 == 0 }) != nil
myList.first(where: someFunction) != nil
myList.map { $0 + 1 }.first { $0 % 2 == 0 } != nil
(myList.first { $0 % 2 == 0 }) != nil

Control Statement

Identifier Enabled by default Supports autocorrection Kind Analyzer Minimum Swift Compiler Version
control_statement Enabled No style No 3.0.0

if, for, guard, switch, while, and catch statements shouldn't unnecessarily wrap their conditionals or arguments in parentheses.

Examples

Non Triggering Examples
if condition {
if (a, b) == (0, 1) {
if (a || b) && (c || d) {
if (min...max).contains(value) {
if renderGif(data) {
renderGif(data)
for item in collection {
for (key, value) in dictionary {
for (index, value) in enumerate(array) {
for var index = 0; index < 42; index++ {
guard condition else {
while condition {
} while condition {
do { ; } while condition {
switch foo {
do {
} catch let error as NSError {
}
foo().catch(all: true) {}
if max(a, b) < c {
switch (lhs, rhs) {
Triggering Examples
if (condition) {
if(condition) {
if (condition == endIndex) {
if ((a || b) && (c || d)) {
if ((min...max).contains(value)) {
for (item in collection) {
for (var index = 0; index < 42; index++) {
for(item in collection) {
for(var index = 0; index < 42; index++) {
guard (condition) else {
while (condition) {
while(condition) {
} while (condition) {
} while(condition) {
do { ; } while(condition) {
do { ; } while (condition) {
switch (foo) {
do {
} catch(let error as NSError) {
}
if (max(a, b) < c) {

Convenience Type

Identifier Enabled by default Supports autocorrection Kind Analyzer Minimum Swift Compiler Version
convenience_type Disabled No idiomatic No 4.1.0

Types used for hosting only static members should be implemented as a caseless enum to avoid instantiation.

Examples

Non Triggering Examples
enum Math { // enum
    public static let pi = 3.14
}
// class with inheritance
class MathViewController: UIViewController {
    public static let pi = 3.14
}
@objc class Math: NSObject { // class visible to Obj-C
    public static let pi = 3.14
}
struct Math { // type with non-static declarations
    public static let pi = 3.14
    public let randomNumber = 2
}
class DummyClass {}
Triggering Examples
struct Math {
    public static let pi = 3.14
}
class Math {
    public static let pi = 3.14
}
struct Math {
    public static let pi = 3.14
    @available(*, unavailable) init() {}
}

Custom Rules

Identifier Enabled by default Supports autocorrection Kind Analyzer Minimum Swift Compiler Version
custom_rules Enabled No style No 3.0.0

Create custom rules by providing a regex string. Optionally specify what syntax kinds to match against, the severity level, and what message to display.

Cyclomatic Complexity

Identifier Enabled by default Supports autocorrection Kind Analyzer Minimum Swift Compiler Version
cyclomatic_complexity Enabled No metrics No 3.0.0

Complexity of function bodies should be limited.

Examples

Non Triggering Examples
func f1() {
if true {
for _ in 1..5 { } }
if false { }
}
func f(code: Int) -> Int {switch code {
 case 0: fallthrough
case 0: return 1
case 0: return 1
case 0: return 1
case 0: return 1
case 0: return 1
case 0: return 1
case 0: return 1
case 0: return 1
default: return 1}}
func f1() {if true {}; if true {}; if true {}; if true {}; if true {}; if true {}
func f2() {
if true {}; if true {}; if true {}; if true {}; if true {}
}}
Triggering Examples
func f1() {
  if true {
    if true {
      if false {}
    }
  }
  if false {}
  let i = 0

  switch i {
  case 1: break
  case 2: break
  case 3: break
  case 4: break
 default: break
  }
  for _ in 1...5 {
    guard true else {
      return
    }
  }
}

Discarded Notification Center Observer

Identifier Enabled by default Supports autocorrection Kind Analyzer Minimum Swift Compiler Version
discarded_notification_center_observer Enabled No lint No 3.0.0

When registering for a notification using a block, the opaque observer that is returned should be stored so it can be removed later.

Examples

Non Triggering Examples
let foo = nc.addObserver(forName: .NSSystemTimeZoneDidChange, object: nil, queue: nil) { }
let foo = nc.addObserver(forName: .NSSystemTimeZoneDidChange, object: nil, queue: nil, using: { })
func foo() -> Any {
   return nc.addObserver(forName: .NSSystemTimeZoneDidChange, object: nil, queue: nil, using: { })
}
Triggering Examples
nc.addObserver(forName: .NSSystemTimeZoneDidChange, object: nil, queue: nil) { }
nc.addObserver(forName: .NSSystemTimeZoneDidChange, object: nil, queue: nil, using: { })
@discardableResult func foo() -> Any {
   return nc.addObserver(forName: .NSSystemTimeZoneDidChange, object: nil, queue: nil, using: { })
}

Discouraged Direct Initialization

Identifier Enabled by default Supports autocorrection Kind Analyzer Minimum Swift Compiler Version
discouraged_direct_init Enabled No lint No 3.0.0

Discouraged direct initialization of types that can be harmful.

Examples

Non Triggering Examples
let foo = UIDevice.current
let foo = Bundle.main
let foo = Bundle(path: "bar")
let foo = Bundle(identifier: "bar")
let foo = Bundle.init(path: "bar")
let foo = Bundle.init(identifier: "bar")
Triggering Examples
UIDevice()
Bundle()
let foo = UIDevice()
let foo = Bundle()
let foo = bar(bundle: Bundle(), device: UIDevice())
UIDevice.init()
Bundle.init()
let foo = UIDevice.init()
let foo = Bundle.init()
let foo = bar(bundle: Bundle.init(), device: UIDevice.init())

Discouraged Object Literal

Identifier Enabled by default Supports autocorrection Kind Analyzer Minimum Swift Compiler Version
discouraged_object_literal Disabled No idiomatic No 3.0.0

Prefer initializers over object literals.

Examples

Non Triggering Examples
let image = UIImage(named: aVariable)
let image = UIImage(named: "interpolated \(variable)")
let color = UIColor(red: value, green: value, blue: value, alpha: 1)
let image = NSImage(named: aVariable)
let image = NSImage(named: "interpolated \(variable)")
let color = NSColor(red: value, green: value, blue: value, alpha: 1)
Triggering Examples
let image = #imageLiteral(resourceName: "image.jpg")
let color = #colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)

Discouraged Optional Boolean

Identifier Enabled by default Supports autocorrection Kind Analyzer Minimum Swift Compiler Version
discouraged_optional_boolean Disabled No idiomatic No 3.0.0

Prefer non-optional booleans over optional booleans.

Examples

Non Triggering Examples
var foo: Bool
var foo: [String: Bool]
var foo: [Bool]
let foo: Bool = true
let foo: Bool = false
let foo: [String: Bool] = [:]
let foo: [Bool] = []
var foo: Bool { return true }
let foo: Bool { return false }()
func foo() -> Bool {}
func foo() -> [String: Bool] {}
func foo() -> ([Bool]) -> String {}
func foo(input: Bool = true) {}
func foo(input: [String: Bool] = [:]) {}
func foo(input: [Bool] = []) {}
class Foo {
	func foo() -> Bool {}
}
class Foo {
	func foo() -> [String: Bool] {}
}
class Foo {
	func foo() -> ([Bool]) -> String {}
}
struct Foo {
	func foo() -> Bool {}
}
struct Foo {
	func foo() -> [String: Bool] {}
}
struct Foo {
	func foo() -> ([Bool]) -> String {}
}
enum Foo {
	func foo() -> Bool {}
}
enum Foo {
	func foo() -> [String: Bool] {}
}
enum Foo {
	func foo() -> ([Bool]) -> String {}
}
class Foo {
	func foo(input: Bool = true) {}
}
class Foo {
	func foo(input: [String: Bool] = [:]) {}
}
class Foo {
	func foo(input: [Bool] = []) {}
}
struct Foo {
	func foo(input: Bool = true) {}
}
struct Foo {
	func foo(input: [String: Bool] = [:]) {}
}
struct Foo {
	func foo(input: [Bool] = []) {}
}
enum Foo {
	func foo(input: Bool = true) {}
}
enum Foo {
	func foo(input: [String: Bool] = [:]) {}
}
enum Foo {
	func foo(input: [Bool] = []) {}
}
Triggering Examples
var foo: Bool?
var foo: [String: Bool?]
var foo: [Bool?]
let foo: Bool? = nil
let foo: [String: Bool?] = [:]
let foo: [Bool?] = []
let foo = Optional.some(false)
let foo = Optional.some(true)
var foo: Bool? { return nil }
let foo: Bool? { return nil }()
func foo() ->Bool? {}
func foo() -> [String: ↓Bool?] {}
func foo() -> [↓Bool?] {}
static func foo() ->Bool? {}
static func foo() -> [String: ↓Bool?] {}
static func foo() -> [↓Bool?] {}
func foo() -> (↓Bool?) -> String {}
func foo() -> ([Int]) ->Bool? {}
func foo(input: ↓Bool?) {}
func foo(input: [String: ↓Bool?]) {}
func foo(input: [↓Bool?]) {}
static func foo(input: ↓Bool?) {}
static func foo(input: [String: ↓Bool?]) {}
static func foo(input: [↓Bool?]) {}
class Foo {
	var foo: Bool?
}
class Foo {
	var foo: [String: Bool?]
}
class Foo {
	let foo: Bool? = nil
}
class Foo {
	let foo: [String: Bool?] = [:]
}
class Foo {
	let foo: [Bool?] = []
}
struct Foo {
	var foo: Bool?
}
struct Foo {
	var foo: [String: Bool?]
}
struct Foo {
	let foo: Bool? = nil
}
struct Foo {
	let foo: [String: Bool?] = [:]
}
struct Foo {
	let foo: [Bool?] = []
}
class Foo {
	var foo: Bool? { return nil }
}
class Foo {
	let foo: Bool? { return nil }()
}
struct Foo {
	var foo: Bool? { return nil }
}
struct Foo {
	let foo: Bool? { return nil }()
}
enum Foo {
	var foo: Bool? { return nil }
}
enum Foo {
	let foo: Bool? { return nil }()
}
class Foo {
	func foo() ->Bool? {}
}
class Foo {
	func foo() -> [String: ↓Bool?] {}
}
class Foo {
	func foo() -> [↓Bool?] {}
}
class Foo {
	static func foo() ->Bool? {}
}
class Foo {
	static func foo() -> [String: ↓Bool?] {}
}
class Foo {
	static func foo() -> [↓Bool?] {}
}
class Foo {
	func foo() -> (↓Bool?) -> String {}
}
class Foo {
	func foo() -> ([Int]) ->Bool? {}
}
struct Foo {
	func foo() ->Bool? {}
}
struct Foo {
	func foo() -> [String: ↓Bool?] {}
}
struct Foo {
	func foo() -> [↓Bool?] {}
}
struct Foo {
	static func foo() ->Bool? {}
}
struct Foo {
	static func foo() -> [String: ↓Bool?] {}
}
struct Foo {
	static func foo() -> [↓Bool?] {}
}
struct Foo {
	func foo() -> (↓Bool?) -> String {}
}
struct Foo {
	func foo() -> ([Int]) ->Bool? {}
}
enum Foo {
	func foo() ->Bool? {}
}
enum Foo {
	func foo() -> [String: ↓Bool?] {}
}
enum Foo {
	func foo() -> [↓Bool?] {}
}
enum Foo {
	static func foo() ->Bool? {}
}
enum Foo {
	static func foo() -> [String: ↓Bool?] {}
}
enum Foo {
	static func foo() -> [↓Bool?] {}
}
enum Foo {
	func foo() -> (↓Bool?) -> String {}
}
enum Foo {
	func foo() -> ([Int]) ->Bool? {}
}
class Foo {
	func foo(input: ↓Bool?) {}
}
class Foo {
	func foo(input: [String: ↓Bool?]) {}
}
class Foo {
	func foo(input: [↓Bool?]) {}
}
class Foo {
	static func foo(input: ↓Bool?) {}
}
class Foo {
	static func foo(input: [String: ↓Bool?]) {}
}
class Foo {
	static func foo(input: [↓Bool?]) {}
}
struct Foo {
	func foo(input: ↓Bool?) {}
}
struct Foo {
	func foo(input: [String: ↓Bool?]) {}
}
struct Foo {
	func foo(input: [↓Bool?]) {}
}
struct Foo {
	static func foo(input: ↓Bool?) {}
}
struct Foo {
	static func foo(input: [String: ↓Bool?]) {}
}
struct Foo {
	static func foo(input: [↓Bool?]) {}
}
enum Foo {
	func foo(input: ↓Bool?) {}
}
enum Foo {
	func foo(input: [String: ↓Bool?]) {}
}
enum Foo {
	func foo(input: [↓Bool?]) {}
}
enum Foo {
	static func foo(input: ↓Bool?) {}
}
enum Foo {
	static func foo(input: [String: ↓Bool?]) {}
}
enum Foo {
	static func foo(input: [↓Bool?]) {}
}

Discouraged Optional Collection

Identifier Enabled by default Supports autocorrection Kind Analyzer Minimum Swift Compiler Version
discouraged_optional_collection Disabled No idiomatic No 3.0.0

Prefer empty collection over optional collection.

Examples

Non Triggering Examples
var foo: [Int]
var foo: [String: Int]
var foo: Set<String>
var foo: [String: [String: Int]]
let foo: [Int] = []
let foo: [String: Int] = [:]
let foo: Set<String> = []
let foo: [String: [String: Int]] = [:]
var foo: [Int] { return [] }
func foo() -> [Int] {}
func foo() -> [String: String] {}
func foo() -> Set<Int> {}
func foo() -> ([Int]) -> String {}
func foo(input: [String] = []) {}
func foo(input: [String: String] = [:]) {}
func foo(input: Set<String> = []) {}
class Foo {
	func foo() -> [Int] {}
}
class Foo {
	func foo() -> [String: String] {}
}
class Foo {
	func foo() -> Set<Int> {}
}
class Foo {
	func foo() -> ([Int]) -> String {}
}
struct Foo {
	func foo() -> [Int] {}
}
struct Foo {
	func foo() -> [String: String] {}
}
struct Foo {
	func foo() -> Set<Int> {}
}
struct Foo {
	func foo() -> ([Int]) -> String {}
}
enum Foo {
	func foo() -> [Int] {}
}
enum Foo {
	func foo() -> [String: String] {}
}
enum Foo {
	func foo() -> Set<Int> {}
}
enum Foo {
	func foo() -> ([Int]) -> String {}
}
class Foo {
	func foo(input: [String] = []) {}
}
class Foo {
	func foo(input: [String: String] = [:]) {}
}
class Foo {
	func foo(input: Set<String> = []) {}
}
struct Foo {
	func foo(input: [String] = []) {}
}
struct Foo {
	func foo(input: [String: String] = [:]) {}
}
struct Foo {
	func foo(input: Set<String> = []) {}
}
enum Foo {
	func foo(input: [String] = []) {}
}
enum Foo {
	func foo(input: [String: String] = [:]) {}
}
enum Foo {
	func foo(input: Set<String> = []) {}
}
Triggering Examples
var foo: [Int]?
var foo: [String: Int]?
var foo: Set<String>?
let foo: [Int]? = nil
let foo: [String: Int]? = nil
let foo: Set<String>? = nil
var foo: [Int]? { return nil }
let foo: [Int]? { return nil }()
func foo() -> [T]? {}
func foo() -> [String: String]? {}
func foo() -> [String: [String: String]]? {}
func foo() -> [String: [String: String]?] {}
func foo() -> Set<Int>? {}
static func foo() -> [T]? {}
static func foo() -> [String: String]? {}
static func foo() -> [String: [String: String]]? {}
static func foo() -> [String: [String: String]?] {}
static func foo() -> Set<Int>? {}
func foo() -> ([Int]?) -> String {}
func foo() -> ([Int]) -> [String]? {}
func foo(↓input: [String: String]?) {}
func foo(↓input: [String: [String: String]]?) {}
func foo(↓input: [String: [String: String]?]) {}
func foo(↓↓input: [String: [String: String]?]?) {}
func foo<K, V>(_ dict1: [K: V], ↓_ dict2: [K: V]?) -> [K: V]
func foo<K, V>(dict1: [K: V], ↓dict2: [K: V]?) -> [K: V]
static func foo(↓input: [String: String]?) {}
static func foo(↓input: [String: [String: String]]?) {}
static func foo(↓input: [String: [String: String]?]) {}
static func foo(↓↓input: [String: [String: String]?]?) {}
static func foo<K, V>(_ dict1: [K: V], ↓_ dict2: [K: V]?) -> [K: V]
static func foo<K, V>(dict1: [K: V], ↓dict2: [K: V]?) -> [K: V]
class Foo {
	var foo: [Int]?
}
class Foo {
	var foo: [String: Int]?
}
class Foo {
	var foo: Set<String>?
}
class Foo {
	let foo: [Int]? = nil
}
class Foo {
	let foo: [String: Int]? = nil
}
class Foo {
	let foo: Set<String>? = nil
}
struct Foo {
	var foo: [Int]?
}
struct Foo {
	var foo: [String: Int]?
}
struct Foo {
	var foo: Set<String>?
}
struct Foo {
	let foo: [Int]? = nil
}
struct Foo {
	let foo: [String: Int]? = nil
}
struct Foo {
	let foo: Set<String>? = nil
}
class Foo {
	var foo: [Int]? { return nil }
}
class Foo {
	let foo: [Int]? { return nil }()
}
class Foo {
	var foo: Set<String>? { return nil }
}
class Foo {
	let foo: Set<String>? { return nil }()
}
struct Foo {
	var foo: [Int]? { return nil }
}
struct Foo {
	let foo: [Int]? { return nil }()
}
struct Foo {
	var foo: Set<String>? { return nil }
}
struct Foo {
	let foo: Set<String>? { return nil }()
}
enum Foo {
	var foo: [Int]? { return nil }
}
enum Foo {
	let foo: [Int]? { return nil }()
}
enum Foo {
	var foo: Set<String>? { return nil }
}
enum Foo {
	let foo: Set<String>? { return nil }()
}
class Foo {
	func foo() -> [T]? {}
}
class Foo {
	func foo() -> [String: String]? {}
}
class Foo {
	func foo() -> [String: [String: String]]? {}
}
class Foo {
	func foo() -> [String: [String: String]?] {}
}
class Foo {
	func foo() -> Set<Int>? {}
}
class Foo {
	static func foo() -> [T]? {}
}
class Foo {
	static func foo() -> [String: String]? {}
}
class Foo {
	static func foo() -> [String: [String: String]]? {}
}
class Foo {
	static func foo() -> [String: [String: String]?] {}
}
class Foo {
	static func foo() -> Set<Int>? {}
}
class Foo {
	func foo() -> ([Int]?) -> String {}
}
class Foo {
	func foo() -> ([Int]) -> [String]? {}
}
struct Foo {
	func foo() -> [T]? {}
}
struct Foo {
	func foo() -> [String: String]? {}
}
struct Foo {
	func foo() -> [String: [String: String]]? {}
}
struct Foo {
	func foo() -> [String: [String: String]?] {}
}
struct Foo {
	func foo() -> Set<Int>? {}
}
struct Foo {
	static func foo() -> [T]? {}
}
struct Foo {
	static func foo() -> [String: String]? {}
}
struct Foo {
	static func foo() -> [String: [String: String]]? {}
}
struct Foo {
	static func foo() -> [String: [String: String]?] {}
}
struct Foo {
	static func foo() -> Set<Int>? {}
}
struct Foo {
	func foo() -> ([Int]?) -> String {}
}
struct Foo {
	func foo() -> ([Int]) -> [String]? {}
}
enum Foo {
	func foo() -> [T]? {}
}
enum Foo {
	func foo() -> [String: String]? {}
}
enum Foo {
	func foo() -> [String: [String: String]]? {}
}
enum Foo {
	func foo() -> [String: [String: String]?] {}
}
enum Foo {
	func foo() -> Set<Int>? {}
}
enum Foo {
	static func foo() -> [T]? {}
}
enum Foo {
	static func foo() -> [String: String]? {}
}
enum Foo {
	static func foo() -> [String: [String: String]]? {}
}
enum Foo {
	static func foo() -> [String: [String: String]?] {}
}
enum Foo {
	static func foo() -> Set<Int>? {}
}
enum Foo {
	func foo() -> ([Int]?) -> String {}
}
enum Foo {
	func foo() -> ([Int]) -> [String]? {}
}
class Foo {
	func foo(↓input: [String: String]?) {}
}
class Foo {
	func foo(↓input: [String: [String: String]]?) {}
}
class Foo {
	func foo(↓input: [String: [String: String]?]) {}
}
class Foo {
	func foo(↓↓input: [String: [String: String]?]?) {}
}
class Foo {
	func foo<K, V>(_ dict1: [K: V], ↓_ dict2: [K: V]?) -> [K: V]
}
class Foo {
	func foo<K, V>(dict1: [K: V], ↓dict2: [K: V]?) -> [K: V]
}
class Foo {
	static func foo(↓input: [String: String]?) {}
}
class Foo {
	static func foo(↓input: [String: [String: String]]?) {}
}
class Foo {
	static func foo(↓input: [String: [String: String]?]) {}
}
class Foo {
	static func foo(↓↓input: [String: [String: String]?]?) {}
}
class Foo {
	static func foo<K, V>(_ dict1: [K: V], ↓_ dict2: [K: V]?) -> [K: V]
}
class Foo {
	static func foo<K, V>(dict1: [K: V], ↓dict2: [K: V]?) -> [K: V]
}
struct Foo {
	func foo(↓input: [String: String]?) {}
}
struct Foo {
	func foo(↓input: [String: [String: String]]?) {}
}
struct Foo {
	func foo(↓input: [String: [String: String]?]) {}
}
struct Foo {
	func foo(↓↓input: [String: [String: String]?]?) {}
}
struct Foo {
	func foo<K, V>(_ dict1: [K: V], ↓_ dict2: [K: V]?) -> [K: V]
}
struct Foo {
	func foo<K, V>(dict1: [K: V], ↓dict2: [K: V]?) -> [K: V]
}
struct Foo {
	static func foo(↓input: [String: String]?) {}
}
struct Foo {
	static func foo(↓input: [String: [String: String]]?) {}
}
struct Foo {
	static func foo(↓input: [String: [String: String]?]) {}
}
struct Foo {
	static func foo(↓↓input: [String: [String: String]?]?) {}
}
struct Foo {
	static func foo<K, V>(_ dict1: [K: V], ↓_ dict2: [K: V]?) -> [K: V]
}
struct Foo {
	static func foo<K, V>(dict1: [K: V], ↓dict2: [K: V]?) -> [K: V]
}
enum Foo {
	func foo(↓input: [String: String]?) {}
}
enum Foo {
	func foo(↓input: [String: [String: String]]?) {}
}
enum Foo {
	func foo(↓input: [String: [String: String]?]) {}
}
enum Foo {
	func foo(↓↓input: [String: [String: String]?]?) {}
}
enum Foo {
	func foo<K, V>(_ dict1: [K: V], ↓_ dict2: [K: V]?) -> [K: V]
}
enum Foo {
	func foo<K, V>(dict1: [K: V], ↓dict2: [K: V]?) -> [K: V]
}
enum Foo {
	static func foo(↓input: [String: String]?) {}
}
enum Foo {
	static func foo(↓input: [String: [String: String]]?) {}
}
enum Foo {
	static func foo(↓input: [String: [String: String]?]) {}
}
enum Foo {
	static func foo(↓↓input: [String: [String: String]?]?) {}
}
enum Foo {
	static func foo<K, V>(_ dict1: [K: V], ↓_ dict2: [K: V]?) -> [K: V]
}
enum Foo {
	static func foo<K, V>(dict1: [K: V], ↓dict2: [K: V]?) -> [K: V]
}

Dynamic Inline

Identifier Enabled by default Supports autocorrection Kind Analyzer Minimum Swift Compiler Version
dynamic_inline Enabled No lint No 3.0.0

Avoid using 'dynamic' and '@inline(__always)' together.

Examples

Non Triggering Examples
class C {
dynamic func f() {}}
class C {
@inline(__always) func f() {}}
class C {
@inline(never) dynamic func f() {}}
Triggering Examples
class C {
@inline(__always) dynamic func f() {}
}
class C {
@inline(__always) public dynamic func f() {}
}
class C {
@inline(__always) dynamic internal func f() {}
}
class C {
@inline(__always)
dynamic func f() {}
}
class C {
@inline(__always)
dynamic
func f() {}
}

Empty Count

Identifier Enabled by default Supports autocorrection Kind Analyzer Minimum Swift Compiler Version
empty_count Disabled No performance No 3.0.0

Prefer checking isEmpty over comparing count to zero.

Examples

Non Triggering Examples
var count = 0
[Int]().isEmpty
[Int]().count > 1
[Int]().count == 1
[Int]().count == 0xff
[Int]().count == 0b01
[Int]().count == 0o07
discount == 0
order.discount == 0
Triggering Examples
[Int]().↓count == 0
[Int]().↓count > 0
[Int]().↓count != 0
[Int]().↓count == 0x0
[Int]().↓count == 0x00_00
[Int]().↓count == 0b00
[Int]().↓count == 0o00
count == 0

Empty Enum Arguments

Identifier Enabled by default Supports autocorrection Kind Analyzer Minimum Swift Compiler Version
empty_enum_arguments Enabled Yes style No 3.0.0

Arguments can be omitted when matching enums with associated types if they are not used.

Examples

Non Triggering Examples
switch foo {
    case .bar: break
}
switch foo {
    case .bar(let x): break
}
switch foo {
    case let .bar(x): break
}
switch (foo, bar) {
    case (_, _): break
}
switch foo {
    case "bar".uppercased(): break
}
switch (foo, bar) {
    case (_, _) where !something: break
}
switch foo {
    case (let f as () -> String)?: break
}
switch foo {
    default: break
}
Triggering Examples
switch foo {
    case .bar(_): break
}
switch foo {
    case .bar(): break
}
switch foo {
    case .bar(_), .bar2(_): break
}
switch foo {
    case .bar() where method() > 2: break
}
func example(foo: Foo) {
    switch foo {
    case case .bar(_):
        break
    }
}

Empty Parameters

Identifier Enabled by default Supports autocorrection Kind Analyzer Minimum Swift Compiler Version
empty_parameters Enabled Yes style No 3.0.0

Prefer () -> over Void -> .

Examples

Non Triggering Examples
let abc: () -> Void = {}
func foo(completion: () -> Void)
func foo(completion: () thows -> Void)
let foo: (ConfigurationTests) -> Void throws -> Void)
let foo: (ConfigurationTests) ->   Void throws -> Void)
let foo: (ConfigurationTests) ->Void throws -> Void)
Triggering Examples
let abc: (Void) -> Void = {}
func foo(completion: ↓(Void) -> Void)
func foo(completion: ↓(Void) throws -> Void)
let foo: (Void) -> () throws -> Void)

Empty Parentheses with Trailing Closure

Identifier Enabled by default Supports autocorrection Kind Analyzer Minimum Swift Compiler Version
empty_parentheses_with_trailing_closure Enabled Yes style No 3.0.0

When using trailing closures, empty parentheses should be avoided after the method call.

Examples

Non Triggering Examples
[1, 2].map { $0 + 1 }
[1, 2].map({ $0 + 1 })
[1, 2].reduce(0) { $0 + $1 }
[1, 2].map { number in
 number + 1 
}
let isEmpty = [1, 2].isEmpty()
UIView.animateWithDuration(0.3, animations: {
   self.disableInteractionRightView.alpha = 0
}, completion: { _ in
   ()
})
Triggering Examples
[1, 2].map() { $0 + 1 }
[1, 2].map( ) { $0 + 1 }
[1, 2].map() { number in
 number + 1 
}
[1, 2].map(  ) { number in
 number + 1 
}
func foo() -> [Int] {
    return [1, 2].map() { $0 + 1 }
}

Empty String

Identifier Enabled by default Supports autocorrection Kind Analyzer Minimum Swift Compiler Version
empty_string Disabled No performance No 3.0.0

Prefer checking isEmpty over comparing string to an empty string literal.

Examples

Non Triggering Examples
myString.isEmpty
!myString.isEmpy
Triggering Examples
myString == ""
myString != ""

Empty XCTest Method

Identifier Enabled by default Supports autocorrection Kind Analyzer Minimum Swift Compiler Version
empty_xctest_method Disabled No lint No 3.0.0

Empty XCTest method should be avoided.

Examples

Non Triggering Examples
class TotoTests: XCTestCase {
    var foobar: Foobar?

    override func setUp() {
        super.setUp()
        foobar = Foobar()
    }

    override func tearDown() {
        foobar = nil
        super.tearDown()
    }

    func testFoo() {
        XCTAssertTrue(foobar?.foo)
    }

    func testBar() {
        // comment...

        XCTAssertFalse(foobar?.bar)

        // comment...
    }
}
class Foobar {
    func setUp() {}

    func tearDown() {}

    func testFoo() {}
}
class TotoTests: XCTestCase {
    func setUp(with object: Foobar) {}

    func tearDown(object: Foobar) {}

    func testFoo(_ foo: Foobar) {}

    func testBar(bar: (String) -> Int) {}
}
class TotoTests: XCTestCase {
    func testFoo() { XCTAssertTrue(foobar?.foo) }

    func testBar() { XCTAssertFalse(foobar?.bar) }
}
Triggering Examples
class TotoTests: XCTestCase {
    override func setUp() {
    }

    override func tearDown() {

    }

    func testFoo() {


    }

    func testBar() {



    }

    func helperFunction() {
    }
}
class TotoTests: XCTestCase {
    override func setUp() {}

    override func tearDown() {}

    func testFoo() {}

    func helperFunction() {}
}
class TotoTests: XCTestCase {
    override func setUp() {
        // comment...
    }

    override func tearDown() {
        // comment...
        // comment...
    }

    func testFoo() {
        // comment...

        // comment...

        // comment...
    }

    func testBar() {
        /*
         * comment...
         *
         * comment...
         *
         * comment...
         */
    }

    func helperFunction() {
    }
}
class FooTests: XCTestCase {
    override func setUp() {}
}

class BarTests: XCTestCase {
    func testFoo() {}
}

Explicit ACL

Identifier Enabled by default Supports autocorrection Kind Analyzer Minimum Swift Compiler Version
explicit_acl Disabled No idiomatic No 3.0.0

All declarations should specify Access Control Level keywords explicitly.

Examples

Non Triggering Examples
internal enum A {}
public final class B {}
private struct C {}
internal enum A {
 internal enum B {}
}
internal final class Foo {}
internal
class Foo {  private let bar = 5 }
internal func a() { let a =  }
private func a() { func innerFunction() { } }
private enum Foo { enum Bar { } }
private struct C { let d = 5 }
internal protocol A {
    func b()
}
internal protocol A {
    var b: Int
}
internal class A { deinit {} }
Triggering Examples
enum A {}
final class B {}
internal struct C { let d = 5 }
public struct C { let d = 5 }
func a() {}
internal let a = 0
func b() {}

Explicit Enum Raw Value

Identifier Enabled by default Supports autocorrection Kind Analyzer Minimum Swift Compiler Version
explicit_enum_raw_value Disabled No idiomatic No 3.0.0

Enums should be explicitly assigned their raw values.

Examples

Non Triggering Examples
enum Numbers {
 case int(Int)
 case short(Int16)
}
enum Numbers: Int {
 case one = 1
 case two = 2
}
enum Numbers: Double {
 case one = 1.1
 case two = 2.2
}
enum Numbers: String {
 case one = "one"
 case two = "two"
}
protocol Algebra {}
enum Numbers: Algebra {
 case one
}
Triggering Examples
enum Numbers: Int {
 case one = 10, ↓two, three = 30
}
enum Numbers: NSInteger {
 case ↓one
}
enum Numbers: String {
 case ↓one
 case ↓two
}
enum Numbers: String {
 case ↓one, two = "two"
}
enum Numbers: Decimal {
 case ↓one, two
}

Explicit Init

Identifier Enabled by default Supports autocorrection Kind Analyzer Minimum Swift Compiler Version
explicit_init Disabled Yes idiomatic No 3.0.0

Explicitly calling .init() should be avoided.

Examples

Non Triggering Examples
import Foundation; class C: NSObject { override init() { super.init() }}
struct S { let n: Int }; extension S { init() { self.init(n: 1) } }
[1].flatMap(String.init)
[String.self].map { $0.init(1) }
[String.self].map { type in type.init(1) }
Observable.zip(obs1, obs2, resultSelector: MyType.init).asMaybe()
Observable.zip(
    obs1,
    obs2,
    resultSelector: MyType.init
).asMaybe()
Triggering Examples
[1].flatMap{String.init($0)}
[String.self].map { Type in Type.init(1) }
func foo() -> [String] {
    return [1].flatMap { String.init($0) }
}
Observable.zip(
    obs1,
    obs2,
    resultSelector: { MyType.init($0, $1) }
).asMaybe()

Explicit Self

Identifier Enabled by default Supports autocorrection Kind Analyzer Minimum Swift Compiler Version
explicit_self Disabled Yes style Yes 3.0.0

Instance variables and functions should be explicitly accessed with 'self.'.

Examples

Non Triggering Examples
struct A {
    func f1() {}
    func f2() {
        self.f1()
    }
}
struct A {
    let p1: Int
    func f1() {
        _ = self.p1
    }
}
Triggering Examples
struct A {
    func f1() {}
    func f2() {
        f1()
    }
}
struct A {
    let p1: Int
    func f1() {
        _ = p1
    }
}

Explicit Top Level ACL

Identifier Enabled by default Supports autocorrection Kind Analyzer Minimum Swift Compiler Version
explicit_top_level_acl Disabled No idiomatic No 3.0.0

Top-level declarations should specify Access Control Level keywords explicitly.

Examples

Non Triggering Examples
internal enum A {}
public final class B {}
private struct C {}
internal enum A {
 enum B {}
}
internal final class Foo {}
internal
class Foo {}
internal func a() {}
Triggering Examples
enum A {}
final class B {}
struct C {}
func a() {}
internal let a = 0
func b() {}

Explicit Type Interface

Identifier Enabled by default Supports autocorrection Kind Analyzer Minimum Swift Compiler Version
explicit_type_interface Disabled No idiomatic No 3.0.0

Properties should have a type interface

Examples

Non Triggering Examples
class Foo {
  var myVar: Int? = 0
}
class Foo {
  let myVar: Int? = 0
}
class Foo {
  static var myVar: Int? = 0
}
class Foo {
  class var myVar: Int? = 0
}
Triggering Examples
class Foo {
  var myVar = 0

}
class Foo {
  let mylet = 0

}
class Foo {
  static var myStaticVar = 0
}
class Foo {
  class var myClassVar = 0
}
class Foo {
  let myVar = Int(0)
}
class Foo {
  let myVar = Set<Int>(0)
}

Extension Access Modifier

Identifier Enabled by default Supports autocorrection Kind Analyzer Minimum Swift Compiler Version
extension_access_modifier Disabled No idiomatic No 3.0.0

Prefer to use extension access modifiers

Examples

Non Triggering Examples
extension Foo: SomeProtocol {
   public var bar: Int { return 1 }
}
extension Foo {
   private var bar: Int { return 1 }
   public var baz: Int { return 1 }
}
extension Foo {
   private var bar: Int { return 1 }
   public func baz() {}
}
extension Foo {
   var bar: Int { return 1 }
   var baz: Int { return 1 }
}
public extension Foo {
   var bar: Int { return 1 }
   var baz: Int { return 1 }
}
extension Foo {
   private bar: Int { return 1 }
   private baz: Int { return 1 }
}
extension Foo {
   open bar: Int { return 1 }
   open baz: Int { return 1 }
}
Triggering Examples
extension Foo {
   public var bar: Int { return 1 }
   public var baz: Int { return 1 }
}
extension Foo {
   public var bar: Int { return 1 }
   public func baz() {}
}
public extension Foo {
   public func bar() {}
   public func baz() {}
}

Fallthrough

Identifier Enabled by default Supports autocorrection Kind Analyzer Minimum Swift Compiler Version
fallthrough Disabled No idiomatic No 3.0.0

Fallthrough should be avoided.

Examples

Non Triggering Examples
switch foo {
case .bar, .bar2, .bar3:
    something()
}
Triggering Examples
switch foo {
case .bar:
    fallthrough
case .bar2:
    something()
}

Fatal Error Message

Identifier Enabled by default Supports autocorrection Kind Analyzer Minimum Swift Compiler Version
fatal_error_message Disabled No idiomatic No 3.0.0

A fatalError call should have a message.

Examples

Non Triggering Examples
func foo() {
  fatalError("Foo")
}
func foo() {
  fatalError(x)
}
Triggering Examples
func foo() {
  fatalError("")
}
func foo() {
  fatalError()
}

File Header

Identifier Enabled by default Supports autocorrection Kind Analyzer Minimum Swift Compiler Version
file_header Disabled No style No 3.0.0

Header comments should be consistent with project patterns. The SWIFTLINT_CURRENT_FILENAME placeholder can optionally be used in the required and forbidden patterns. It will be replaced by the real file name.

Examples

Non Triggering Examples
let foo = "Copyright"
let foo = 2 // Copyright
let foo = 2
 // Copyright
Triggering Examples
// ↓Copyright
//
// ↓Copyright
//
//  FileHeaderRule.swift
//  SwiftLint
//
//  Created by Marcelo Fabri on 27/11/16.
//  ↓Copyright © 2016 Realm. All rights reserved.
//

File Line Length

Identifier Enabled by default Supports autocorrection Kind Analyzer Minimum Swift Compiler Version
file_length Enabled No metrics No 3.0.0

Files should not span too many lines.

Examples

Non Triggering Examples
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
Triggering Examples
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
print("swiftlint")
//

File Name

Identifier Enabled by default Supports autocorrection Kind Analyzer Minimum Swift Compiler Version
file_name Disabled No idiomatic No 3.0.0

File name should match a type or extension declared in the file (if any).

First Where

Identifier Enabled by default Supports autocorrection Kind Analyzer Minimum Swift Compiler Version
first_where Disabled No performance No 3.0.0

Prefer using .first(where:) over .filter { }.first in collections.

Examples

Non Triggering Examples
kinds.filter(excludingKinds.contains).isEmpty && kinds.first == .identifier
myList.first(where: { $0 % 2 == 0 })
match(pattern: pattern).filter { $0.first == .identifier }
(myList.filter { $0 == 1 }.suffix(2)).first
Triggering Examples
myList.filter { $0 % 2 == 0 }.first
myList.filter({ $0 % 2 == 0 }).first
myList.map { $0 + 1 }.filter({ $0 % 2 == 0 }).first
myList.map { $0 + 1 }.filter({ $0 % 2 == 0 }).first?.something()
myList.filter(someFunction).first
myList.filter({ $0 % 2 == 0 })
.first
(myList.filter { $0 == 1 }).first

For Where

Identifier Enabled by default Supports autocorrection Kind Analyzer Minimum Swift Compiler Version
for_where Enabled No idiomatic No 3.0.0

where clauses are preferred over a single if inside a for.

Examples

Non Triggering Examples
for user in users where user.id == 1 { }
for user in users {
   if let id = user.id { }
}
for user in users {
   if var id = user.id { }
}
for user in users {
   if user.id == 1 { } else { }
}
for user in users {
   if user.id == 1 {
} else if user.id == 2 { }
}
for user in users {
   if user.id == 1 { }
   print(user)
}
for user in users {
   let id = user.id
   if id == 1 { }
}
for user in users {
   if user.id == 1 { }
   return true
}
for user in users {
   if user.id == 1 && user.age > 18 { }
}
for (index, value) in array.enumerated() {
   if case .valueB(_) = value {
       return index
   }
}
Triggering Examples
for user in users {
   if user.id == 1 { return true }
}

Force Cast

Identifier Enabled by default Supports autocorrection Kind Analyzer Minimum Swift Compiler Version
force_cast Enabled No idiomatic No 3.0.0

Force casts should be avoided.

Examples

Non Triggering Examples
NSNumber() as? Int
Triggering Examples
NSNumber() as! Int

Force Try

Identifier Enabled by default Supports autocorrection Kind Analyzer Minimum Swift Compiler Version
force_try Enabled No idiomatic No 3.0.0

Force tries should be avoided.

Examples

Non Triggering Examples
func a() throws {}; do { try a() } catch {}
Triggering Examples
func a() throws {}; try! a()

Force Unwrapping

Identifier Enabled by default Supports autocorrection Kind Analyzer Minimum Swift Compiler Version
force_unwrapping Disabled No idiomatic No 3.0.0

Force unwrapping should be avoided.

Examples

Non Triggering Examples
if let url = NSURL(string: query)
navigationController?.pushViewController(viewController, animated: true)
let s as! Test
try! canThrowErrors()
let object: Any!
@IBOutlet var constraints: [NSLayoutConstraint]!
setEditing(!editing, animated: true)
navigationController.setNavigationBarHidden(!navigationController.navigationBarHidden, animated: true)
if addedToPlaylist && (!self.selectedFilters.isEmpty || self.searchBar?.text?.isEmpty == false) {}
print("\(xVar)!")
var test = (!bar)
var a: [Int]!
private var myProperty: (Void -> Void)!
func foo(_ options: [AnyHashable: Any]!) {
func foo() -> [Int]!
func foo() -> [AnyHashable: Any]!
func foo() -> [Int]! { return [] }
Triggering Examples
let url = NSURL(string: query)↓!
navigationController↓!.pushViewController(viewController, animated: true)
let unwrapped = optional↓!
return cell↓!
let url = NSURL(string: "http://www.google.com")↓!
let dict = ["Boooo": "👻"]func bla() -> String { return dict["Boooo"]↓! }
let dict = ["Boooo": "👻"]func bla() -> String { return dict["Boooo"]↓!.contains("B") }
let a = dict["abc"]↓!.contains("B")
dict["abc"]↓!.bar("B")
if dict["a"]↓!!!! {
var foo: [Bool]! = dict["abc"]↓!
context("abc") {
  var foo: [Bool]! = dict["abc"]↓!
}
open var computed: String { return foo.bar↓! }

Function Body Length

Identifier Enabled by default Supports autocorrection Kind Analyzer Minimum Swift Compiler Version
function_body_length Enabled No metrics No 3.0.0

Functions bodies should not span too many lines.

Function Default Parameter at End

Identifier Enabled by default Supports autocorrection Kind Analyzer Minimum Swift Compiler Version
function_default_parameter_at_end Disabled No idiomatic No 3.0.0

Prefer to locate parameters with defaults toward the end of the parameter list.

Examples

Non Triggering Examples
func foo(baz: String, bar: Int = 0) {}
func foo(x: String, y: Int = 0, z: CGFloat = 0) {}
func foo(bar: String, baz: Int = 0, z: () -> Void) {}
func foo(bar: String, z: () -> Void, baz: Int = 0) {}
func foo(bar: Int = 0) {}
func foo() {}
class A: B {
    override func foo(bar: Int = 0, baz: String) {}
func foo(bar: Int = 0, completion: @escaping CompletionHandler) {}
func foo(a: Int, b: CGFloat = 0) {
    let block = { (error: Error?) in }
}
Triggering Examples
func foo(bar: Int = 0, baz: String) {}

Function Parameter Count

Identifier Enabled by default Supports autocorrection Kind Analyzer Minimum Swift Compiler Version
function_parameter_count Enabled No metrics No 3.0.0

Number of function parameters should be low.

Examples

Non Triggering Examples
init(a: Int, b: Int, c: Int, d: Int, e: Int, f: Int) {}
init (a: Int, b: Int, c: Int, d: Int, e: Int, f: Int) {}
`init`(a: Int, b: Int, c: Int, d: Int, e: Int, f: Int) {}
init?(a: Int, b: Int, c: Int, d: Int, e: Int, f: Int) {}
init?<T>(a: T, b: Int, c: Int, d: Int, e: Int, f: Int) {}
init?<T: String>(a: T, b: Int, c: Int, d: Int, e: Int, f: Int) {}
func f2(p1: Int, p2: Int) { }
func f(a: Int, b: Int, c: Int, d: Int, x: Int = 42) {}
func f(a: [Int], b: Int, c: Int, d: Int, f: Int) -> [Int] {
let s = a.flatMap { $0 as? [String: Int] } ?? []}}
override func f(a: Int, b: Int, c: Int, d: Int, e: Int, f: Int) {}
Triggering Examples
func f(a: Int, b: Int, c: Int, d: Int, e: Int, f: Int) {}
func initialValue(a: Int, b: Int, c: Int, d: Int, e: Int, f: Int) {}
func f(a: Int, b: Int, c: Int, d: Int, e: Int, f: Int = 2, g: Int) {}
struct Foo {
init(a: Int, b: Int, c: Int, d: Int, e: Int, f: Int) {}
func bar(a: Int, b: Int, c: Int, d: Int, e: Int, f: Int) {}}

Generic Type Name

Identifier Enabled by default Supports autocorrection Kind Analyzer Minimum Swift Compiler Version
generic_type_name Enabled No idiomatic No 3.0.0

Generic type name should only contain alphanumeric characters, start with an uppercase character and span between 1 and 20 characters in length.

Examples

Non Triggering Examples
func foo<T>() {}
func foo<T>() -> T {}
func foo<T, U>(param: U) -> T {}
func foo<T: Hashable, U: Rule>(param: U) -> T {}
struct Foo<T> {}
class Foo<T> {}
enum Foo<T> {}
func run(_ options: NoOptions<CommandantError<()>>) {}
func foo(_ options: Set<type>) {}
func < <T: Comparable>(lhs: T?, rhs: T?) -> Bool
func configureWith(data: Either<MessageThread, (project: Project, backing: Backing)>)
typealias StringDictionary<T> = Dictionary<String, T>
typealias BackwardTriple<T1, T2, T3> = (T3, T2, T1)
typealias DictionaryOfStrings<T : Hashable> = Dictionary<T, String>
Triggering Examples
func foo<↓T_Foo>() {}
func foo<T, ↓U_Foo>(param: U_Foo) -> T {}
func foo<↓TTTTTTTTTTTTTTTTTTTTT>() {}
func foo<↓type>() {}
typealias StringDictionary<↓T_Foo> = Dictionary<String, T_Foo>
typealias BackwardTriple<T1, ↓T2_Bar, T3> = (T3, T2_Bar, T1)
typealias DictionaryOfStrings<↓T_Foo: Hashable> = Dictionary<T_Foo, String>
class Foo<↓T_Foo> {}
class Foo<T, ↓U_Foo> {}
class Foo<↓T_Foo, ↓U_Foo> {}
class Foo<↓TTTTTTTTTTTTTTTTTTTTT> {}
class Foo<↓type> {}
struct Foo<↓T_Foo> {}
struct Foo<T, ↓U_Foo> {}
struct Foo<↓T_Foo, ↓U_Foo> {}
struct Foo<↓TTTTTTTTTTTTTTTTTTTTT> {}
struct Foo<↓type> {}
enum Foo<↓T_Foo> {}
enum Foo<T, ↓U_Foo> {}
enum Foo<↓T_Foo, ↓U_Foo> {}
enum Foo<↓TTTTTTTTTTTTTTTTTTTTT> {}
enum Foo<↓type> {}

Identical Operands

Identifier Enabled by default Supports autocorrection Kind Analyzer Minimum Swift Compiler Version
identical_operands Disabled No lint No 3.0.0

Comparing two identical operands is likely a mistake.

Examples

Non Triggering Examples
1 == 2
foo == bar
prefixedFoo == foo
foo.aProperty == foo.anotherProperty
self.aProperty == self.anotherProperty
"1 == 1"
self.aProperty == aProperty
lhs.aProperty == rhs.aProperty
lhs.identifier == rhs.identifier
i == index
$0 == 0
keyValues?.count ?? 0  == 0
1 != 2
foo != bar
prefixedFoo != foo
foo.aProperty != foo.anotherProperty
self.aProperty != self.anotherProperty
"1 != 1"
self.aProperty != aProperty
lhs.aProperty != rhs.aProperty
lhs.identifier != rhs.identifier
i != index
$0 != 0
keyValues?.count ?? 0  != 0
1 === 2
foo === bar
prefixedFoo === foo
foo.aProperty === foo.anotherProperty
self.aProperty === self.anotherProperty
"1 === 1"
self.aProperty === aProperty
lhs.aProperty === rhs.aProperty
lhs.identifier === rhs.identifier
i === index
$0 === 0
keyValues?.count ?? 0  === 0
1 !== 2
foo !== bar
prefixedFoo !== foo
foo.aProperty !== foo.anotherProperty
self.aProperty !== self.anotherProperty
"1 !== 1"
self.aProperty !== aProperty
lhs.aProperty !== rhs.aProperty
lhs.identifier !== rhs.identifier
i !== index
$0 !== 0
keyValues?.count ?? 0  !== 0
1 > 2
foo > bar
prefixedFoo > foo
foo.aProperty > foo.anotherProperty
self.aProperty > self.anotherProperty
"1 > 1"
self.aProperty > aProperty
lhs.aProperty > rhs.aProperty
lhs.identifier > rhs.identifier
i > index
$0 > 0
keyValues?.count ?? 0  > 0
1 >= 2
foo >= bar
prefixedFoo >= foo
foo.aProperty >= foo.anotherProperty
self.aProperty >= self.anotherProperty
"1 >= 1"
self.aProperty >= aProperty
lhs.aProperty >= rhs.aProperty
lhs.identifier >= rhs.identifier
i >= index
$0 >= 0
keyValues?.count ?? 0  >= 0
1 < 2
foo < bar
prefixedFoo < foo
foo.aProperty < foo.anotherProperty
self.aProperty < self.anotherProperty
"1 < 1"
self.aProperty < aProperty
lhs.aProperty < rhs.aProperty
lhs.identifier < rhs.identifier
i < index
$0 < 0
keyValues?.count ?? 0  < 0
1 <= 2
foo <= bar
prefixedFoo <= foo
foo.aProperty <= foo.anotherProperty
self.aProperty <= self.anotherProperty
"1 <= 1"
self.aProperty <= aProperty
lhs.aProperty <= rhs.aProperty
lhs.identifier <= rhs.identifier
i <= index
$0 <= 0
keyValues?.count ?? 0  <= 0
func evaluate(_ mode: CommandMode) -> Result<AutoCorrectOptions, CommandantError<CommandantError<()>>>
Triggering Examples
1 == 1
foo == foo
foo.aProperty == foo.aProperty
self.aProperty == self.aProperty
$0 == $0
1 != 1
foo != foo
foo.aProperty != foo.aProperty
self.aProperty != self.aProperty
$0 != $0
1 === 1
foo === foo
foo.aProperty === foo.aProperty
self.aProperty === self.aProperty
$0 === $0
1 !== 1
foo !== foo
foo.aProperty !== foo.aProperty
self.aProperty !== self.aProperty
$0 !== $0
1 > 1
foo > foo
foo.aProperty > foo.aProperty
self.aProperty > self.aProperty
$0 > $0
1 >= 1
foo >= foo
foo.aProperty >= foo.aProperty
self.aProperty >= self.aProperty
$0 >= $0
1 < 1
foo < foo
foo.aProperty < foo.aProperty
self.aProperty < self.aProperty
$0 < $0
1 <= 1
foo <= foo
foo.aProperty <= foo.aProperty
self.aProperty <= self.aProperty
$0 <= $0

Identifier Name

Identifier Enabled by default Supports autocorrection Kind Analyzer Minimum Swift Compiler Version
identifier_name Enabled No style No 3.0.0

Identifier names should only contain alphanumeric characters and start with a lowercase character or should only contain capital letters. In an exception to the above, variable names may start with a capital letter when they are declared static and immutable. Variable names should not be too long or too short.

Examples

Non Triggering Examples
let myLet = 0
var myVar = 0
private let _myLet = 0
class Abc { static let MyLet = 0 }
let URL: NSURL? = nil
let XMLString: String? = nil
override var i = 0
enum Foo { case myEnum }
func isOperator(name: String) -> Bool
func typeForKind(_ kind: SwiftDeclarationKind) -> String
func == (lhs: SyntaxToken, rhs: SyntaxToken) -> Bool
override func IsOperator(name: String) -> Bool
enum Foo { case `private` }
enum Foo { case value(String) }
Triggering Examples
let MyLet = 0
let _myLet = 0
private let myLet_ = 0
let myExtremelyVeryVeryVeryVeryVeryVeryLongLet = 0
var myExtremelyVeryVeryVeryVeryVeryVeryLongVar = 0
private let _myExtremelyVeryVeryVeryVeryVeryVeryLongLet = 0
let i = 0
var id = 0
private let _i = 0
func IsOperator(name: String) -> Bool
enum Foo { case ↓MyEnum }

Implicit Getter

Identifier Enabled by default Supports autocorrection Kind Analyzer Minimum Swift Compiler Version
implicit_getter Enabled No style No 3.0.0

Computed read-only properties and subscripts should avoid using the get keyword.

Examples

Non Triggering Examples
class Foo {
    var foo: Int {
        get { return 3 }
        set { _abc = newValue }
    }
}
class Foo {
    var foo: Int {
        return 20
    }
}
class Foo {
    static var foo: Int {
        return 20
    }
}
class Foo {
    static var foo: Int {
        get { return 3 }
        set { _abc = newValue }
    }
}
class Foo {
    var foo: Int
}
class Foo {
    var foo: Int {
        return getValueFromDisk()
    }
}
class Foo {
    var foo: String {
        return "get"
    }
}
protocol Foo {
    var foo: Int { get }
protocol Foo {
    var foo: Int { get set }
class Foo {
    var foo: Int {
        struct Bar {
            var bar: Int {
                get { return 1 }
                set { _ = newValue }
            }
        }

        return Bar().bar
    }
}
var _objCTaggedPointerBits: UInt {
    @inline(__always) get { return 0 }
}
var next: Int? {
    mutating get {
        defer { self.count += 1 }
        return self.count
    }
}
class Foo {
    subscript(i: Int) -> Int {
        return 20
    }
}
class Foo {
    subscript(i: Int) -> Int {
        get { return 3 }
        set { _abc = newValue }
    }
}
protocol Foo {
    subscript(i: Int) -> Int { get }
}
protocol Foo {
    subscript(i: Int) -> Int { get set }
}
Triggering Examples
class Foo {
    var foo: Int {
        get {
            return 20
        }
    }
}
class Foo {
    var foo: Int {
        get{ return 20 }
    }
}
class Foo {
    static var foo: Int {
        get {
            return 20
        }
    }
}
var foo: Int {
    get { return 20 }
}
class Foo {
    @objc func bar() {}
    var foo: Int {
        get {
            return 20
        }
    }
}
class Foo {
    subscript(i: Int) -> Int {
        get {
            return 20
        }
    }
}

Implicit Return

Identifier Enabled by default Supports autocorrection Kind Analyzer Minimum Swift Compiler Version
implicit_return Disabled Yes style No 3.0.0

Prefer implicit returns in closures.

Examples

Non Triggering Examples
foo.map { $0 + 1 }
foo.map({ $0 + 1 })
foo.map { value in value + 1 }
func foo() -> Int {
  return 0
}
if foo {
  return 0
}
var foo: Bool { return true }
Triggering Examples
foo.map { value in
  return value + 1
}
foo.map {
  return $0 + 1
}
foo.map({ return $0 + 1})
[1, 2].first(where: {
    return true
})

Implicitly Unwrapped Optional

Identifier Enabled by default Supports autocorrection Kind Analyzer Minimum Swift Compiler Version
implicitly_unwrapped_optional Disabled No idiomatic No 3.0.0

Implicitly unwrapped optionals should be avoided when possible.

Examples

Non Triggering Examples
@IBOutlet private var label: UILabel!
@IBOutlet var label: UILabel!
@IBOutlet var label: [UILabel!]
if !boolean {}
let int: Int? = 42
let int: Int? = nil
Triggering Examples
let label: UILabel!
let IBOutlet: UILabel!
let labels: [UILabel!]
var ints: [Int!] = [42, nil, 42]
let label: IBOutlet!
let int: Int! = 42
let int: Int! = nil
var int: Int! = 42
let int: ImplicitlyUnwrappedOptional<Int>
let collection: AnyCollection<Int!>
func foo(int: Int!) {}

Inert Defer

Identifier Enabled by default Supports autocorrection Kind Analyzer Minimum Swift Compiler Version
inert_defer Enabled No lint No 3.0.0

If defer is at the end of its parent scope, it will be executed right where it is anyway.

Examples

Non Triggering Examples
func example3() {
    defer { /* deferred code */ }

    print("other code")
}
func example4() {
    if condition {
        defer { /* deferred code */ }
        print("other code")
    }
}
Triggering Examples
func example0() {
    defer { /* deferred code */ }
}
func example1() {
    defer { /* deferred code */ }
    // comment
}
func example2() {
    if condition {
        defer { /* deferred code */ }
        // comment
    }
}

Is Disjoint

Identifier Enabled by default Supports autocorrection Kind Analyzer Minimum Swift Compiler Version
is_disjoint Enabled No idiomatic No 3.0.0

Prefer using Set.isDisjoint(with:) over Set.intersection(_:).isEmpty.

Examples

Non Triggering Examples
_ = Set(syntaxKinds).isDisjoint(with: commentAndStringKindsSet)
let isObjc = !objcAttributes.isDisjoint(with: dictionary.enclosedSwiftAttributes)
_ = Set(syntaxKinds).intersection(commentAndStringKindsSet)
_ = !objcAttributes.intersection(dictionary.enclosedSwiftAttributes)
Triggering Examples
_ = Set(syntaxKinds).↓intersection(commentAndStringKindsSet).isEmpty
let isObjc = !objcAttributes.↓intersection(dictionary.enclosedSwiftAttributes).isEmpty

Joined Default Parameter

Identifier Enabled by default Supports autocorrection Kind Analyzer Minimum Swift Compiler Version
joined_default_parameter Disabled Yes idiomatic No 3.0.0

Discouraged explicit usage of the default separator.

Examples

Non Triggering Examples
let foo = bar.joined()
let foo = bar.joined(separator: ",")
let foo = bar.joined(separator: toto)
Triggering Examples
let foo = bar.joined(separator: "")
let foo = bar.filter(toto)
             .joined(separator: "")
func foo() -> String {
   return ["1", "2"].joined(separator: "")
}

Large Tuple

Identifier Enabled by default Supports autocorrection Kind Analyzer Minimum Swift Compiler Version
large_tuple Enabled No metrics No 3.0.0

Tuples shouldn't have too many members. Create a custom type instead.

Examples

Non Triggering Examples
let foo: (Int, Int)
let foo: (start: Int, end: Int)
let foo: (Int, (Int, String))
func foo() -> (Int, Int)
func foo() -> (Int, Int) {}
func foo(bar: String) -> (Int, Int)
func foo(bar: String) -> (Int, Int) {}
func foo() throws -> (Int, Int)
func foo() throws -> (Int, Int) {}
let foo: (Int, Int, Int) -> Void
let foo: (Int, Int, Int) throws -> Void
func foo(bar: (Int, String, Float) -> Void)
func foo(bar: (Int, String, Float) throws -> Void)
var completionHandler: ((_ data: Data?, _ resp: URLResponse?, _ e: NSError?) -> Void)!
func getDictionaryAndInt() -> (Dictionary<Int, String>, Int)?
func getGenericTypeAndInt() -> (Type<Int, String, Float>, Int)?
Triggering Examples
let foo: (Int, Int, Int)
let foo: (start: Int, end: Int, value: String)
let foo: (Int, (Int, Int, Int))
func foo(↓bar: (Int, Int, Int))
func foo() -> ↓(Int, Int, Int)
func foo() -> ↓(Int, Int, Int) {}
func foo(bar: String) -> ↓(Int, Int, Int)
func foo(bar: String) -> ↓(Int, Int, Int) {}
func foo() throws -> ↓(Int, Int, Int)
func foo() throws -> ↓(Int, Int, Int) {}
func foo() throws -> ↓(Int, ↓(String, String, String), Int) {}
func getDictionaryAndInt() -> (Dictionary<Int, ↓(String, String, String)>, Int)?

Leading Whitespace

Identifier Enabled by default Supports autocorrection Kind Analyzer Minimum Swift Compiler Version
leading_whitespace Enabled Yes style No 3.0.0

Files should not contain leading whitespace.

Examples

Non Triggering Examples
//
Triggering Examples
 //

Legacy CGGeometry Functions

Identifier Enabled by default Supports autocorrection Kind Analyzer Minimum Swift Compiler Version
legacy_cggeometry_functions Enabled Yes idiomatic No 3.0.0

Struct extension properties and methods are preferred over legacy functions

Examples

Non Triggering Examples
rect.width
rect.height
rect.minX
rect.midX
rect.maxX
rect.minY
rect.midY
rect.maxY
rect.isNull
rect.isEmpty
rect.isInfinite
rect.standardized
rect.integral
rect.insetBy(dx: 5.0, dy: -7.0)
rect.offsetBy(dx: 5.0, dy: -7.0)
rect1.union(rect2)
rect1.intersect(rect2)
rect1.contains(rect2)
rect.contains(point)
rect1.intersects(rect2)
Triggering Examples
CGRectGetWidth(rect)
CGRectGetHeight(rect)
CGRectGetMinX(rect)
CGRectGetMidX(rect)
CGRectGetMaxX(rect)
CGRectGetMinY(rect)
CGRectGetMidY(rect)
CGRectGetMaxY(rect)
CGRectIsNull(rect)
CGRectIsEmpty(rect)
CGRectIsInfinite(rect)
CGRectStandardize(rect)
CGRectIntegral(rect)
CGRectInset(rect, 10, 5)
CGRectOffset(rect, -2, 8.3)
CGRectUnion(rect1, rect2)
CGRectIntersection(rect1, rect2)
CGRectContainsRect(rect1, rect2)
CGRectContainsPoint(rect, point)
CGRectIntersectsRect(rect1, rect2)

Legacy Constant

Identifier Enabled by default Supports autocorrection Kind Analyzer Minimum Swift Compiler Version
legacy_constant Enabled Yes idiomatic No 3.0.0

Struct-scoped constants are preferred over legacy global constants.

Examples

Non Triggering Examples
CGRect.infinite
CGPoint.zero
CGRect.zero
CGSize.zero
NSPoint.zero
NSRect.zero
NSSize.zero
CGRect.null
CGFloat.pi
Float.pi
Triggering Examples
CGRectInfinite
CGPointZero
CGRectZero
CGSizeZero
NSZeroPoint
NSZeroRect
NSZeroSize
CGRectNull
CGFloat(M_PI)
Float(M_PI)

Legacy Constructor

Identifier Enabled by default Supports autocorrection Kind Analyzer Minimum Swift Compiler Version
legacy_constructor Enabled Yes idiomatic No 3.0.0

Swift constructors are preferred over legacy convenience functions.

Examples

Non Triggering Examples
CGPoint(x: 10, y: 10)
CGPoint(x: xValue, y: yValue)
CGSize(width: 10, height: 10)
CGSize(width: aWidth, height: aHeight)
CGRect(x: 0, y: 0, width: 10, height: 10)
CGRect(x: xVal, y: yVal, width: aWidth, height: aHeight)
CGVector(dx: 10, dy: 10)
CGVector(dx: deltaX, dy: deltaY)
NSPoint(x: 10, y: 10)
NSPoint(x: xValue, y: yValue)
NSSize(width: 10, height: 10)
NSSize(width: aWidth, height: aHeight)
NSRect(x: 0, y: 0, width: 10, height: 10)
NSRect(x: xVal, y: yVal, width: aWidth, height: aHeight)
NSRange(location: 10, length: 1)
NSRange(location: loc, length: len)
UIEdgeInsets(top: 0, left: 0, bottom: 10, right: 10)
UIEdgeInsets(top: aTop, left: aLeft, bottom: aBottom, right: aRight)
NSEdgeInsets(top: 0, left: 0, bottom: 10, right: 10)
NSEdgeInsets(top: aTop, left: aLeft, bottom: aBottom, right: aRight)
UIOffset(horizontal: 0, vertical: 10)
UIOffset(horizontal: horizontal, vertical: vertical)
Triggering Examples
CGPointMake(10, 10)
CGPointMake(xVal, yVal)
CGPointMake(calculateX(), 10)
CGSizeMake(10, 10)
CGSizeMake(aWidth, aHeight)
CGRectMake(0, 0, 10, 10)
CGRectMake(xVal, yVal, width, height)
CGVectorMake(10, 10)
CGVectorMake(deltaX, deltaY)
NSMakePoint(10, 10)
NSMakePoint(xVal, yVal)
NSMakeSize(10, 10)
NSMakeSize(aWidth, aHeight)
NSMakeRect(0, 0, 10, 10)
NSMakeRect(xVal, yVal, width, height)
NSMakeRange(10, 1)
NSMakeRange(loc, len)
UIEdgeInsetsMake(0, 0, 10, 10)
UIEdgeInsetsMake(top, left, bottom, right)
NSEdgeInsetsMake(0, 0, 10, 10)
NSEdgeInsetsMake(top, left, bottom, right)
CGVectorMake(10, 10)
NSMakeRange(10, 1)
UIOffsetMake(0, 10)
UIOffsetMake(horizontal, vertical)

Legacy Hashing

Identifier Enabled by default Supports autocorrection Kind Analyzer Minimum Swift Compiler Version
legacy_hashing Enabled No idiomatic No 4.2.0

Prefer using the hash(into:) function instead of overriding hashValue

Examples

Non Triggering Examples
struct Foo: Hashable {
    let bar: Int = 10

    func hash(into hasher: inout Hasher) {
        hasher.combine(bar)
      }
}
class Foo: Hashable {
    let bar: Int = 10

    func hash(into hasher: inout Hasher) {
        hasher.combine(bar)
      }
}
var hashValue: Int { return 1 }
class Foo: Hashable { 
 }
class Foo: Hashable {
    let bar: String = "Foo"

    public var hashValue: String {
        return bar
    }
}
class Foo: Hashable {
    let bar: String = "Foo"

    public var hashValue: String {
        get { return bar }
        set { bar = newValue }
    }
}
Triggering Examples
struct Foo: Hashable {
    let bar: Int = 10

    public var hashValue: Int {
        return bar
    }
}
class Foo: Hashable {
    let bar: Int = 10

    public var hashValue: Int {
        return bar
    }
}

Legacy NSGeometry Functions

Identifier Enabled by default Supports autocorrection Kind Analyzer Minimum Swift Compiler Version
legacy_nsgeometry_functions Enabled Yes idiomatic No 3.0.0

Struct extension properties and methods are preferred over legacy functions

Examples

Non Triggering Examples
rect.width
rect.height
rect.minX
rect.midX
rect.maxX
rect.minY
rect.midY
rect.maxY
rect.isEmpty
rect.integral
rect.insetBy(dx: 5.0, dy: -7.0)
rect.offsetBy(dx: 5.0, dy: -7.0)
rect1.union(rect2)
rect1.intersect(rect2)
rect1.contains(rect2)
rect.contains(point)
rect1.intersects(rect2)
Triggering Examples
NSWidth(rect)
NSHeight(rect)
NSMinX(rect)
NSMidX(rect)
NSMaxX(rect)
NSMinY(rect)
NSMidY(rect)
NSMaxY(rect)
NSEqualRects(rect1, rect2)
NSEqualSizes(size1, size2)
NSEqualPoints(point1, point2)
NSEdgeInsetsEqual(insets2, insets2)
NSIsEmptyRect(rect)
NSIntegralRect(rect)
NSInsetRect(rect, 10, 5)
NSOffsetRect(rect, -2, 8.3)
NSUnionRect(rect1, rect2)
NSIntersectionRect(rect1, rect2)
NSContainsRect(rect1, rect2)
NSPointInRect(rect, point)
NSIntersectsRect(rect1, rect2)

Legacy Random

Identifier Enabled by default Supports autocorrection Kind Analyzer Minimum Swift Compiler Version
legacy_random Disabled No idiomatic No 4.2.0

Prefer using type.random(in:) over legacy functions.

Examples

Non Triggering Examples
Int.random(in: 0..<10)
Double.random(in: 8.6...111.34)
Float.random(in: 0 ..< 1)
Triggering Examples
arc4random(10)
arc4random_uniform(83)
drand48(52)

Variable Declaration Whitespace

Identifier Enabled by default Supports autocorrection Kind Analyzer Minimum Swift Compiler Version
let_var_whitespace Disabled No style No 3.0.0

Let and var should be separated from other statements by a blank line.

Examples

Non Triggering Examples
let a = 0
var x = 1

x = 2
a = 5

var x = 1
struct X {
	var a = 0
}
let a = 1 +
	2
let b = 5
var x: Int {
	return 0
}
var x: Int {
	let a = 0

	return a
}
#if os(macOS)
let a = 0
#endif
@available(swift 4)
let a = 0
class C {
	@objc
	var s: String = ""
}
class C {
	@objc
	func a() {}
}
class C {
	var x = 0
	lazy
	var y = 0
}
@available(OSX, introduced: 10.6)
@available(*, deprecated)
var x = 0
// swiftlint:disable superfluous_disable_command
// swiftlint:disable force_cast

let x = bar as! Bar
var x: Int {
	let a = 0
	return a
}
Triggering Examples
var x = 1
x = 2
a = 5
var x = 1
struct X {
	let a
	func x() {}
}
var x = 0
@objc func f() {}
var x = 0
@objc
	func f() {}
@objc func f() {
}
var x = 0

Line Length

Identifier Enabled by default Supports autocorrection Kind Analyzer Minimum Swift Compiler Version
line_length Enabled No metrics No 3.0.0

Lines should not span too many characters.

Examples

Non Triggering Examples
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)
#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")
Triggering Examples
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)
#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")

Literal Expression End Indentation

Identifier Enabled by default Supports autocorrection Kind Analyzer Minimum Swift Compiler Version
literal_expression_end_indentation Disabled Yes style No 3.0.0

Array and dictionary literal end should have the same indentation as the line that started it.

Examples

Non Triggering Examples
[1, 2, 3]
[1,
 2
]
[
   1,
   2
]
[
   1,
   2]
   let x = [
       1,
       2
   ]
[key: 2, key2: 3]
[key: 1,
 key2: 2
]
[
   key: 0,
   key2: 20
]
Triggering Examples
let x = [
   1,
   2
   ]
   let x = [
       1,
       2
]
let x = [
   key: value
   ]

Lower ACL than parent

Identifier Enabled by default Supports autocorrection Kind Analyzer Minimum Swift Compiler Version
lower_acl_than_parent Disabled No lint No 3.0.0

Ensure definitions have a lower access control level than their enclosing parent

Examples

Non Triggering Examples
public struct Foo { public func bar() {} }
internal struct Foo { func bar() {} }
struct Foo { func bar() {} }
open class Foo { public func bar() {} }
open class Foo { open func bar() {} }
fileprivate struct Foo { private func bar() {} }
private struct Foo { private func bar(id: String) }
extension Foo { public func bar() {} }
private struct Foo { fileprivate func bar() {} }
private func foo(id: String) {}
Triggering Examples
struct Foo { public func bar() {} }
enum Foo { public func bar() {} }
public class Foo { open func bar() }
class Foo { public private(set) var bar: String? }

Mark

Identifier Enabled by default Supports autocorrection Kind Analyzer Minimum Swift Compiler Version
mark Enabled Yes lint No 3.0.0

MARK comment should be in valid format. e.g. '// MARK: ...' or '// MARK: - ...'

Examples

Non Triggering Examples
// MARK: good
// MARK: - good
// MARK: -
// BOOKMARK
//BOOKMARK
// BOOKMARKS
Triggering Examples
//MARK: bad
// MARK:bad
//MARK:bad
//  MARK: bad
// MARK:  bad
// MARK: -bad
// MARK:- bad
// MARK:-bad
//MARK: - bad
//MARK:- bad
//MARK: -bad
//MARK:-bad
//Mark: bad
// Mark: bad
// MARK bad
//MARK bad
// MARK - bad
//MARK : bad
// MARKL:
// MARKR 
// MARKK -
//MARK:- Top-Level bad mark
//MARK:- Another bad mark
struct MarkTest {}
// MARK:- Bad mark
extension MarkTest {}

Missing Docs

Identifier Enabled by default Supports autocorrection Kind Analyzer Minimum Swift Compiler Version
missing_docs Disabled No lint No 4.1.0

Declarations should be documented.

Examples

Non Triggering Examples
/// docs
public class A {
/// docs
public func b() {}
}
/// docs
public class B: A { override public func b() {} }
import Foundation
/// docs
public class B: NSObject {
// no docs
override public var description: String { fatalError() } }
Triggering Examples
public func a() {}
// regular comment
public func a() {}
/* regular comment */
public func a() {}
/// docs
public protocol A {
// no docs
var b: Int { get } }
/// docs
public struct C: A {

public let b: Int
}

Modifier Order

Identifier Enabled by default Supports autocorrection Kind Analyzer Minimum Swift Compiler Version
modifier_order Disabled No style No 4.1.0

Modifier order should be consistent.

Examples

Non Triggering Examples
public class Foo { 
   public convenience required init() {} 
}
public class Foo { 
   public static let bar = 42 
}
public class Foo { 
   public static var bar: Int { 
       return 42   }}
public class Foo { 
   public class var bar: Int { 
       return 42 
   } 
}
public class Bar { 
   public class var foo: String { 
       return "foo" 
   } 
} 
public class Foo: Bar { 
   override public final class var foo: String { 
       return "bar" 
   } 
}
open class Bar { 
   public var foo: Int? { 
       return 42 
   } 
} 
open class Foo: Bar { 
   override public var foo: Int? { 
       return 43 
   } 
}
open class Bar { 
   open class func foo() -> Int { 
       return 42 
   } 
} 
class Foo: Bar { 
   override open class func foo() -> Int { 
       return 43 
   } 
}
protocol Foo: class {} 
class Bar { 
    public private(set) weak var foo: Foo? 
} 
@objc 
public final class Foo: NSObject {} 
@objcMembers 
public final class Foo: NSObject {} 
@objc 
override public private(set) weak var foo: Bar? 
@objc 
public final class Foo: NSObject {} 
@objc 
open final class Foo: NSObject { 
   open weak var weakBar: NSString? = nil 
}
public final class Foo {}
class Bar { 
   func bar() {} 
}
internal class Foo: Bar { 
   override internal func bar() {} 
}
public struct Foo { 
   internal weak var weakBar: NSObject? = nil 
}
class Foo { 
   internal lazy var bar: String = "foo" 
}
Triggering Examples
class Foo { 
   convenience required public init() {} 
}
public class Foo { 
   static public let bar = 42 
}
public class Foo { 
   static public var bar: Int { 
       return 42 
   } 
} 
public class Foo { 
   class public var bar: Int { 
       return 42 
   } 
}
public class RootFoo { 
   class public var foo: String { 
       return "foo" 
   } 
} 
public class Foo: RootFoo { 
   override final class public var foo: String { 
       return "bar" 
   } 
}
open class Bar { 
   public var foo: Int? { 
       return 42 
   } 
} 
open class Foo: Bar { 
    public override var foo: Int? { 
       return 43 
   } 
}
protocol Foo: class {} 
class Bar { 
    private(set) public weak var foo: Foo? 
} 
open class Bar { 
   open class func foo() -> Int { 
       return 42 
   } 
} 
class Foo: Bar { 
   class open override func foo() -> Int { 
       return 43 
   } 
}
open class Bar { 
   open class func foo() -> Int { 
       return 42 
   } 
} 
class Foo: Bar { 
   open override class func foo() -> Int { 
       return 43 
   } 
}
@objc 
final public class Foo: NSObject {}
@objcMembers 
final public class Foo: NSObject {}
@objc 
final open class Foo: NSObject { 
   weak open var weakBar: NSString? = nil 
}
final public class Foo {} 
internal class Foo: Bar { 
   internal override func bar() {} 
}
public struct Foo { 
   weak internal var weakBar: NSObjetc? = nil 
}
class Foo { 
   lazy internal var bar: String = "foo" 
}

Multiline Arguments

Identifier Enabled by default Supports autocorrection Kind Analyzer Minimum Swift Compiler Version
multiline_arguments Disabled No style No 3.0.0

Arguments should be either on the same line, or one per line.

Examples

Non Triggering Examples
foo()
foo(
    
)
foo { }
foo {
    
}
foo(0)
foo(0, 1)
foo(0, 1) { }
foo(0, param1: 1)
foo(0, param1: 1) { }
foo(param1: 1)
foo(param1: 1) { }
foo(param1: 1, param2: true) { }
foo(param1: 1, param2: true, param3: [3]) { }
foo(param1: 1, param2: true, param3: [3]) {
    bar()
}
foo(param1: 1,
    param2: true,
    param3: [3])
foo(
    param1: 1, param2: true, param3: [3]
)
foo(
    param1: 1,
    param2: true,
    param3: [3]
)
Triggering Examples
foo(0,
    param1: 1, param2: true, param3: [3])
foo(0, param1: 1,
    param2: true, param3: [3])
foo(0, param1: 1, param2: true,
    param3: [3])
foo(
    0, param1: 1,
    param2: true, param3: [3]
)

Multiline Arguments Brackets

Identifier Enabled by default Supports autocorrection Kind Analyzer Minimum Swift Compiler Version
multiline_arguments_brackets Disabled No style No 3.0.0

Multiline arguments should have their surrounding brackets in a new line.

Examples

Non Triggering Examples
foo(param1: "Param1", param2: "Param2", param3: "Param3")
foo(
    param1: "Param1", param2: "Param2", param3: "Param3"
)
func foo(
    param1: "Param1",
    param2: "Param2",
    param3: "Param3"
)
foo { param1, param2 in
    print("hello world")
}
foo(
    bar(
        x: 5,
        y: 7
    )
)
AlertViewModel.AlertAction(title: "some title", style: .default) {
    AlertManager.shared.presentNextDebugAlert()
}
Triggering Examples
foo(param1: "Param1", param2: "Param2",
         param3: "Param3"
)
foo(
    param1: "Param1",
    param2: "Param2",
    param3: "Param3")
foo(bar(
    x: 5,
    y: 7
)
)
foo(
    bar(
        x: 5,
        y: 7
))

Multiline Function Chains

Identifier Enabled by default Supports autocorrection Kind Analyzer Minimum Swift Compiler Version
multiline_function_chains Disabled No style No 3.0.0

Chained function calls should be either on the same line, or one per line.

Examples

Non Triggering Examples
let evenSquaresSum = [20, 17, 35, 4].filter { $0 % 2 == 0 }.map { $0 * $0 }.reduce(0, +)
let evenSquaresSum = [20, 17, 35, 4]
    .filter { $0 % 2 == 0 }.map { $0 * $0 }.reduce(0, +)",
let chain = a
    .b(1, 2, 3)
    .c { blah in
        print(blah)
    }
    .d()
let chain = a.b(1, 2, 3)
    .c { blah in
        print(blah)
    }
    .d()
let chain = a.b(1, 2, 3)
    .c { blah in print(blah) }
    .d()
let chain = a.b(1, 2, 3)
    .c(.init(
        a: 1,
        b, 2,
        c, 3))
    .d()
self.viewModel.outputs.postContextualNotification
  .observeForUI()
  .observeValues {
    NotificationCenter.default.post(
      Notification(
        name: .ksr_showNotificationsDialog,
        userInfo: [UserInfoKeys.context: PushNotificationDialog.Context.pledge,
                   UserInfoKeys.viewController: self]
     )
    )
  }
let remainingIDs = Array(Set(self.currentIDs).subtracting(Set(response.ids)))
self.happeningNewsletterOn = self.updateCurrentUser
    .map { $0.newsletters.happening }.skipNil().skipRepeats()
Triggering Examples
let evenSquaresSum = [20, 17, 35, 4]
    .filter { $0 % 2 == 0 }.map { $0 * $0 }
    .reduce(0, +)
let evenSquaresSum = a.b(1, 2, 3)
    .c { blah in
        print(blah)
    }.d()
let evenSquaresSum = a.b(1, 2, 3)
    .c(2, 3, 4).d()
let evenSquaresSum = a.b(1, 2, 3).c { blah in
        print(blah)
    }
    .d()
a.b {
//  ““
}.e()

Multiline Literal Brackets

Identifier Enabled by default Supports autocorrection Kind Analyzer Minimum Swift Compiler Version
multiline_literal_brackets Disabled No style No 3.0.0

Multiline literals should have their surrounding brackets in a new line.

Examples

Non Triggering Examples
let trio = ["harry", "ronald", "hermione"]
let houseCup = ["gryffinder": 460, "hufflepuff": 370, "ravenclaw": 410, "slytherin": 450]
let trio = [
    "harry",
    "ronald",
    "hermione"
]
let houseCup = [
    "gryffinder": 460,
    "hufflepuff": 370,
    "ravenclaw": 410,
    "slytherin": 450
]
let trio = [
    "harry", "ronald", "hermione"
]
let houseCup = [
    "gryffinder": 460, "hufflepuff": 370,
    "ravenclaw": 410, "slytherin": 450
]
    _ = [
        1,
        2,
        3,
        4,
        5, 6,
        7, 8, 9
    ]
Triggering Examples
let trio = ["harry",
            "ronald",
            "hermione"
]
let houseCup = ["gryffinder": 460, "hufflepuff": 370,
                "ravenclaw": 410, "slytherin": 450
]
let trio = [
    "harry",
    "ronald",
    "hermione"]
let houseCup = [
    "gryffinder": 460, "hufflepuff": 370,
    "ravenclaw": 410, "slytherin": 450]
class Hogwarts {
    let houseCup = [
        "gryffinder": 460, "hufflepuff": 370,
        "ravenclaw": 410, "slytherin": 450]
}
    _ = [
        1,
        2,
        3,
        4,
        5, 6,
        7, 8, 9]
    _ = [1, 2, 3,
         4, 5, 6,
         7, 8, 9
    ]

Multiline Parameters

Identifier Enabled by default Supports autocorrection Kind Analyzer Minimum Swift Compiler Version
multiline_parameters Disabled No style No 3.0.0

Functions and methods parameters should be either on the same line, or one per line.

Examples

Non Triggering Examples
func foo() { }
func foo(param1: Int) { }
func foo(param1: Int, param2: Bool) { }
func foo(param1: Int, param2: Bool, param3: [String]) { }
func foo(param1: Int,
         param2: Bool,
         param3: [String]) { }
func foo(_ param1: Int, param2: Int, param3: Int) -> (Int) -> Int {
   return { x in x + param1 + param2 + param3 }
}
static func foo() { }
static func foo(param1: Int) { }
static func foo(param1: Int, param2: Bool) { }
static func foo(param1: Int, param2: Bool, param3: [String]) { }
static func foo(param1: Int,
                param2: Bool,
                param3: [String]) { }
protocol Foo {
	func foo() { }
}
protocol Foo {
	func foo(param1: Int) { }
}
protocol Foo {
	func foo(param1: Int, param2: Bool) { }
}
protocol Foo {
	func foo(param1: Int, param2: Bool, param3: [String]) { }
}
protocol Foo {
   func foo(param1: Int,
            param2: Bool,
            param3: [String]) { }
}
protocol Foo {
	static func foo(param1: Int, param2: Bool, param3: [String]) { }
}
protocol Foo {
   static func foo(param1: Int,
                   param2: Bool,
                   param3: [String]) { }
}
protocol Foo {
	class func foo(param1: Int, param2: Bool, param3: [String]) { }
}
protocol Foo {
   class func foo(param1: Int,
                  param2: Bool,
                  param3: [String]) { }
}
enum Foo {
	func foo() { }
}
enum Foo {
	func foo(param1: Int) { }
}
enum Foo {
	func foo(param1: Int, param2: Bool) { }
}
enum Foo {
	func foo(param1: Int, param2: Bool, param3: [String]) { }
}
enum Foo {
   func foo(param1: Int,
            param2: Bool,
            param3: [String]) { }
}
enum Foo {
	static func foo(param1: Int, param2: Bool, param3: [String]) { }
}
enum Foo {
   static func foo(param1: Int,
                   param2: Bool,
                   param3: [String]) { }
}
struct Foo {
	func foo() { }
}
struct Foo {
	func foo(param1: Int) { }
}
struct Foo {
	func foo(param1: Int, param2: Bool) { }
}
struct Foo {
	func foo(param1: Int, param2: Bool, param3: [String]) { }
}
struct Foo {
   func foo(param1: Int,
            param2: Bool,
            param3: [String]) { }
}
struct Foo {
	static func foo(param1: Int, param2: Bool, param3: [String]) { }
}
struct Foo {
   static func foo(param1: Int,
                   param2: Bool,
                   param3: [String]) { }
}
class Foo {
	func foo() { }
}
class Foo {
	func foo(param1: Int) { }
}
class Foo {
	func foo(param1: Int, param2: Bool) { }
}
class Foo {
	func foo(param1: Int, param2: Bool, param3: [String]) { }
	}
class Foo {
   func foo(param1: Int,
            param2: Bool,
            param3: [String]) { }
}
class Foo {
	class func foo(param1: Int, param2: Bool, param3: [String]) { }
}
class Foo {
   class func foo(param1: Int,
                  param2: Bool,
                  param3: [String]) { }
}
class Foo {
   class func foo(param1: Int,
                  param2: Bool,
                  param3: @escaping (Int, Int) -> Void = { _, _ in }) { }
}
class Foo {
   class func foo(param1: Int,
                  param2: Bool,
                  param3: @escaping (Int) -> Void = { _ in }) { }
}
class Foo {
   class func foo(param1: Int,
                  param2: Bool,
                  param3: @escaping ((Int) -> Void)? = nil) { }
}
class Foo {
   class func foo(param1: Int,
                  param2: Bool,
                  param3: @escaping ((Int) -> Void)? = { _ in }) { }
}
class Foo {
   class func foo(param1: Int,
                  param2: @escaping ((Int) -> Void)? = { _ in },
                  param3: Bool) { }
}
class Foo {
   class func foo(param1: Int,
                  param2: @escaping ((Int) -> Void)? = { _ in },
                  param3: @escaping (Int, Int) -> Void = { _, _ in }) { }
}
class Foo {
   class func foo(param1: Int,
                  param2: Bool,
                  param3: @escaping (Int) -> Void = { (x: Int) in }) { }
}
class Foo {
   class func foo(param1: Int,
                  param2: Bool,
                  param3: @escaping (Int, (Int) -> Void) -> Void = { (x: Int, f: (Int) -> Void) in }) { }
}
Triggering Examples
func foo(_ param1: Int,
          param2: Int, param3: Int) -> (Int) -> Int {
   return { x in x + param1 + param2 + param3 }
}
protocol Foo {
   func foo(param1: Int,
             param2: Bool, param3: [String]) { }
}
protocol Foo {
   func foo(param1: Int, param2: Bool,
             param3: [String]) { }
}
protocol Foo {
   static func foo(param1: Int,
                    param2: Bool, param3: [String]) { }
}
protocol Foo {
   static func foo(param1: Int, param2: Bool,
                    param3: [String]) { }
}
protocol Foo {
   class func foo(param1: Int,
                   param2: Bool, param3: [String]) { }
}
protocol Foo {
   class func foo(param1: Int, param2: Bool,
                   param3: [String]) { }
}
enum Foo {
   func foo(param1: Int,
             param2: Bool, param3: [String]) { }
}
enum Foo {
   func foo(param1: Int, param2: Bool,
             param3: [String]) { }
}
enum Foo {
   static func foo(param1: Int,
                    param2: Bool, param3: [String]) { }
}
enum Foo {
   static func foo(param1: Int, param2: Bool,
                    param3: [String]) { }
}
struct Foo {
   func foo(param1: Int,
             param2: Bool, param3: [String]) { }
}
struct Foo {
   func foo(param1: Int, param2: Bool,
             param3: [String]) { }
}
struct Foo {
   static func foo(param1: Int,
                    param2: Bool, param3: [String]) { }
}
struct Foo {
   static func foo(param1: Int, param2: Bool,
                    param3: [String]) { }
}
class Foo {
   func foo(param1: Int,
             param2: Bool, param3: [String]) { }
}
class Foo {
   func foo(param1: Int, param2: Bool,
             param3: [String]) { }
}
class Foo {
   class func foo(param1: Int,
                   param2: Bool, param3: [String]) { }
}
class Foo {
   class func foo(param1: Int, param2: Bool,
                   param3: [String]) { }
}
class Foo {
   class func foo(param1: Int,
                  param2: Bool, param3: @escaping (Int, Int) -> Void = { _, _ in }) { }
}
class Foo {
   class func foo(param1: Int,
                  param2: Bool, param3: @escaping (Int) -> Void = { (x: Int) in }) { }
}

Multiline Parameters Brackets

Identifier Enabled by default Supports autocorrection Kind Analyzer Minimum Swift Compiler Version
multiline_parameters_brackets Disabled No style No 3.0.0

Multiline parameters should have their surrounding brackets in a new line.

Examples

Non Triggering Examples
func foo(param1: String, param2: String, param3: String)
func foo(
    param1: String, param2: String, param3: String
)
func foo(
    param1: String,
    param2: String,
    param3: String
)
class SomeType {
    func foo(param1: String, param2: String, param3: String)
}
class SomeType {
    func foo(
        param1: String, param2: String, param3: String
    )
}
class SomeType {
    func foo(
        param1: String,
        param2: String,
        param3: String
    )
}
func foo<T>(param1: T, param2: String, param3: String) -> T { /* some code */ }
Triggering Examples
func foo(↓param1: String, param2: String,
         param3: String
)
func foo(
    param1: String,
    param2: String,
    param3: String↓)
class SomeType {
    func foo(↓param1: String, param2: String,
             param3: String
    )
}
class SomeType {
    func foo(
        param1: String,
        param2: String,
        param3: String↓)
}
func foo<T>(↓param1: T, param2: String,
         param3: String
) -> T

Multiple Closures with Trailing Closure

Identifier Enabled by default Supports autocorrection Kind Analyzer Minimum Swift Compiler Version
multiple_closures_with_trailing_closure Enabled No style No 3.0.0

Trailing closure syntax should not be used when passing more than one closure argument.

Examples

Non Triggering Examples
foo.map { $0 + 1 }
foo.reduce(0) { $0 + $1 }
if let foo = bar.map({ $0 + 1 }) {

}
foo.something(param1: { $0 }, param2: { $0 + 1 })
UIView.animate(withDuration: 1.0) {
    someView.alpha = 0.0
}
Triggering Examples
foo.something(param1: { $0 }) { $0 + 1 }
UIView.animate(withDuration: 1.0, animations: {
    someView.alpha = 0.0
}) { _ in
    someView.removeFromSuperview()
}

Nesting

Identifier Enabled by default Supports autocorrection Kind Analyzer Minimum Swift Compiler Version
nesting Enabled No metrics No 3.0.0

Types should be nested at most 1 level deep, and statements should be nested at most 5 levels deep.

Examples

Non Triggering Examples
class Class0 { class Class1 {} }
func func0() {
func func1() {
func func2() {
func func3() {
func func4() { func func5() {
}
}
}
}
}
}
struct Class0 { struct Class1 {} }
func func0() {
func func1() {
func func2() {
func func3() {
func func4() { func func5() {
}
}
}
}
}
}
enum Class0 { enum Class1 {} }
func func0() {
func func1() {
func func2() {
func func3() {
func func4() { func func5() {
}
}
}
}
}
}
enum Enum0 { enum Enum1 { case Case } }
Triggering Examples
class A { class B { class C {} } }
struct A { struct B { struct C {} } }
enum A { enum B { enum C {} } }
func func0() {
func func1() {
func func2() {
func func3() {
func func4() { func func5() {
func func6() {
}
}
}
}
}
}
}

Nimble Operator

Identifier Enabled by default Supports autocorrection Kind Analyzer Minimum Swift Compiler Version
nimble_operator Disabled Yes idiomatic No 3.0.0

Prefer Nimble operator overloads over free matcher functions.

Examples

Non Triggering Examples
expect(seagull.squawk) != "Hi!"
expect("Hi!") == "Hi!"
expect(10) > 2
expect(10) >= 10
expect(10) < 11
expect(10) <= 10
expect(x) === x
expect(10) == 10
expect(object.asyncFunction()).toEventually(equal(1))
expect(actual).to(haveCount(expected))
foo.method {
    expect(value).to(equal(expectedValue), description: "Failed")
    return Bar(value: ())
}
Triggering Examples
expect(seagull.squawk).toNot(equal("Hi"))
expect(12).toNot(equal(10))
expect(10).to(equal(10))
expect(10, line: 1).to(equal(10))
expect(10).to(beGreaterThan(8))
expect(10).to(beGreaterThanOrEqualTo(10))
expect(10).to(beLessThan(11))
expect(10).to(beLessThanOrEqualTo(10))
expect(x).to(beIdenticalTo(x))
expect(10) > 2
 expect(10).to(beGreaterThan(2))

No Extension Access Modifier

Identifier Enabled by default Supports autocorrection Kind Analyzer Minimum Swift Compiler Version
no_extension_access_modifier Disabled No idiomatic No 3.0.0

Prefer not to use extension access modifiers

Examples

Non Triggering Examples
extension String {}
 extension String {}
Triggering Examples
private extension String {}
public 
 extension String {}
open extension String {}
internal extension String {}
fileprivate extension String {}

No Fallthrough Only

Identifier Enabled by default Supports autocorrection Kind Analyzer Minimum Swift Compiler Version
no_fallthrough_only Enabled No idiomatic No 3.0.0

Fallthroughs can only be used if the case contains at least one other statement.

Examples

Non Triggering Examples
switch myvar {
case 1:
    var a = 1
    fallthrough
case 2:
    var a = 2
}
switch myvar {
case "a":
    var one = 1
    var two = 2
    fallthrough
case "b": /* comment */
    var three = 3
}
switch myvar {
case 1:
   let one = 1
case 2:
   // comment
   var two = 2
}
switch myvar {
case MyFunc(x: [1, 2, YourFunc(a: 23)], y: 2):
    var three = 3
    fallthrough
default:
    var three = 4
}
switch myvar {
case .alpha:
    var one = 1
case .beta:
    var three = 3
    fallthrough
default:
    var four = 4
}
let aPoint = (1, -1)
switch aPoint {
case let (x, y) where x == y:
    let A = "A"
case let (x, y) where x == -y:
    let B = "B"
    fallthrough
default:
    let C = "C"
}
switch myvar {
case MyFun(with: { $1 }):
    let one = 1
    fallthrough
case "abc":
    let two = 2
}
Triggering Examples
switch myvar {
case 1:
    fallthrough
case 2:
    var a = 1
}
switch myvar {
case 1:
    var a = 2
case 2:
    fallthrough
case 3:
    var a = 3
}
switch myvar {
case 1: // comment
    fallthrough
}
switch myvar {
case 1: /* multi
    line
    comment */
    fallthrough
case 2:
    var a = 2
}
switch myvar {
case MyFunc(x: [1, 2, YourFunc(a: 23)], y: 2):
    fallthrough
default:
    var three = 4
}
switch myvar {
case .alpha:
    var one = 1
case .beta:
    fallthrough
case .gamma:
    var three = 3
default:
  var four = 4
}
let aPoint = (1, -1)
switch aPoint {
case let (x, y) where x == y:
    let A = "A"
case let (x, y) where x == -y:
    fallthrough
default:
    let B = "B"
}
switch myvar {
case MyFun(with: { $1 }):
    fallthrough
case "abc":
    let two = 2
}

No Grouping Extension

Identifier Enabled by default Supports autocorrection Kind Analyzer Minimum Swift Compiler Version
no_grouping_extension Disabled No idiomatic No 3.0.0

Extensions shouldn't be used to group code within the same source file.

Examples

Non Triggering Examples
protocol Food {}
extension Food {}
class Apples {}
extension Oranges {}
Triggering Examples
enum Fruit {}
extension Fruit {}
extension Tea: Error {}
struct Tea {}
class Ham { class Spam {}}
extension Ham.Spam {}
extension External { struct Gotcha {}}
extension External.Gotcha {}

Notification Center Detachment

Identifier Enabled by default Supports autocorrection Kind Analyzer Minimum Swift Compiler Version
notification_center_detachment Enabled No lint No 3.0.0

An object should only remove itself as an observer in deinit.

Examples

Non Triggering Examples
class Foo { 
   deinit {
       NotificationCenter.default.removeObserver(self)
   }
}
class Foo { 
   func bar() {
       NotificationCenter.default.removeObserver(otherObject)
   }
}
Triggering Examples
class Foo { 
   func bar() {
       NotificationCenter.default.removeObserver(self)
   }
}

Number Separator

Identifier Enabled by default Supports autocorrection Kind Analyzer Minimum Swift Compiler Version
number_separator Disabled Yes style No 3.0.0

Underscores should be used as thousand separator in large decimal numbers.

Examples

Non Triggering Examples
let foo = -100
let foo = -1_000
let foo = -1_000_000
let foo = -1.000_1
let foo = -1_000_000.000_000_1
let binary = -0b10000
let binary = -0b1000_0001
let hex = -0xA
let hex = -0xAA_BB
let octal = -0o21
let octal = -0o21_1
let exp = -1_000_000.000_000e2
let foo = +100
let foo = +1_000
let foo = +1_000_000
let foo = +1.000_1
let foo = +1_000_000.000_000_1
let binary = +0b10000
let binary = +0b1000_0001
let hex = +0xA
let hex = +0xAA_BB
let octal = +0o21
let octal = +0o21_1
let exp = +1_000_000.000_000e2
let foo = 100
let foo = 1_000
let foo = 1_000_000
let foo = 1.000_1
let foo = 1_000_000.000_000_1
let binary = 0b10000
let binary = 0b1000_0001
let hex = 0xA
let hex = 0xAA_BB
let octal = 0o21
let octal = 0o21_1
let exp = 1_000_000.000_000e2
Triggering Examples
let foo = ↓-10_0
let foo = ↓-1000
let foo = ↓-1000e2
let foo = ↓-1000E2
let foo = ↓-1__000
let foo = ↓-1.0001
let foo = ↓-1_000_000.000000_1
let foo = ↓-1000000.000000_1
let foo = +↓10_0
let foo = +↓1000
let foo = +↓1000e2
let foo = +↓1000E2
let foo = +↓1__000
let foo = +↓1.0001
let foo = +↓1_000_000.000000_1
let foo = +↓1000000.000000_1
let foo = 10_0
let foo = 1000
let foo = 1000e2
let foo = 1000E2
let foo = 1__000
let foo = 1.0001
let foo = 1_000_000.000000_1
let foo = 1000000.000000_1

Object Literal

Identifier Enabled by default Supports autocorrection Kind Analyzer Minimum Swift Compiler Version
object_literal Disabled No idiomatic No 3.0.0

Prefer object literals over image and color inits.

Examples

Non Triggering Examples
let image = #imageLiteral(resourceName: "image.jpg")
let color = #colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)
let image = UIImage(named: aVariable)
let image = UIImage(named: "interpolated \(variable)")
let color = UIColor(red: value, green: value, blue: value, alpha: 1)
let image = NSImage(named: aVariable)
let image = NSImage(named: "interpolated \(variable)")
let color = NSColor(red: value, green: value, blue: value, alpha: 1)
Triggering Examples
let image = UIImage(named: "foo")
let color = UIColor(red: 0.3, green: 0.3, blue: 0.3, alpha: 1)
let color = UIColor(red: 100 / 255.0, green: 50 / 255.0, blue: 0, alpha: 1)
let color = UIColor(white: 0.5, alpha: 1)
let image = NSImage(named: "foo")
let color = NSColor(red: 0.3, green: 0.3, blue: 0.3, alpha: 1)
let color = NSColor(red: 100 / 255.0, green: 50 / 255.0, blue: 0, alpha: 1)
let color = NSColor(white: 0.5, alpha: 1)
let image = UIImage.init(named: "foo")
let color = UIColor.init(red: 0.3, green: 0.3, blue: 0.3, alpha: 1)
let color = UIColor.init(red: 100 / 255.0, green: 50 / 255.0, blue: 0, alpha: 1)
let color = UIColor.init(white: 0.5, alpha: 1)
let image = NSImage.init(named: "foo")
let color = NSColor.init(red: 0.3, green: 0.3, blue: 0.3, alpha: 1)
let color = NSColor.init(red: 100 / 255.0, green: 50 / 255.0, blue: 0, alpha: 1)
let color = NSColor.init(white: 0.5, alpha: 1)

Opening Brace Spacing

Identifier Enabled by default Supports autocorrection Kind Analyzer Minimum Swift Compiler Version
opening_brace Enabled Yes style No 3.0.0

Opening braces should be preceded by a single space and on the same line as the declaration.

Examples

Non Triggering Examples
func abc() {
}
[].map() { $0 }
[].map({ })
if let a = b { }
while a == b { }
guard let a = b else { }
if
	let a = b,
	let c = d
	where a == c
{ }
while
	let a = b,
	let c = d
	where a == c
{ }
guard
	let a = b,
	let c = d
	where a == c else
{ }
struct Rule {}
struct Parent {
	struct Child {
		let foo: Int
	}
}
Triggering Examples
func abc()↓{
}
func abc()
	{ }
[].map(){ $0 }
[].map( { } )
if let a = b{ }
while a == b{ }
guard let a = b else{ }
if
	let a = b,
	let c = d
	where a == c{ }
while
	let a = b,
	let c = d
	where a == c{ }
guard
	let a = b,
	let c = d
	where a == c else{ }
struct Rule↓{}
struct Rule
↓{
}
struct Rule

	↓{
}
struct Parent {
	struct Child
	↓{
		let foo: Int
	}
}

Operator Usage Whitespace

Identifier Enabled by default Supports autocorrection Kind Analyzer Minimum Swift Compiler Version
operator_usage_whitespace Disabled Yes style No 3.0.0

Operators should be surrounded by a single whitespace when they are being used.

Examples

Non Triggering Examples
let foo = 1 + 2
let foo = 1 > 2
let foo = !false
let foo: Int?
let foo: Array<String>
let model = CustomView<Container<Button>, NSAttributedString>()
let foo: [String]
let foo = 1 + 
  2
let range = 1...3
let range = 1 ... 3
let range = 1..<3
#if swift(>=3.0)
    foo()
#endif
array.removeAtIndex(-200)
let name = "image-1"
button.setImage(#imageLiteral(resourceName: "image-1"), for: .normal)
let doubleValue = -9e-11
let foo = GenericType<(UIViewController) -> Void>()
let foo = Foo<Bar<T>, Baz>()
let foo = SignalProducer<Signal<Value, Error>, Error>([ self.signal, next ]).flatten(.concat)
Triggering Examples
let foo = 1↓+2
let foo = 1   + 2
let foo = 1   +    2
let foo = 1 +    2
let foo↓=1↓+2
let foo↓=1 + 2
let foo↓=bar
let range = 1 ..<  3
let foo = bar   ?? 0
let foo = bar↓??0
let foo = bar !=  0
let foo = bar !==  bar2
let v8 = Int8(1)  << 6
let v8 = 1 <<  (6)
let v8 = 1 <<  (6)
 let foo = 1 > 2

Operator Function Whitespace

Identifier Enabled by default Supports autocorrection Kind Analyzer Minimum Swift Compiler Version
operator_whitespace Enabled No style No 3.0.0

Operators should be surrounded by a single whitespace when defining them.

Examples

Non Triggering Examples
func <| (lhs: Int, rhs: Int) -> Int {}
func <|< <A>(lhs: A, rhs: A) -> A {}
func abc(lhs: Int, rhs: Int) -> Int {}
Triggering Examples
func <|(lhs: Int, rhs: Int) -> Int {}
func <|<<A>(lhs: A, rhs: A) -> A {}
func <|  (lhs: Int, rhs: Int) -> Int {}
func <|<  <A>(lhs: A, rhs: A) -> A {}
func  <| (lhs: Int, rhs: Int) -> Int {}
func  <|< <A>(lhs: A, rhs: A) -> A {}

Overridden methods call super

Identifier Enabled by default Supports autocorrection Kind Analyzer Minimum Swift Compiler Version
overridden_super_call Disabled No lint No 3.0.0

Some overridden methods should always call super

Examples

Non Triggering Examples
class VC: UIViewController {
	override func viewWillAppear(_ animated: Bool) {
		super.viewWillAppear(animated)
	}
}
class VC: UIViewController {
	override func viewWillAppear(_ animated: Bool) {
		self.method1()
		super.viewWillAppear(animated)
		self.method2()
	}
}
class VC: UIViewController {
	override func loadView() {
	}
}
class Some {
	func viewWillAppear(_ animated: Bool) {
	}
}
class VC: UIViewController {
	override func viewDidLoad() {
		defer {
			super.viewDidLoad()
		}
	}
}
Triggering Examples
class VC: UIViewController {
	override func viewWillAppear(_ animated: Bool) {
		//Not calling to super
		self.method()
	}
}
class VC: UIViewController {
	override func viewWillAppear(_ animated: Bool) {
		super.viewWillAppear(animated)
		//Other code
		super.viewWillAppear(animated)
	}
}
class VC: UIViewController {
	override func didReceiveMemoryWarning() {
	}
}

Override in Extension

Identifier Enabled by default Supports autocorrection Kind Analyzer Minimum Swift Compiler Version
override_in_extension</