Swiftlint warning : For Where Violation: `where` clauses are preferred over a single `if` inside a `for`. (for_where)

Viewed 17860

I am using swift for my application development and using Swift lint. But I am getting a warning regarding the following code:

for settingsKeys in searchResults {

        if  settingsKeys.key == settingsObject.key {
          settingsKeys.value = settingsObject.value
          try context.save()
        }
      }

The screenshot is attached hereby:

enter image description here

No automatic fix option is available, so how do I eliminate this warning?

2 Answers
Related