Pattern: Use of unsafe cast
Issue: -
Reports casts which are unsafe. In case the cast is not possible it will throw an exception.
Example of incorrect code:
fun foo(s: Any) {
println(s as Int)
}
Example of correct code:
fun foo(s: Any) {
println((s as? Int) ?: 0)
}