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

reduce_boolean triggers in cases where it shouldn't #4894

Closed
2 tasks done
mr-fixit opened this issue Apr 14, 2023 · 0 comments · Fixed by #4895
Closed
2 tasks done

reduce_boolean triggers in cases where it shouldn't #4894

mr-fixit opened this issue Apr 14, 2023 · 0 comments · Fixed by #4895
Assignees
Labels
bug Unexpected and reproducible misbehavior.

Comments

@mr-fixit
Copy link

New Issue Checklist

Describe the bug

Given

struct SSS {
    func reduce(initial: Bool,
                closure: (Bool, Bool) -> Bool) -> Bool {
        false
    }
}
_ = SSS().reduce(initial: false) { _, _ in true }

the reduce_boolean rule is triggered, and it's suggested I use contains.

Complete output when running SwiftLint, including the stack trace and command used
$ swiftlint lint
[Xcode 14.3's `foo is implemented in bar and baz` lines omitted]
Linting Swift files at paths File.swift
Linting 'File.swift' (1/1)
/Users/eric/File.swift:7:11: warning: Reduce Boolean Violation: Use `contains` instead (reduce_boolean)
Done linting! Found 1 violation, 0 serious in 1 file.

Environment

  • SwiftLint version 0.50.3
  • Installation method used brew
  • No configuration file
  • Which Xcode version are you using: Xcode 14.3 Build version 14E222b
  • Do you have a sample that shows the issue? see above
@SimplyDanny SimplyDanny added the bug Unexpected and reproducible misbehavior. label Apr 14, 2023
@SimplyDanny SimplyDanny self-assigned this Apr 14, 2023
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