Exceptions Rule Set
Rules in this rule set report issues related to how code throws and handles Exceptions.
ExceptionRaisedInUnexpectedLocation
This rule reports functions which should never throw an exception. If a function exists that does throw
an exception it will be reported. By default, this rule checks toString, hashCode, equals and
finalize. This rule is configurable via the methodNames configuration to change the list of functions which
should not throw any exceptions.
Active by default: Yes - Since v1.16.0
Debt: 20min
Configuration options:
-
methodNames(default:['equals', 'finalize', 'hashCode', 'toString'])methods which should not throw exceptions
Noncompliant Code:
class Foo {
override fun toString(): String {
throw IllegalStateException() // exception should not be thrown here
}
}