Swiftlint: Function Parenthesis removed because followed by braces

Created on 14 Oct 2020  路  4Comments  路  Source: realm/SwiftLint

New Issue Checklist

Describe the bug

When we write the following code:

private func handleError(error: MyError) {
        switch dispatch(error: error) {
        case .retryMode:
            if startTime + args.retryDuration < .now() {
                completion(Result(error: .other))
            } else {
                oneMoreTime()
            }
        case .failed(let anotherError):
            completion(Result(error: anotherError))
        }
    }

It outputs the following:

private func handleError(error: MyError) {
        switch dispatch(error: error) {
        case .retryMode:
            if startTime + args.retryDuration < .now {
                completion(Result(error: .other))
            } else {
                oneMoreTime()
            }
        case .failed(let anotherError):
            completion(Result(error: anotherError))
        }
    }

Which triggers a compilation error

Complete output when running SwiftLint, including the stack trace and command used
$ swiftlint lint

Can't do this due to company rules

Environment

  • SwiftLint version (run swiftlint version to be sure)?

0.40.3

  • Installation method used (Homebrew, CocoaPods, building from source, etc)?

homebrew

  • Paste your configuration file:

Can't do this due to company rules

# insert yaml contents here
  • Are you using nested configurations?
    If so, paste their relative paths and respective contents.
  • Which Xcode version are you using (check xcodebuild -version)?

11.7

  • Do you have a sample that shows the issue? Run echo "[string here]" | swiftlint lint --no-cache --use-stdin --enable-all-rules
    to quickly test if your example is really demonstrating the issue. If your example is more
    complex, you can use swiftlint lint --path [file here] --no-cache --enable-all-rules.
// This triggers a violation:
let foo = try! bar()
bug

All 4 comments

@mime29 It doesn't clear what is the issue here.
Can you clarify?

@PaulTaykalo DispatchTime.now() gets transformed into DispatchTime.now (line 4, .now() -> .now)

@lordzsolt Are you trying to perform autocorrection?
If so, what is your config?
linting itself shouldn't do any harm

Okay, got it.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Tableau-David-Potter picture Tableau-David-Potter  路  3Comments

castus picture castus  路  3Comments

tomasebrennan picture tomasebrennan  路  3Comments

Den-Ree picture Den-Ree  路  3Comments

mildm8nnered picture mildm8nnered  路  3Comments