Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exclude Function Builder from closure_body_length rule #3143

Open
2 tasks done
417-72KI opened this issue Mar 15, 2020 · 5 comments
Open
2 tasks done

Exclude Function Builder from closure_body_length rule #3143

417-72KI opened this issue Mar 15, 2020 · 5 comments

Comments

@417-72KI
Copy link
Contributor

New Issue Checklist

Describe the bug

Function Builder (since Swift 5.1) is recognized as closure, and often triggers closure_body_length violation.

Function Builder is used in SwiftUI and usually over 20 lines (here is an official sample code), so it should be excluded.

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

Environment

  • SwiftLint version (run swiftlint version to be sure)?
    0.39.1
  • Installation method used (Homebrew, CocoaPods, building from source, etc)?
    Mint
  • Paste your configuration file:
# 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)?
  • 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: closure_body_length
NavigationView {
    Form {
        Picker(selection: $viewModel.form.argument1, label: Text("Argument1")) {
            ForEach(ViewForm.Argument1.allCases, id: \.self) {
                Text($0.name)
            }
        }
        DatePicker(selection: $viewModel.form.argument,
                    in: ...Date(),
                    displayedComponents: [.date, .hourAndMinute]) {
                    Text("Date")
        }
        Picker(selection: $viewModel.form.argument2, label: Text("Argument2")) {
            ForEach(ViewForm.Argument2.allCases, id: \.self) {
                Text($0.label)
            }
        }
        Picker(selection: $viewModel.form.argument3, label: Text("Argument3")) {
            ForEach(ViewForm.Argument3.allCases, id: \.self) {
                Text($0.label)
            }
        }
        Picker(selection: $viewModel.form.argument4, label: Text("Argument4")) {
            ForEach(ViewForm.Argument4.allCases, id: \.self) {
                Text($0.label)
            }
        }
        Picker(selection: $viewModel.form.argument5, label: Text("Argument5")) {
            ForEach(ViewForm.Argument5.allCases, id: \.self) {
                Text($0.label)
            }
        }
        Picker(selection: $viewModel.form.argument6, label: Text("Argument6")) {
            ForEach(ViewForm.Argument6.allCases, id: \.self) {
                Text($0.label)
            }
        }
        Picker(selection: $viewModel.form.argument7, label: Text("Argument7")) {
            ForEach(ViewForm.Argument7.allCases, id: \.self) {
                Text($0.label)
            }
        }
        Toggle(isOn: $viewModel.form.argument8) {
            Text("Argument8")
        }
    }.navigationBarTitle("Title", displayMode: .inline)
        .navigationBarItems(
            trailing: Button(action: { self.submit() },
                                label: { Text("Submit") }))
}
@stale
Copy link

stale bot commented Nov 8, 2020

This issue has been automatically marked as stale because it has not had any recent activity. Please comment to prevent this issue from being closed. Thank you for your contributions!

@stale stale bot added the wontfix label Nov 8, 2020
@417-72KI
Copy link
Contributor Author

I wish it won't be closed

@stale stale bot removed the wontfix label Nov 10, 2020
@stale
Copy link

stale bot commented Jan 9, 2021

This issue has been automatically marked as stale because it has not had any recent activity. Please comment to prevent this issue from being closed. Thank you for your contributions!

@stale stale bot added the wontfix label Jan 9, 2021
@417-72KI
Copy link
Contributor Author

do not close

@stale stale bot removed the wontfix label Jan 12, 2021
@WolframPRO
Copy link

same problem

@jpsim jpsim closed this as completed Feb 24, 2021
@jpsim jpsim reopened this Feb 24, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants