Reports redundant return keywords in expressions that appear as the last expression of an if
or when branch when the entire if/when expression is itself returned.
These keywords add no value and only clutter the code.
The quick-fix removes the redundant return keyword, leaving only the expression.
Example:
fun foo(flag: Boolean): String {
return if (flag) {
"foo"
} else {
return "bar" // redundant 'return' keyword
}
}
After the quick-fix is applied:
fun foo(flag: Boolean): String {
return if (flag) {
"foo"
} else {
"bar"
}
}
New in 2025.3