SwiftLint icon indicating copy to clipboard operation
SwiftLint copied to clipboard

False positive in closure_end_indentation

Open marcelofabri opened this issue 4 years ago • 2 comments

New Issue Checklist

Describe the bug

A clear and concise description of what the bug is.

Complete output when running SwiftLint, including the stack trace and command used
$ swiftlint lint
/Users/marcelofabri/SwiftLint/file.swift:10:1: warning: Closure End Indentation Violation: Closure end should have the same indentation as the line that started it. Expected 16, got 0. (closure_end_indentation)
Done linting! Found 1 violation, 0 serious in 1 file.

Environment

  • SwiftLint version (run swiftlint version to be sure)? 0.43.1
  • Installation method used (Homebrew, CocoaPods, building from source, etc)? Homebrew
  • Paste your configuration file:
opt_in_rules:
  - closure_end_indentation

No

  • Which Xcode version are you using (check xcodebuild -version)?

12.5.1

  • 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.
Observable.combineLatest(
    mapSectionProviders(context: context)
        .map { provider -> Observable<HomeSection> in
            provider.fetch(context: context)
                .startWith(.empty)
                .catchAndReturn(.empty)
        }
).map { sections in
    sections.filter { !$0.items.isEmpty }
}

marcelofabri avatar Aug 30 '21 05:08 marcelofabri

I have the same issue:

Example

file.swift
Section(header: Text("dinner")
        .font(.system(size: 17, weight: .semibold)),
        footer: SomeView(
          error: "",
          isTimeValid: true)) {
            DatePicker("Start", selection: Date() displayedComponents: .hourAndMinute)
              DatePicker("End" selection: Date() displayedComponents: .hourAndMinute)
} <-- no error if it is here
          } <-- error if it is here, but it should be here

The swiftlint moves the latest brace to the start of the Section line, not to the start of isTimeValid line

iSevenDays avatar Nov 04 '21 14:11 iSevenDays

I am also seeing this issue currently.

Example
    .execute { response in
        switch response {
        case let .success(value):
            /* do work */
        case let .failure(error):
            /* report error */
        }
    }      <=== Error here, correct location as per ctrl+i
} <=== no error here.

RobertHaworth avatar Apr 21 '22 13:04 RobertHaworth