Skip to content

Commit

Permalink
[Bugfix] int to Int migration (#2767)
Browse files Browse the repository at this point in the history
Replaced occurrences of `int` with `Int` in Kotlin code snippets to align with Kotlin's type system, which uses non-primitive types. The previous examples contained errors due to the use of `int`, which does not exist in Kotlin. This change ensures the code is syntactically correct and consistent with Kotlin's type conventions.
  • Loading branch information
GrzegorzBobryk authored Aug 13, 2024
1 parent 2b7a885 commit ba68576
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 18 deletions.
4 changes: 2 additions & 2 deletions documentation/release-latest/docs/rules/standard.md
Original file line number Diff line number Diff line change
Expand Up @@ -1041,7 +1041,7 @@ If at least one branch of an if-else statement or an if-else-if statement is wra
=== "[:material-heart:](#) Ktlint"

```kotlin
fun foo(value: int) {
fun foo(value: Int) {
if (value > 0) {
doSomething()
} else if (value < 0) {
Expand All @@ -1055,7 +1055,7 @@ If at least one branch of an if-else statement or an if-else-if statement is wra
=== "[:material-heart-off-outline:](#) Disallowed"

```kotlin
fun foo(value: int) {
fun foo(value: Int) {
if (value > 0)
doSomething()
else if (value < 0) {
Expand Down
4 changes: 2 additions & 2 deletions documentation/snapshot/docs/rules/standard.md
Original file line number Diff line number Diff line change
Expand Up @@ -1041,7 +1041,7 @@ If at least one branch of an if-else statement or an if-else-if statement is wra
=== "[:material-heart:](#) Ktlint"

```kotlin
fun foo(value: int) {
fun foo(value: Int) {
if (value > 0) {
doSomething()
} else if (value < 0) {
Expand All @@ -1055,7 +1055,7 @@ If at least one branch of an if-else statement or an if-else-if statement is wra
=== "[:material-heart-off-outline:](#) Disallowed"

```kotlin
fun foo(value: int) {
fun foo(value: Int) {
if (value > 0)
doSomething()
else if (value < 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -338,10 +338,10 @@ class AnnotationRuleTest {
val code =
"""
fun foo(
a: int,
@Bar1 b: int,
@Bar1 @Bar2 c: int,
@Bar3("bar3") @Bar1 d: int
a: Int,
@Bar1 b: Int,
@Bar1 @Bar2 c: Int,
@Bar3("bar3") @Bar1 d: Int
) {}
""".trimIndent()
annotationRuleAssertThat(code).hasNoLintViolations()
Expand Down Expand Up @@ -608,7 +608,8 @@ class AnnotationRuleTest {
annotationRuleAssertThat(code).hasNoLintViolations()
}

@Nested inner class `Array syntax annotations, Issue #1765` {
@Nested
inner class `Array syntax annotations, Issue #1765` {
@Test
fun `annotation preceded by array syntax annotation`() {
val code =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ class IfElseBracingRuleTest {
inner class `Given an IF with ELSE-IF` {
private val formattedCode =
"""
fun foo(value: int) {
fun foo(value: Int) {
if (value > 0) {
doSomething()
} else if (value < 0) {
Expand All @@ -211,7 +211,7 @@ class IfElseBracingRuleTest {
fun `Given all branches without-braces then do not reformat`() {
val code =
"""
fun foo(value: int) {
fun foo(value: Int) {
if (value > 0)
doSomething()
else if (value < 0) doSomethingElse()
Expand All @@ -227,7 +227,7 @@ class IfElseBracingRuleTest {
fun `Given if { -- } else if -- else -- then reformat`() {
val code =
"""
fun foo(value: int) {
fun foo(value: Int) {
if (value > 0) {
doSomething()
} else if (value < 0)
Expand All @@ -249,7 +249,7 @@ class IfElseBracingRuleTest {
fun `Given if -- else if { -- } else -- then reformat`() {
val code =
"""
fun foo(value: int) {
fun foo(value: Int) {
if (value > 0)
doSomething()
else if (value < 0) {
Expand All @@ -271,7 +271,7 @@ class IfElseBracingRuleTest {
fun `Given if -- else if -- else { -- } then reformat`() {
val code =
"""
fun foo(value: int) {
fun foo(value: Int) {
if (value > 0)
doSomething()
else if (value < 0)
Expand All @@ -294,7 +294,7 @@ class IfElseBracingRuleTest {
fun `Given if { -- } else if { -- } else -- then reformat`() {
val code =
"""
fun foo(value: int) {
fun foo(value: Int) {
if (value > 0) {
doSomething()
} else if (value < 0) {
Expand All @@ -314,7 +314,7 @@ class IfElseBracingRuleTest {
fun `Given if { -- } else if -- else { -- } then reformat`() {
val code =
"""
fun foo(value: int) {
fun foo(value: Int) {
if (value > 0) {
doSomething()
} else if (value < 0)
Expand All @@ -335,7 +335,7 @@ class IfElseBracingRuleTest {
fun `Given if -- else if { -- } else { -- } then reformat`() {
val code =
"""
fun foo(value: int) {
fun foo(value: Int) {
if (value > 0)
doSomething()
else if (value < 0) {
Expand All @@ -356,7 +356,7 @@ class IfElseBracingRuleTest {
fun `Given all branches with braces then do not reformat`() {
val code =
"""
fun foo(value: int) {
fun foo(value: Int) {
if (value > 0) {
doSomething()
} else if (value < 0) {
Expand Down

0 comments on commit ba68576

Please sign in to comment.