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 for unused_enumerated #5881

Open
2 tasks done
carl8382 opened this issue Dec 3, 2024 · 0 comments
Open
2 tasks done

False positive for unused_enumerated #5881

carl8382 opened this issue Dec 3, 2024 · 0 comments
Labels
bug Unexpected and reproducible misbehavior.

Comments

@carl8382
Copy link

carl8382 commented Dec 3, 2024

New Issue Checklist

Bug Description

There's a false positive for the rule unused_enumerated. The offset given from enumerated is used, just apparently not fast enough.

// This triggers a unused_enumerated  violation:
let previousValueComponent = "1234"
let currentValueComponent = "1434"

                // Compare previous and current components and find if there are any indexes where:
                // - two characters are digits
                // - these two digits are different
                //
                let firstIndexWithDifferentDigit = zip(previousValueComponent, currentValueComponent)
                    .enumerated()
                    .first {
                        $0.element.0.isNumber &&
                        $0.element.1.isNumber &&
                        $0.element.0 != $0.element.1
                    }?.offset

                return firstIndexWithDifferentDigit

Mention the command or other SwiftLint integration method that caused the issue. Include stack traces or command output.

$ swiftlint lint [--no-cache] [--fix]

Environment

  • SwiftLint version (run swiftlint version to be sure) 0.57.1
  • Xcode version (run xcodebuild -version to be sure) 16.0
  • Installation method used (Homebrew, CocoaPods, building from source, etc) SPM
  • Configuration file:
# insert yaml contents here

Are you using nested configurations? If so, paste their
relative paths and respective contents.

@SimplyDanny SimplyDanny added the bug Unexpected and reproducible misbehavior. label Dec 3, 2024
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

No branches or pull requests

2 participants