-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Closed
Description
New Issue Checklist
- [ x ] I've Updated SwiftLint to the latest version.
- [ x ] I've searched for existing GitHub issues.
Bug Description
The rule redundant_discardable_let is falsely triggered inside SwiftUI @ViewBuilder implementation, although the option ignore_swiftui_view_bodies is set to true.
Using the --fix option for this violation will remove the let, and previews won't compile. The option is working properly inside SwiftUI var body: some View declarations.
// This triggers a violation:
@ViewBuilder
func viewBuilder() -> some View {
let _ = "Test Builder"
EmptyView()
}Removing the let will break the View conformance. Adding explicit return to EmptyView will break the result builder ViewBuilder.
$ swiftlint --strict --progress
TestFile.swift:60:9: error: Redundant Discardable Let Violation: Prefer `_ = foo()` over `let _ = foo()` when discarding a result from a function (redundant_discardable_let)Environment
- SwiftLint version: 0.59.1
- Xcode version: Xcode 16.2, Build version 16C5032a
- Installation via Homebrew
- Configuration file:
# Default rule configuration
redundant_discardable_let:
ignore_swiftui_view_bodies: trueNo nested configurations.
Imho the exception for var body: some View should also apply to @ViewBuilder implementations since they follow the same rules as the var body: some View declarations.
Metadata
Metadata
Assignees
Labels
No labels