Use "if-then to" even for 'if (arg != null) arg' removing 'if'

This commit is contained in:
Mikhail Glukhikh
2017-05-11 19:59:51 +03:00
parent 977d8e1cd7
commit 326d850760
4 changed files with 18 additions and 4 deletions
@@ -135,4 +135,12 @@
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">If-Then foldable to '?.'</problem_class>
<description>Replace 'if' expression with safe cast expression</description>
</problem>
<problem>
<file>nullCheckSimple.kt</file>
<line>2</line>
<module>light_idea_test_case</module>
<entry_point TYPE="file" FQNAME="temp:///src/nullCheckSimple.kt" />
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">If-Then foldable to '?.'</problem_class>
<description>Remove redundant 'if' expression</description>
</problem>
</problems>
@@ -1,5 +1,3 @@
// IS_APPLICABLE: false
fun foo(arg: Any?): Any? {
return if (<caret>arg != null) arg else null
}
@@ -0,0 +1,3 @@
fun foo(arg: Any?): Any? {
return arg
}