I have a Scala method for which SonarLint (IntelliJ plugin version 3.2.1.2406) is flagging the return statement as 'Unreachable code'. For the purposes of this example I've removed the actual logic and replaced with printlns, but it produces the same issue. Note that debugging this shows that the return statement is in fact reachable.
def someMethod(): String = {
try {
println("Do something here")
} finally {
try {
println("Do something else")
} catch {
case e: Exception => {
println("Exception: " + e.getMessage)
}
}
}
return "Finished" // Sonarlint 'Unreachable code'
}
Additionally, removing the catch block results in the unreachable code issue disappearing.
Is this a bug in SonarLint? or am I missing something