From ba68576b232ca78f16cd85459a73d8590f1e402e Mon Sep 17 00:00:00 2001 From: GrzegorzBobryk <38888282+GrzegorzBobryk@users.noreply.github.com> Date: Tue, 13 Aug 2024 08:40:20 +0200 Subject: [PATCH] [Bugfix] `int` to `Int` migration (#2767) 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. --- .../release-latest/docs/rules/standard.md | 4 ++-- documentation/snapshot/docs/rules/standard.md | 4 ++-- .../standard/rules/AnnotationRuleTest.kt | 11 ++++++----- .../standard/rules/IfElseBracingRuleTest.kt | 18 +++++++++--------- 4 files changed, 19 insertions(+), 18 deletions(-) diff --git a/documentation/release-latest/docs/rules/standard.md b/documentation/release-latest/docs/rules/standard.md index 3835384960..dff1aa6858 100644 --- a/documentation/release-latest/docs/rules/standard.md +++ b/documentation/release-latest/docs/rules/standard.md @@ -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) { @@ -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) { diff --git a/documentation/snapshot/docs/rules/standard.md b/documentation/snapshot/docs/rules/standard.md index 3835384960..dff1aa6858 100644 --- a/documentation/snapshot/docs/rules/standard.md +++ b/documentation/snapshot/docs/rules/standard.md @@ -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) { @@ -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) { diff --git a/ktlint-ruleset-standard/src/test/kotlin/com/pinterest/ktlint/ruleset/standard/rules/AnnotationRuleTest.kt b/ktlint-ruleset-standard/src/test/kotlin/com/pinterest/ktlint/ruleset/standard/rules/AnnotationRuleTest.kt index 47a499216a..2e6bb20410 100644 --- a/ktlint-ruleset-standard/src/test/kotlin/com/pinterest/ktlint/ruleset/standard/rules/AnnotationRuleTest.kt +++ b/ktlint-ruleset-standard/src/test/kotlin/com/pinterest/ktlint/ruleset/standard/rules/AnnotationRuleTest.kt @@ -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() @@ -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 = diff --git a/ktlint-ruleset-standard/src/test/kotlin/com/pinterest/ktlint/ruleset/standard/rules/IfElseBracingRuleTest.kt b/ktlint-ruleset-standard/src/test/kotlin/com/pinterest/ktlint/ruleset/standard/rules/IfElseBracingRuleTest.kt index d0b026b7cf..f121573708 100644 --- a/ktlint-ruleset-standard/src/test/kotlin/com/pinterest/ktlint/ruleset/standard/rules/IfElseBracingRuleTest.kt +++ b/ktlint-ruleset-standard/src/test/kotlin/com/pinterest/ktlint/ruleset/standard/rules/IfElseBracingRuleTest.kt @@ -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) { @@ -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() @@ -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) @@ -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) { @@ -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) @@ -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) { @@ -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) @@ -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) { @@ -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) {