unneeded_parentheses_in_closure_argument - ApplebaumIan/BitbucketAPI GitHub Wiki

Unneeded Parentheses in Closure Argument

Parentheses are not needed when declaring closure arguments.

  • Identifier: unneeded_parentheses_in_closure_argument
  • Enabled by default: Disabled
  • Supports autocorrection: Yes
  • Kind: style
  • Analyzer rule: No
  • Minimum Swift compiler version: 3.0.0
  • Default configuration: warning

Non Triggering Examples

let foo = { (bar: Int) in }

let foo = { bar, _  in }

let foo = { bar in }

let foo = { bar -> Bool in return true }

Triggering Examples

call(arg: { ↓(bar) in })

call(arg: { ↓(bar, _) in })

let foo = { ↓(bar) -> Bool in return true }

foo.map { ($0, $0) }.forEach { ↓(x, y) in }
foo.bar { [weak self] ↓(x, y) in }
[].first { ↓(temp) in
    [].first { ↓(temp) in
        [].first { ↓(temp) in
            _ = temp
            return false
        }
        return false
    }
    return false
}
[].first { temp in
    [].first { ↓(temp) in
        [].first { ↓(temp) in
            _ = temp
            return false
        }
        return false
    }
    return false
}