Add inspection for ranges with start > endInclusive #KT-18438 Fixed

This commit is contained in:
Kirill Rakhman
2017-06-14 00:10:21 +03:00
committed by Mikhail Glukhikh
parent 647558c98a
commit 13a2612e20
13 changed files with 261 additions and 33 deletions
@@ -0,0 +1,56 @@
<problems>
<problem>
<file>test.kt</file>
<line>5</line>
<module>light_idea_test_case</module>
<entry_point TYPE="file" FQNAME="temp:///src/test.kt"/>
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Range with start greater than endInclusive is empty
</problem_class>
<description>This range is empty. Did you mean to use 'downTo'?</description>
</problem>
<problem>
<file>test.kt</file>
<line>6</line>
<module>light_idea_test_case</module>
<entry_point TYPE="file" FQNAME="temp:///src/test.kt"/>
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Range with start greater than endInclusive is empty
</problem_class>
<description>This range is empty. Did you mean to use 'downTo'?</description>
</problem>
<problem>
<file>test.kt</file>
<line>7</line>
<module>light_idea_test_case</module>
<entry_point TYPE="file" FQNAME="temp:///src/test.kt"/>
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Range with start greater than endInclusive is empty
</problem_class>
<description>This range is empty. Did you mean to use 'downTo'?</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="WARNING_ATTRIBUTES">Range with start greater than endInclusive is empty
</problem_class>
<description>This range is empty. Did you mean to use 'downTo'?</description>
</problem>
<problem>
<file>test.kt</file>
<line>9</line>
<module>light_idea_test_case</module>
<entry_point TYPE="file" FQNAME="temp:///src/test.kt"/>
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Range with start greater than endInclusive is empty
</problem_class>
<description>This range is empty. Did you mean to use 'downTo'?</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">Range with start greater than endInclusive is empty
</problem_class>
<description>This range is empty. Did you mean to use 'downTo'?</description>
</problem>
</problems>
@@ -0,0 +1 @@
// INSPECTION_CLASS: org.jetbrains.kotlin.idea.inspections.EmptyRangeInspection
+17
View File
@@ -0,0 +1,17 @@
// WITH_RUNTIME
const val ONE = 1
fun foo() {
2..1
2.rangeTo(1)
2..1L
10L..-10L
5..ONE
10.toShort()..1.toShort()
//valid
1..1
1..10L
1..2
1.rangeTo(2)
}