Scala

Scala

Made by DeepSource

Method variant that return Option[T] should have their names suffixed with Option SC-C1005

Style
Minor

Option[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].

Bad Practice

def min(implicit ord: Ordering[T]): T = {
  // ...
}

def minOpt(implicit ord: Ordering[T]): Option[T] = {
  // same implementation as of `min`
}

Recommended

def min(implicit ord: Ordering[T]): T = {
  // ...
}

def minOption(implicit ord: Ordering[T]): Option[T] = {
  // same implementation as of `min`
}