Scala

Scala

Made by DeepSource

Methods returning Option should only return Some or None SC-T1005

Type check
Major

Methods with return type Option should either return Some if a suitable value exists or None if not. Returning null from such methods can have unintended side effects.

Bad practice

val elements = List(1, 2, 3, 4, 5)
val lastElement = elements.lastOption     // Some(5)

Recommended

val elements = List()
val lastElement = elements.lastOption     // None