Option
should only return Some
or None
SC-T1005Methods 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.
.asInstanceOf
SC-T1000The asInstanceOf
method allows you to explicitly convert an object from one type to another. However, this method should be used with caution. Passing in an invalid type parameter may cause the method to produce unreliable results.
isInstanceOf
SC-T1001The instanceOf
method allows you to check if an object belongs to a particular type. However, this method should be used with caution. Passing in an invalid type parameter may cause the method to produce unreliable results, especially if performing a fruitless type test.
Any
SC-T1002Although Scala allows methods with return type Any
, it is suggested that you opt for a different and a better approach. This is because dealing with Any
may require calls to isInstanceOf[T]
and asInstanceOf[T]
and if the type argument T
is erased during compilation, any calls to asInstanceOf[T]
and isInstanceOf[T]
will return unreliable results.