Skip to content

Commit eb22cc4

Browse files
authored
SONARKT-382 Update rules metadata (#404)
1 parent 9eadc7a commit eb22cc4

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-4
lines changed

sonar-kotlin-plugin/sonarpedia.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"languages": [
44
"KOTLIN"
55
],
6-
"latest-update": "2023-11-21T13:31:58.377021Z",
6+
"latest-update": "2023-12-14T11:00:42.692746Z",
77
"options": {
88
"no-language-in-filenames": true,
99
"preserve-filenames": true

sonar-kotlin-plugin/src/main/resources/org/sonar/l10n/kotlin/rules/kotlin/S6518.html

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ <h3>What is the potential impact?</h3>
66
<h4>Readability and Understanding</h4>
77
<p>This change makes it easier to understand what a function does, because the semantics of indexed access operators is evident to the reader, while
88
for a function call, the reader would need to know what the called function does.</p>
9+
<h4>Java interop</h4>
10+
<p>The issue is also raised when Java API is used as a Kotlin compiler treats all <code>get(.)</code> methods as possible index access operators. Use
11+
<code>CompletableFuture[timeout, unit]</code> instead of <code>CompletableFuture.get(timeout, unit)</code> when accessing Java’s
12+
<code>CompletableFuture</code>.</p>
913
<h2>How to fix it</h2>
1014
<p>Replace <code>instance.get(index)</code> with <code>instance[index]</code>.</p>
1115
<p>Replace <code>instance.set(index, value)</code> with <code>instance[index] = value</code>.</p>

sonar-kotlin-plugin/src/main/resources/org/sonar/l10n/kotlin/rules/kotlin/S6624.html

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,17 @@ <h4>Noncompliant code example</h4>
2020
</pre>
2121
<h4>Compliant solution</h4>
2222
<pre data-diff-id="1" data-diff-type="compliant">
23-
ext {
24-
mockitoVersion = "4.5.1"
25-
}
23+
const val mockitoVersion = "4.5.1"
2624

2725
dependencies {
2826
testImplementation("org.mockito:mockito-core:$mockitoVersion")
2927
testImplementation("org.mockito:mockito-inline:$mockitoVersion")
3028
}
3129
</pre>
30+
<p>Alternatively, you can put <code>const val mockitoVersion = "4.5.1"</code> in any <code>.kt</code> file in <code>buildSrc/src/main/kotlin</code> or
31+
use a more robust dependency management mechanism like <a href="https://plugins.gradle.org/plugin/io.spring.dependency-management">Spring dependency
32+
management plugin</a> or <a href="https://www.youtube.com/watch?v=WvtcCCCLfOc&amp;list=PL0UJI1nZ56yAHv9H9kZA6vat4N1kSRGis&amp;index=21">Version
33+
Catalogs</a>.</p>
3234
<h2>Resources</h2>
3335
<h3>Documentation</h3>
3436
<ul>

0 commit comments

Comments
 (0)