Swiftlint: Ability to configure 'opening_brace'

Created on 12 Feb 2016  路  3Comments  路  Source: realm/SwiftLint

I like having my opening braces on their own line:

if codingStyle.isOldSchool
{
    print("I relate to that!")
}
else
{
    print("I respect that!")
}

I'd love to be able to configure the opening_brace rule to enforce this style. I can look into submitting a patch, but wanted to know if this is something already on your radar...

rule-request

Most helpful comment

I don't think we're tracking this anywhere, but making OpeningBraceRule be configurable by mode (maybe newline: true or mode: same_line/mode: new_line) is fine by me! :+1:

All 3 comments

I don't think we're tracking this anywhere, but making OpeningBraceRule be configurable by mode (maybe newline: true or mode: same_line/mode: new_line) is fine by me! :+1:

+1 for configurable openingBraceRule.
I want to write also closures for arrays or no-argument-label functions like this:

let a1 = [
    "a",
    { "b" }()]

let a2 = [
    "a",
    {
        let b = "b"
        return b
    }()]

func f(_ x: String, _ y: () -> String) -> [String] {
    return [x, y()]
}

let a3 = f(
    "a",
    { return "b" })

let a4 = f(
    "a",
    {
        let b = "b"
        return b
    })

Currently, swiftlint autocorrect with this rule changes the above to this (the declaration of f(_: _:) is fine for me):

let a1 = [
    "a", { "b" }()]

let a2 = [
    "a", {
        let b = "b"
        return b
    }()]

func f(_ x: String, _ y: () -> String) -> [String] {
    return [x, y()]
}

let a3 = f(
    "a", { return "b" })

let a4 = f(
    "a", {
        let b = "b"
        return b
    })

Any news about the rule being configurable?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

tomasebrennan picture tomasebrennan  路  3Comments

castus picture castus  路  3Comments

jcarroll-mediafly picture jcarroll-mediafly  路  3Comments

mrtj picture mrtj  路  3Comments

muzamilhassan1987 picture muzamilhassan1987  路  3Comments