Migration inspection for fromClosedRange() call (KT-17176)
#KT-17176 Open
This commit is contained in:
+22
@@ -0,0 +1,22 @@
|
||||
<problems>
|
||||
<problem>
|
||||
<file>test.kt</file>
|
||||
<line>6</line>
|
||||
<description>It's prohibited to call IntProgression.fromClosedRange() with MIN_VALUE step since 1.3</description>
|
||||
</problem>
|
||||
<problem>
|
||||
<file>test.kt</file>
|
||||
<line>7</line>
|
||||
<description>It's prohibited to call IntProgression.fromClosedRange() with MIN_VALUE step since 1.3</description>
|
||||
</problem>
|
||||
<problem>
|
||||
<file>test.kt</file>
|
||||
<line>14</line>
|
||||
<description>It's prohibited to call LongProgression.fromClosedRange() with MIN_VALUE step since 1.3</description>
|
||||
</problem>
|
||||
<problem>
|
||||
<file>test.kt</file>
|
||||
<line>15</line>
|
||||
<description>It's prohibited to call LongProgression.fromClosedRange() with MIN_VALUE step since 1.3</description>
|
||||
</problem>
|
||||
</problems>
|
||||
+1
@@ -0,0 +1 @@
|
||||
// INSPECTION_CLASS: org.jetbrains.kotlin.idea.inspections.migration.FromClosedRangeMigrationInspection
|
||||
@@ -0,0 +1,22 @@
|
||||
package fromClosedRange
|
||||
|
||||
import kotlin.ranges.IntProgression.Companion.fromClosedRange
|
||||
|
||||
fun testInt(rangeStart: Int, rangeEnd: Int, step: Int) {
|
||||
fromClosedRange(12, 143, step) // report
|
||||
fromClosedRange(12, 143, Int.MIN_VALUE) // report
|
||||
|
||||
fromClosedRange(step = 12, rangeEnd = rangeEnd, rangeStart = rangeStart) // do not report
|
||||
fromClosedRange(12, 143, 2) // do not report
|
||||
}
|
||||
|
||||
fun testLong(rangeStart: Long, rangeEnd: Long, step: Long) {
|
||||
LongProgression.fromClosedRange(12, 143, step) // report
|
||||
LongProgression.fromClosedRange(12, 143, Long.MIN_VALUE) // report
|
||||
|
||||
LongProgression.fromClosedRange(12, 143, 2.toLong()) // do no report
|
||||
LongProgression.fromClosedRange(step = 12, rangeEnd = rangeEnd, rangeStart = rangeStart) // do not report
|
||||
LongProgression.fromClosedRange(12, 143, 2) // do not report
|
||||
LongProgression.fromClosedRange(12, 143, 2L) // do not report
|
||||
LongProgression.fromClosedRange(12, 143, Int.MIN_VALUE) // do not report
|
||||
}
|
||||
Reference in New Issue
Block a user