Rule to ban raw loops

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

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

SwiftLint has been tracking a ticket to add a rule that would suggest using higher level algorithms when it detected certain patterns in loops: Rule Request: Loop to filter/map conversion · Issue #871 · realm/SwiftLint · GitHub

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


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