Multiline Parameters
Functions and methods parameters should be either on the same line, or one per line
- Identifier:
multiline_parameters
- Enabled by default: No
- Supports autocorrection: No
- Kind: style
- Analyzer rule: No
- Minimum Swift compiler version: 5.0.0
- Default configuration:
Key Value severity warning allows_single_line true
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 }) { }
}
class Foo {
init(param1: Int,
param2: Bool,
param3: @escaping ((Int) -> Void)? = { _ in }) { }
}
//
// allows_single_line: false
//
func foo() { }
//
// allows_single_line: false
//
func foo(param1: Int) { }
//
// allows_single_line: false
//
protocol Foo {
func foo(param1: Int,
param2: Bool,
param3: [String]) { }
}
//
// allows_single_line: false
//
protocol Foo {
func foo(
param1: Int
) { }
}
//
// allows_single_line: false
//
protocol Foo {
func foo(
param1: Int,
param2: Bool,
param3: [String]
) { }
}
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 }) { }
}
class Foo {
↓init(param1: Int, param2: Bool,
param3: @escaping ((Int) -> Void)? = { _ in }) { }
}
//
// allows_single_line: false
//
func ↓foo(param1: Int, param2: Bool) { }
//
// allows_single_line: false
//
func ↓foo(param1: Int, param2: Bool, param3: [String]) { }