realm / SwiftLint

A tool to enforce Swift style and conventions.
https://realm.github.io/SwiftLint
MIT License
18.49k stars 2.2k forks source link

Swift type checking using is #5295

Open inotetw opened 8 months ago

inotetw commented 8 months ago

New rule request

type ching using is

Bad

if  a as? Dog  != nil { 
   doSomeThing()
}

Good

if  a is Dog  { 
   doSomeThing()
}

if  let dog = dog as? Dog  { 
   dog.run()
}

type checking using "is" is more easy to understand then type casting and check nil

AballahNsour commented 2 months ago

I will take this one

SimplyDanny commented 2 months ago

I will take this one

There has been some work in https://github.com/realm/SwiftLint/pull/5561 already.