Rule to ban raw loops

(Adrian Zubarev) #1

I just watched this very awesome WWDC session and thought maybe we need actually a similar rule in SwiftLint. The opt-in rule would basically forbid any possible raw loops and force some codebases to use more generic algorithms from the stdlib. Thoughts?

1 Like
(Rod Brown) #2

I like the idea, though I wouldn’t use it. I tend to be conservative on linter rules against “discouraged” language features.

I’d certainly be for it if it were opt-in, just not opt-out.

1 Like
(JP Simard) #3

SwiftLint has been tracking a ticket to add a rule that would suggest using higher level algorithms when it detected certain patterns in loops: https://github.com/realm/SwiftLint/issues/871

It'd be trivial to build a very basic version of this, and expand over time with more complex cases.

2 Likes
(Adrian Zubarev) #4

Cool, I'd use it, but it definitely must be opt-in by default. :slight_smile: