Introduce "Redundant else in if" inspection #KT-19668 Fixed

This commit is contained in:
Mikhail Glukhikh
2018-11-29 15:23:59 +03:00
parent ca87e53f04
commit 7cbc8e8b76
24 changed files with 430 additions and 0 deletions
@@ -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>