Add inspection for ranges with start > endInclusive #KT-18438 Fixed
This commit is contained in:
committed by
Mikhail Glukhikh
parent
647558c98a
commit
13a2612e20
@@ -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
@@ -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)
|
||||
}
|
||||
Reference in New Issue
Block a user