Swiftlint: empty_parentheses_with_trailing_closure false positive

Created on 11 Jan 2017  路  2Comments  路  Source: realm/SwiftLint

We have a class with a init function that take a closure as parameter

class Promise {
    public init(_ f: (something) -> Void))
}

when I call it

Promise() { 
    // doing something here
}

the rule empty_parentheses_with_trailing_closure will give a warning even if the call is totally ok.

question

Most helpful comment

Actually, the rule enforces exactly this. You should use:

Promise { _ in
    print("foo")
}

(Or disable the rule if you don't agree with this style)

All 2 comments

Actually, the rule enforces exactly this. You should use:

Promise { _ in
    print("foo")
}

(Or disable the rule if you don't agree with this style)

ok, thank you.

Was this page helpful?
0 / 5 - 0 ratings