You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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:
letpreviousValueComponent="1234"letcurrentValueComponent="1434"
// Compare previous and current components and find if there are any indexes where:
// - two characters are digits
// - these two digits are different
//
letfirstIndexWithDifferentDigit=zip(previousValueComponent,currentValueComponent).enumerated().first{$0.element.0.isNumber&&$0.element.1.isNumber&&$0.element.0!=$0.element.1}?.offsetreturn 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.
Reacted by Marco Piovanelli, Anton and Ross Goldberg
Opened #6544 for this. The fix carries result-member usage from the surrounding higher-order call back into the check, so cases like stop getting flagged while the existing real violations still trigger.
Opened #6544 for this. The fix carries result-member usage from the surrounding higher-order call back into the rule, so cases like .max { ... }?.offset stop getting flagged while the existing real violations still trigger.
Activity
ortekka commentedon Jan 30, 2025
For reference, here's an even simpler code snippet that triggers a false positive:
Just because
offsetisn't used in the closure doesn't mean that.enumerated()can be removed, as the warning message incorrectly suggests.rgoldberg commentedon Oct 20, 2025
Is this scheduled to be fixed? Thanks.
SimplyDanny commentedon Oct 22, 2025
Well, we don't schedule topics. Whoever wants to, may work on it.
theamodhshetty commentedon Mar 17, 2026
Opened #6544 for this. The fix carries result-member usage from the surrounding higher-order call back into the check, so cases like stop getting flagged while the existing real violations still trigger.
theamodhshetty commentedon Mar 17, 2026
Opened #6544 for this. The fix carries result-member usage from the surrounding higher-order call back into the rule, so cases like
.max { ... }?.offsetstop getting flagged while the existing real violations still trigger.