SwiftLint
SwiftLint copied to clipboard
False positive in closure_end_indentation
New Issue Checklist
- [x] Updated SwiftLint to the latest version
- [x] I searched for existing GitHub issues
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 versionto 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
- Are you using nested configurations? If so, paste their relative paths and respective contents.
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-rulesto quickly test if your example is really demonstrating the issue. If your example is more complex, you can useswiftlint 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 }
}
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
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.