Throwable and Error should not be caught in Kotlin (equivalent of Java rule: squid:S1181)

kotlin

(Jonathan Cornaz) #1

Hi,

The rule squid:S1181 (“Throwable and Error should not be caught”) is true in Kotlin as well.

Please add that rule for Kotlin.

Actually many of the Java rules also apply to Kotlin, because both target the same platform: Java (Yes, Kotlin may target JS, or Native, but Kotlin’s design is made mainly with the Java platform in mind).

It would be nice to review the Java rules, and create a Kotlin equivalent for each of them which also apply to Kotlin.

I think it is quite important, because most of the people introduce Kotlin in existing code-base by converting existing Java classes. Then issues may suddenly disappear in sonar, just because the code has been converted to Kotlin, although the problems are still here.