I hava a project on github that is analysed by codacy . The analysis suggest to \"Avoid using null\" for the following line of code:
def doS
There's no need to explicitly check for null or wrap path in an Option.
You can do this:
path match {
case p: String => Option(doSomethingWith(p))
case _ => None //if path is null this will be returned
}
That will return an Option, which may not be what you want, but in that case instead of producing a None, raise an exception. require will raise an exception in your example anyway so if that's what your caller expects just do it explicitly.