Vertical Parameter Alignment

Function parameters should be aligned vertically if they’re in multiple lines in a declaration

  • Identifier: vertical_parameter_alignment
  • Enabled by default: Yes
  • Supports autocorrection: No
  • Kind: style
  • Analyzer rule: No
  • Minimum Swift compiler version: 5.0.0
  • Default configuration:
    KeyValue
    severity warning

Non Triggering Examples

func validateFunction(_ file: SwiftLintFile, kind: SwiftDeclarationKind,
                      dictionary: SourceKittenDictionary) { }
func validateFunction(_ file: SwiftLintFile, kind: SwiftDeclarationKind,
                      dictionary: SourceKittenDictionary) -> [StyleViolation]
func foo(bar: Int)
func foo(bar: Int) -> String
func validateFunction(_ file: SwiftLintFile, kind: SwiftDeclarationKind,
                      dictionary: SourceKittenDictionary)
                      -> [StyleViolation]
func validateFunction(
   _ file: SwiftLintFile, kind: SwiftDeclarationKind,
   dictionary: SourceKittenDictionary) -> [StyleViolation]
func validateFunction(
   _ file: SwiftLintFile, kind: SwiftDeclarationKind,
   dictionary: SourceKittenDictionary
) -> [StyleViolation]
func regex(_ pattern: String,
           options: NSRegularExpression.Options = [.anchorsMatchLines,
                                                   .dotMatchesLineSeparators]) -> NSRegularExpression
func foo(a: Void,
         b: [String: String] =
         [:]) {
}
func foo(data: (size: CGSize,
                identifier: String)) {}
func foo(data: Data,
         @ViewBuilder content: @escaping (Data.Element.IdentifiedValue) -> Content) {}
class A {
    init(bar: Int)
}
class A {
    init(foo: Int,
         bar: String)
}

Triggering Examples

func validateFunction(_ file: SwiftLintFile, kind: SwiftDeclarationKind,
                  dictionary: SourceKittenDictionary) { }
func validateFunction(_ file: SwiftLintFile, kind: SwiftDeclarationKind,
                       dictionary: SourceKittenDictionary) { }
func validateFunction(_ file: SwiftLintFile,
                  kind: SwiftDeclarationKind,
                  dictionary: SourceKittenDictionary) { }
func foo(data: Data,
            @ViewBuilder content: @escaping (Data.Element.IdentifiedValue) -> Content) {}
class A {
    init(data: Data,
                @ViewBuilder content: @escaping (Data.Element.IdentifiedValue) -> Content) {}
}