Introduce "Redundant else in if" inspection #KT-19668 Fixed
This commit is contained in:
@@ -3145,6 +3145,15 @@
|
||||
language="kotlin"
|
||||
/>
|
||||
|
||||
<localInspection implementationClass="org.jetbrains.kotlin.idea.inspections.RedundantElseInIfInspection"
|
||||
displayName="Redundant 'else' in 'if'"
|
||||
groupPath="Kotlin"
|
||||
groupName="Style issues"
|
||||
enabledByDefault="true"
|
||||
level="INFORMATION"
|
||||
language="kotlin"
|
||||
/>
|
||||
|
||||
<referenceImporter implementation="org.jetbrains.kotlin.idea.quickfix.KotlinReferenceImporter"/>
|
||||
|
||||
<fileType.fileViewProviderFactory filetype="KJSM" implementationClass="com.intellij.psi.ClassFileViewProviderFactory"/>
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
<html>
|
||||
<body>
|
||||
This inspection reports redundant <b>else</b> in <b>if</b> with <b>return</b>:
|
||||
|
||||
<pre>
|
||||
fun foo(arg: Boolean): Int {
|
||||
if (arg) return 0
|
||||
// This else is redundant, code in braces could be just shifted left
|
||||
else {
|
||||
...
|
||||
}
|
||||
}
|
||||
</pre>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user