You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
SwiftLint's 'Multiple Closures With Trailing Closure' rule flags the use of Swift 5.3's new multiple trailing closure syntax (SE-209) on the last closure.
Example:
Button{print("Button tapped")} label:{// Multiple Closures with Trailing Closure ViolationText("Button")}
Proposed Fix/Behavior
The new syntax serves to alleviate the call site confusion that initially motivated creating the rule. Thus, the rule implementation could be adjust to detect multiple closures with trailing closure(s) -- flag when a non-trailing closure is used as an argument that has either a single trailing closure or multiple trailing closures.
This would mean this would get flagged:
Button(action:{print("Button tapped")}){// Multiple Closures with Trailing Closure ViolationText("Button")}
Complete output when running SwiftLint, including the stack trace and command used
$ echo"Button { print(\"Button tapped\")} label: { Text(\"Button\")}"| swiftlint lint --no-cache --use-stdin --enable-all-rules
Loading configuration from '.swiftlint.yml'<nopath>:3:3: warning: Multiple Closures with Trailing Closure Violation: Trailing closure syntax should not be used when passing more than one closure argument. (multiple_closures_with_trailing_closure)
Done linting! Found 1 violation, 0 serious in 1 file.
Environment
SwiftLint version: 0.40.0
Installation method used (Homebrew, CocoaPods, building from source, etc): Homebrew
Paste your configuration file:
Empty file. Relevant rule: multiple_closures_with_trailing_closure.
Which Xcode version are you using (check xcodebuild -version)?
Xcode 12.0 Beta 4 (12A8179i)
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.
New Issue Checklist
Describe the bug
SwiftLint's 'Multiple Closures With Trailing Closure' rule flags the use of Swift 5.3's new multiple trailing closure syntax (SE-209) on the last closure.
Example:
Proposed Fix/Behavior
The new syntax serves to alleviate the call site confusion that initially motivated creating the rule. Thus, the rule implementation could be adjust to detect multiple closures with trailing closure(s) -- flag when a non-trailing closure is used as an argument that has either a single trailing closure or multiple trailing closures.
This would mean this would get flagged:
But this would not:
And this would not:
Complete output when running SwiftLint, including the stack trace and command used
Environment
Empty file. Relevant rule:
multiple_closures_with_trailing_closure
.No.
xcodebuild -version
)?Xcode 12.0 Beta 4 (12A8179i)
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
.The text was updated successfully, but these errors were encountered: