Inspection detecting redundant Unit return type (#1144)

This commit is contained in:
nd
2017-07-07 16:51:53 +02:00
committed by Dmitry Jemerov
parent 5f9a33564a
commit 33a93e5fc5
13 changed files with 147 additions and 30 deletions
@@ -0,0 +1,10 @@
fun foo(): Unit {
}
fun bar(): Unit {
return Unit
}
fun baz(): Unit = println("ok")
fun f1(): Int = 1
@@ -0,0 +1,26 @@
<problems>
<problem>
<file>Test.kt</file>
<line>1</line>
<module>light_idea_test_case</module>
<entry_point TYPE="file" FQNAME="temp:///src/Test.kt" />
<problem_class severity="WARNING" attribute_key="NOT_USED_ELEMENT_ATTRIBUTES">Redundant 'Unit' return type</problem_class>
<description>Redundant Unit return type</description>
</problem>
<problem>
<file>Test.kt</file>
<line>4</line>
<module>light_idea_test_case</module>
<entry_point TYPE="file" FQNAME="temp:///src/Test.kt" />
<problem_class severity="WARNING" attribute_key="NOT_USED_ELEMENT_ATTRIBUTES">Redundant 'Unit' return type</problem_class>
<description>Redundant Unit return type</description>
</problem>
<problem>
<file>Test.kt</file>
<line>8</line>
<module>light_idea_test_case</module>
<entry_point TYPE="file" FQNAME="temp:///src/Test.kt" />
<problem_class severity="WARNING" attribute_key="NOT_USED_ELEMENT_ATTRIBUTES">Redundant 'Unit' return type</problem_class>
<description>Redundant Unit return type</description>
</problem>
</problems>
@@ -0,0 +1 @@
// INSPECTION_CLASS: org.jetbrains.kotlin.idea.intentions.RedundantUnitReturnTypeInspection
@@ -4,15 +4,15 @@
<line>4</line>
<module>light_idea_test_case</module>
<entry_point TYPE="file" FQNAME="temp:///src/test.kt" />
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Redundant setter parameter type</problem_class>
<description>Remove explicit type specification</description>
<problem_class severity="WARNING" attribute_key="NOT_USED_ELEMENT_ATTRIBUTES">Redundant setter parameter type</problem_class>
<description>Redundant setter parameter type</description>
</problem>
<problem>
<file>test.kt</file>
<line>10</line>
<module>light_idea_test_case</module>
<entry_point TYPE="file" FQNAME="temp:///src/test.kt" />
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Redundant setter parameter type</problem_class>
<description>Remove explicit type specification</description>
<problem_class severity="WARNING" attribute_key="NOT_USED_ELEMENT_ATTRIBUTES">Redundant setter parameter type</problem_class>
<description>Redundant setter parameter type</description>
</problem>
</problems>