Skip to content

reduce_boolean triggers in cases where it shouldn't #4894

@mr-fixit

Description

@mr-fixit

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

Metadata

Metadata

Assignees

Labels

bugUnexpected and reproducible misbehavior.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions