None
instead of Some(null)
SC-A1002It is more idiomatic in scala to use Option
, i.e. Some
and None
instead of null
. Using Some(null)
instead of None
defeats the entire purpose of Option
. However, there might be certain scenarios where this is a legitimate approach, such as when dealing with Java-based libraries, to improve compatibility.
Carefully consider whether using Option
with null
is necessary before doing so.
It is suggested that you do not use wildcards in the import statements. This defeats the entire purpose of properly packing the code into different classes and packages. Rather, import only what you need.
Scala allows you to import entities from same package in separate statements. However, it is generally recommended that you group such imports together. Doing so makes the code more readable and easier to navigate.
final
modifier is redundant for object
SC-R1053A class cannot extend an object thereby making the final
modifier redundant. It is therefore recommended that you drop the said modifier.
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.