My linters always complain when I don't have a default case in pattern matching in Scala. However, often the default case is artificial and my programs can never actually reach that case.
As an example, consider the following program:
scala> val x = 1
x: Int = 1
scala> x match {
| case 1 => println("yay")
| case _ => println("nay")
| }
yay
It is clear that the bottom case is in fact dead code here, however, my linter will still complain about it. On the other hand, I very much understand the gut feeling that matching on integers and not covering all cases feel dangerous, but in this case it's clearly irrational.
Should I simply delete the default case here and suppress the linter warning to get some peace of mind?
edit: Please see https://www.codacy.com/app/hejfelix/Frase/issues?bid=2858415&filters=W3siaWQiOiJDYXRlZ29yeSIsInZhbHVlcyI6WyJFcnJvciBQcm9uZSJdfV0= for a more detailed view on the number of cases where Codacy asks for default cases.