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.
Exceptions usually follow the AbcDefException nomenclature. Some examples are - NullPointerException, RuntimeException, etc. This allows the person reading/viewing the code understand that the entity being dealt with is an Exception rather than having to rely on the context.
Any Scala method with a single statement in the body maybe refactored to follow the single-line convention. If the statement is more than 30 chars but less than 70, it is suggested that you move it to the next line and indent it with 2 spaces.
This method takes too many parameters - a potential code smell/styling issue which affects the overall readability of the code. Consider using default parameter values/currying.
Parameterless methods usually return a value and are part of the language. Having such methods have a return type of Unit can affect/hinder readability and defeats the purpose for which it was introduced as part of the syntax/language.
!nonEmpty
with isEmpty
SC-R1018Standard Scala structures provide with both isEmpty
and nonEmpty
methods. Replacing !nonEmpty
with isEmpty
makes the code slightly more readable and easier to comprehend.
Empty blocks do not add anything of value to the codebase. We believe that this is either a copy-paste error or that the programmer forgot to add the relevant statements.
Option[T]
should have their names suffixed with Option
SC-C1005Option[T]
is heavily used within the Scala language due to its obvious advantages.
It is not uncommon to find 2 versions of the same method that differ just in the return types — T
and Option[T]
respectively.
Some such examples are reduce
, reduceOption
, min
, minOption
, and so on.
It is therefore recommended that you follow the same styling convention — suffixing the method name with Option
for the additional implementation
of your method that simply differs in the return type, i.e. returns Option[T]
.