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

[bug] toggle_bool false positive #3398

Closed
1 of 2 tasks
rogerluan opened this issue Oct 30, 2020 · 1 comment · Fixed by #3410
Closed
1 of 2 tasks

[bug] toggle_bool false positive #3398

rogerluan opened this issue Oct 30, 2020 · 1 comment · Fixed by #3410
Labels
bug Unexpected and reproducible misbehavior.

Comments

@rogerluan
Copy link
Contributor

rogerluan commented Oct 30, 2020

New Issue Checklist

  • Updated SwiftLint to the latest version - I honestly didn't and I'm on v0.39.2 but I believe this still happens in latest version (can't upgrade to test right now 😿 ) - feel free to close if you're able to test it and it doesn't happen in the latest release 🙏
  • I searched for existing GitHub issues

Describe the bug

toggle_bool false positive.

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.2
  • Installation method used (Homebrew, CocoaPods, building from source, etc)? Homebrew
  • Paste your configuration file:
# The only relevant part is:

opt_in_rules:
  - toggle_bool
  • Are you using nested configurations?
    If so, paste their relative paths and respective contents. 🤔 don't think so
  • Which Xcode version are you using (check xcodebuild -version)? Xcode 12.0
  • 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 shows my issue:

echo "something = \!something.isEmpty ? executeA() : executeB()" | swiftlint lint --no-cache --use-stdin --enable-all-rules

There is a \ before the ! to escape the ! because apparently that causes issues in the script. But the example in Swift would be:

// This triggers a violation:
something = !something.isEmpty ? executeA() : executeB()

And it shouldn't. In my project the line was much more complex but I could simplify and reproduce it using that statement. In my project I just switched the ternary to e.g. something.isEmpty ? executeB() : executeA() but not sure if that will be possible in all cases 🤔

@jpsim jpsim added the bug Unexpected and reproducible misbehavior. label Nov 7, 2020
@jpsim
Copy link
Collaborator

jpsim commented Nov 7, 2020

I can confirm that this is still a false positive present on master.

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