Skip to content

Commit 1355cac

Browse files
Merge pull request #832 from timis1/BAEL-102744
BAEL-102744 Review remaining warnings in kotlin-build job
2 parents eafa3b8 + 6b94413 commit 1355cac

File tree

20 files changed

+45
-17
lines changed

20 files changed

+45
-17
lines changed

core-kotlin-modules/core-kotlin-6/src/main/kotlin/com/baeldung/deprecation/Date.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ typealias DateFormat = String
3131

3232
fun main() {
3333
val epoch = Date(0)
34+
@Suppress("DEPRECATION")
3435
println(epoch.monthNumber())
3536
println(epoch.month())
3637

core-kotlin-modules/core-kotlin-6/src/test/kotlin/com/baeldung/runExternalCommand/RunExternalCommandUnitTest.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ package com.baeldung.runExternalCommand
22

33
import org.junit.jupiter.api.Test
44
import org.assertj.core.api.Assertions.assertThat
5+
import java.io.BufferedReader
6+
import java.nio.Buffer
57

68
class RunExternalCommandUnitTest {
79

core-kotlin-modules/core-kotlin-annotations/src/main/kotlin/com/baeldung/jvmannotations/Message.kt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,8 @@ class Message {
4949
@set:JvmName("setContent")
5050
var text = ""
5151

52-
// generates a warning
5352
@get:JvmName("getId")
54-
private val id = 0
53+
val id = 0
5554

5655
@get:JvmName("hasAttachment")
5756
var hasAttachment = true

core-kotlin-modules/core-kotlin-collections-5/src/test/kotlin/com/baeldung/intArrayToStringArray/IntArrayToStringArrayUnitTest.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ class IntArrayToStringArrayUnitTest {
1010
fun `when using toInt then it converts array`() {
1111
val stringArray = arrayOf("1", "2", "3", "4", "5")
1212
val intArray = stringArray.map { it.toInt() }.toIntArray()
13+
@Suppress("USELESS_IS_CHECK")
1314
assertThat(intArray.all { it is Int }).isTrue()
1415
assertThat(intArray).isEqualTo(arrayOf(1,2,3,4,5))
1516
}
@@ -40,6 +41,7 @@ class IntArrayToStringArrayUnitTest {
4041
fun `when using toIntOrNull then it converts array`() {
4142
val stringArray = arrayOf("1", "2", "3", "four", "5")
4243
val intArray = stringArray.mapNotNull { it.toIntOrNull() }.toIntArray()
44+
@Suppress("USELESS_IS_CHECK")
4345
assertThat(intArray.all { it is Int }).isTrue()
4446
assertThat(intArray).isEqualTo(arrayOf(1,2,3,5))
4547
}

core-kotlin-modules/core-kotlin-collections-list/src/test/kotlin/com/baeldung/transformation/CustomObjectTransformationKtUnitTest.kt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ class CustomObjectTransformationKtUnitTest {
4040
assertTrue(empNameList == expectedEmpNames)
4141
empNameList.forEach {
4242
assertNotNull(it)
43+
@Suppress("USELESS_IS_CHECK")
4344
assert(it is String)
4445
}
4546
}
@@ -49,6 +50,7 @@ class CustomObjectTransformationKtUnitTest {
4950
val countries = listOf("US", "India", "Australia", null, "Ethiopia", "Brazil", null, "Romania")
5051
val nonNullCountries = countries.mapNotNull { it?.uppercase() }
5152
assertNotNull(countries)
53+
@Suppress("SENSELESS_COMPARISON")
5254
val nullList = nonNullCountries.filter { it == null }
5355
assertEquals(0, nullList.size)
5456
}
@@ -61,6 +63,7 @@ class CustomObjectTransformationKtUnitTest {
6163
assertTrue(empNameList == expectedEmpNames)
6264
empNameList.forEach {
6365
assertNotNull(it)
66+
@Suppress("USELESS_IS_CHECK")
6467
assert(it is String)
6568
}
6669
}
@@ -73,6 +76,7 @@ class CustomObjectTransformationKtUnitTest {
7376
assertTrue(empNameList == expectedEmpNames)
7477
empNameList.forEach {
7578
assertNotNull(it)
79+
@Suppress("USELESS_IS_CHECK")
7680
assert(it is String)
7781
}
7882
}
@@ -99,6 +103,7 @@ class CustomObjectTransformationKtUnitTest {
99103
assertTrue(empNameList == expectedEmpNames)
100104
empNameList.forEach {
101105
assertNotNull(it)
106+
@Suppress("USELESS_IS_CHECK")
102107
assert(it is String)
103108
}
104109
}
@@ -113,6 +118,7 @@ class CustomObjectTransformationKtUnitTest {
113118
assertTrue(empNameList == expectedEmpNames)
114119
empNameList.forEach {
115120
assertNotNull(it)
121+
@Suppress("USELESS_IS_CHECK")
116122
assert(it is String)
117123
}
118124

@@ -127,6 +133,7 @@ class CustomObjectTransformationKtUnitTest {
127133
assertTrue(anotherEmpNameList == expectedEmpNames)
128134
anotherEmpNameList.forEach {
129135
assertNotNull(it)
136+
@Suppress("USELESS_IS_CHECK")
130137
assert(it is String)
131138
}
132139
}
@@ -141,6 +148,7 @@ class CustomObjectTransformationKtUnitTest {
141148
assertTrue(empNameList == expectedEmpNames)
142149
empNameList.forEach {
143150
assertNotNull(it)
151+
@Suppress("USELESS_IS_CHECK")
144152
assert(it is String)
145153
}
146154
}
@@ -155,6 +163,7 @@ class CustomObjectTransformationKtUnitTest {
155163
assertTrue(empNameList == expectedEmpNames)
156164
empNameList.forEach {
157165
assertNotNull(it)
166+
@Suppress("USELESS_IS_CHECK")
158167
assert(it is String)
159168
}
160169
}
@@ -168,6 +177,7 @@ class CustomObjectTransformationKtUnitTest {
168177
assertTrue(empNameList == expectedEmpNames)
169178
empNameList.forEach {
170179
assertNotNull(it)
180+
@Suppress("USELESS_IS_CHECK")
171181
assert(it is String)
172182
}
173183
}

core-kotlin-modules/core-kotlin-concurrency-2/src/main/kotlin/com/baeldung/coroutine/composing/sampleCall.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ class DataProcessUseCase(dispatcher: CoroutineDispatcher) : CoroutineScope by Co
9696
data class UserInput(val query: String)
9797

9898
class HTTPClientMock(private val mockAnswering: (URL) -> String) {
99-
suspend fun get(url: URL, params: String): Response = Response(200, mockAnswering(url))
99+
suspend fun get(url: URL, params: String): Response = Response(200, mockAnswering(url), params)
100100
}
101101

102-
class Response(val status: Int, val body: String)
102+
class Response(val status: Int, val body: String, val params: String)

core-kotlin-modules/core-kotlin-lang-2/src/test/kotlin/com/baeldung/nullsafety/NullSafetyUnitTest.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ class NullSafetyUnitTest {
123123

124124
//when
125125
assertFailsWith<NullPointerException> {
126-
b!!
126+
@Suppress("ALWAYS_NULL")b!!
127127
}
128128
}
129129

core-kotlin-modules/core-kotlin-lang-2/src/test/kotlin/com/baeldung/scope/ScopeFunctionsUnitTest.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ class ScopeFunctionsUnitTest {
4444
}
4545

4646
val aNullMessage = null
47-
val thisIsNull = aNullMessage?.let {
47+
val thisIsNull = aNullMessage?.let {@Suppress("UNREACHABLE_CODE")
4848
"At this point it would be safe to reference the variable. But it will not really happen because it is null. Let's reference: $it"
4949
} ?: "default value"
5050

core-kotlin-modules/core-kotlin-lang-oop-3/src/test/kotlin/com/baeldung/nameOfEnumEntries/GetNamesOfEnumEntriesUnitTest.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import org.junit.jupiter.api.Test
44
import kotlin.enums.EnumEntries
55
import kotlin.test.assertEquals
66

7-
enum class CountryCode(countryName: String) {
7+
enum class CountryCode(@Suppress("UNUSED_PARAMETER")countryName: String) {
88
USA("United States of America"),
99
UKR("Ukraine"),
1010
CAN("Canada"),

core-kotlin-modules/core-kotlin-lang/src/test/kotlin/com/baeldung/voidtypes/VoidTypesUnitTest.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,13 @@ class VoidTypesUnitTest {
3838
fun invokeANothingOnlyFunction() {
3939
alwaysThrowException()
4040

41+
@Suppress("UNREACHABLE_CODE")
4142
var name = "Tom"
4243
}
4344

4445
@Test
4546
fun givenJavaVoidFunction_thenMappedToKotlinUnit() {
47+
@Suppress("USELESS_IS_CHECK")
4648
assertTrue(System.out.println() is Unit)
4749
}
4850

@@ -53,11 +55,13 @@ class VoidTypesUnitTest {
5355

5456
@Test
5557
fun givenUnitReturnTypeDeclared_thenReturnsOfTypeUnit() {
58+
@Suppress("USELESS_IS_CHECK")
5659
assertTrue(unitReturnTypeForNonMeaningfulReturns() is Unit)
5760
}
5861

5962
@Test
6063
fun givenUnitReturnTypeNotDeclared_thenReturnsOfTypeUnit() {
64+
@Suppress("USELESS_IS_CHECK")
6165
assertTrue(unitReturnTypeIsImplicit() is Unit)
6266
}
6367
}

0 commit comments

Comments
 (0)