Modified IfThenToElvis to not apply when using '!!' would be better
This commit is contained in:
committed by
Zalim Bashorov
parent
9f63f7c488
commit
e5054a4a54
@@ -79,4 +79,12 @@
|
||||
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">If-Then foldable to '?:'.</problem_class>
|
||||
<description>Replace 'if' expression with elvis expression</description>
|
||||
</problem>
|
||||
<problem>
|
||||
<file>throwsNPEwithArgument.kt</file>
|
||||
<line>4</line>
|
||||
<module>light_idea_test_case</module>
|
||||
<entry_point TYPE="file" FQNAME="temp:///src/src/throwsNPEwithArgument.kt" />
|
||||
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">If-Then foldable to '?:'</problem_class>
|
||||
<description>Replace 'if' expression with elvis expression</description>
|
||||
</problem>
|
||||
</problems>
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
// IS_APPLICABLE: false
|
||||
// WITH_RUNTIME
|
||||
fun main(args: Array<String>) {
|
||||
val t: String? = "abc"
|
||||
if (t != null<caret>) t else throw KotlinNullPointerException()
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
// IS_APPLICABLE: false
|
||||
// WITH_RUNTIME
|
||||
fun main(args: Array<String>) {
|
||||
val t: String? = "abc"
|
||||
if (t == null<caret>) throw NullPointerException() else t
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
// WITH_RUNTIME
|
||||
fun main(args: Array<String>) {
|
||||
val t: String? = "abc"
|
||||
if (t != null<caret>) t else throw NullPointerException("'t' must not be null")
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
// WITH_RUNTIME
|
||||
fun main(args: Array<String>) {
|
||||
"abc" ?: throw NullPointerException("'t' must not be null")
|
||||
}
|
||||
Reference in New Issue
Block a user