Add inspection to replace not-null assertion with elvis return
#KT-30381 Fixed
This commit is contained in:
committed by
Dmitry Gridin
parent
1c0c01725b
commit
dffcfdc02f
@@ -3355,6 +3355,15 @@
|
||||
language="kotlin"
|
||||
/>
|
||||
|
||||
<localInspection implementationClass="org.jetbrains.kotlin.idea.inspections.ReplaceNotNullAssertionWithElvisReturnInspection"
|
||||
displayName="Replace '!!' with '?: return'"
|
||||
groupPath="Kotlin"
|
||||
groupName="Style issues"
|
||||
enabledByDefault="false"
|
||||
level="WEAK WARNING"
|
||||
language="kotlin"
|
||||
/>
|
||||
|
||||
<referenceImporter implementation="org.jetbrains.kotlin.idea.quickfix.KotlinReferenceImporter"/>
|
||||
|
||||
<fileType.fileViewProviderFactory filetype="KJSM" implementationClass="com.intellij.psi.ClassFileViewProviderFactory"/>
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
<html>
|
||||
<body>
|
||||
This inspection reports not-null assertion (<b>!!</b>) calls that can be replaced with elvis and return (<b>?: return</b>). For example:
|
||||
<br /><br />
|
||||
<pre>
|
||||
val number: Int? = 42
|
||||
fun foo() {
|
||||
val a = number!! // Replace '!!' with '?: return'
|
||||
println(1 + a)
|
||||
}
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user