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

yoda_condition false positive for bit field test #4081

Closed
2 tasks done
Bouke opened this issue Aug 10, 2022 · 0 comments · Fixed by #4089
Closed
2 tasks done

yoda_condition false positive for bit field test #4081

Bouke opened this issue Aug 10, 2022 · 0 comments · Fixed by #4089
Assignees
Labels
bug Unexpected and reproducible misbehavior.

Comments

@Bouke
Copy link

Bouke commented Aug 10, 2022

New Issue Checklist

Describe the bug

When testing an integer bit field the yoda_condition rule triggers a false positive.

if flags & 1 == 1 {
    // ...
}

##### Complete output when running SwiftLint, including the stack trace and command used

```bash
$ swiftlint lint
file.swift:2:1: warning: Yoda condition rule Violation: The variable should be placed on the left, the constant on the right of a comparison operator. (yoda_condition)

Environment

  • SwiftLint version (run swiftlint version to be sure)? 0.47.1
  • Installation method used (Homebrew, CocoaPods, building from source, etc)? brew
  • Paste your configuration file: N/A
  • Are you using nested configurations? N/A
  • Which Xcode version are you using (check xcodebuild -version)? N/A
  • Do you have a sample that shows the issue?
> echo "if b & 1 == 1" | swiftlint lint --no-cache --use-stdin --enable-all-rules
<nopath>:1:1: warning: Yoda condition rule Violation: The variable should be placed on the left, the constant on the right of a comparison operator. (yoda_condition)
Done linting! Found 1 violation, 0 serious in 1 file.
@jpsim jpsim added the bug Unexpected and reproducible misbehavior. label Aug 10, 2022
@SimplyDanny SimplyDanny self-assigned this Aug 11, 2022
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.

3 participants