File tree Expand file tree Collapse file tree 3 files changed +10
-4
lines changed
src/main/resources/org/sonar/l10n/kotlin/rules/kotlin Expand file tree Collapse file tree 3 files changed +10
-4
lines changed Original file line number Diff line number Diff line change 3
3
"languages" : [
4
4
" KOTLIN"
5
5
],
6
- "latest-update" : " 2023-11-21T13:31:58.377021Z " ,
6
+ "latest-update" : " 2023-12-14T11:00:42.692746Z " ,
7
7
"options" : {
8
8
"no-language-in-filenames" : true ,
9
9
"preserve-filenames" : true
Original file line number Diff line number Diff line change @@ -6,6 +6,10 @@ <h3>What is the potential impact?</h3>
6
6
< h4 > Readability and Understanding</ h4 >
7
7
< 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
8
8
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 >
9
13
< h2 > How to fix it</ h2 >
10
14
< p > Replace < code > instance.get(index)</ code > with < code > instance[index]</ code > .</ p >
11
15
< p > Replace < code > instance.set(index, value)</ code > with < code > instance[index] = value</ code > .</ p >
Original file line number Diff line number Diff line change @@ -20,15 +20,17 @@ <h4>Noncompliant code example</h4>
20
20
</ pre >
21
21
< h4 > Compliant solution</ h4 >
22
22
< pre data-diff-id ="1 " data-diff-type ="compliant ">
23
- ext {
24
- mockitoVersion = "4.5.1"
25
- }
23
+ const val mockitoVersion = "4.5.1"
26
24
27
25
dependencies {
28
26
testImplementation("org.mockito:mockito-core:$mockitoVersion")
29
27
testImplementation("org.mockito:mockito-inline:$mockitoVersion")
30
28
}
31
29
</ 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&list=PL0UJI1nZ56yAHv9H9kZA6vat4N1kSRGis&index=21 "> Version
33
+ Catalogs</ a > .</ p >
32
34
< h2 > Resources</ h2 >
33
35
< h3 > Documentation</ h3 >
34
36
< ul >
You can’t perform that action at this time.
0 commit comments