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

False positive with unneeded_break_in_switch while in a loop #3724

Closed
nicolasgoutaland opened this issue Sep 28, 2021 · 0 comments · Fixed by #3725
Closed

False positive with unneeded_break_in_switch while in a loop #3724

nicolasgoutaland opened this issue Sep 28, 2021 · 0 comments · Fixed by #3725
Labels
bug Unexpected and reproducible misbehavior.

Comments

@nicolasgoutaland
Copy link

New Issue Checklist

Describe the bug

The unneeded_break_in_switch is triggering false positive in some cases.

Complete output when running SwiftLint, including the stack trace and command used
AppMigration.swift:133:25: warning: Unneeded Break in Switch Violation: Avoid using unneeded break statements. (unneeded_break_in_switch)```

### Environment

* SwiftLint version (0.44.0)
* Installation method used (CocoaPods)
* Paste your configuration file:

```yml
Using default configuration
  • Are you using nested configurations? No
  • Which Xcode version are you using (check xcodebuild -version)? 12.5.1, but same issue with latest Xcode version (13)
  • 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:
            let items = [Int]()
            for item in items {
                if bar() {
                    do {
                        try foo()
                    } catch {
                        bar()
                        break
                    }
                }
            }
// This doesn't triggers a violation:
            let items = [Int]()
            for item in items {
                if bar() {
                    do {
                        try foo()
                    } catch {
//                        bar()
                        break
                    }
                }
            }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Unexpected and reproducible misbehavior.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants