Skip to content

Commit cefe6e8

Browse files
committed
Reduce the number of compile-time warnings
1 parent 6d9f0b2 commit cefe6e8

File tree

7 files changed

+19
-9
lines changed

7 files changed

+19
-9
lines changed

build.gradle.kts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ import com.github.jengelman.gradle.plugins.shadow.transformers.Log4j2PluginsCach
33
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
44

55
plugins {
6-
kotlin("jvm").version("1.5.31").apply(false)
7-
kotlin("plugin.serialization").version("1.5.31").apply(false)
6+
kotlin("jvm").version("1.7.20").apply(false)
7+
kotlin("plugin.serialization").version("1.7.20").apply(false)
88
id("com.github.johnrengelman.shadow").version("7.1.0").apply(false)
99
}
1010

@@ -19,7 +19,12 @@ subprojects {
1919
options.release.set(11)
2020
}
2121
withType<KotlinCompile> {
22-
kotlinOptions.jvmTarget = "11"
22+
kotlinOptions {
23+
jvmTarget = "11"
24+
freeCompilerArgs = freeCompilerArgs + listOf(
25+
"-opt-in=kotlin.RequiresOptIn",
26+
)
27+
}
2328
}
2429
withType<Jar> {
2530
// Workaround for https://stackoverflow.com/q/42174572/750510

currencies/src/main/kotlin/by/jprof/telegram/bot/currencies/CurrenciesUpdateProcessor.kt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import dev.inmo.tgbotapi.extensions.api.send.reply
88
import dev.inmo.tgbotapi.types.ParseMode.MarkdownV2ParseMode
99
import dev.inmo.tgbotapi.types.message.abstracts.ContentMessage
1010
import dev.inmo.tgbotapi.types.message.content.TextContent
11-
import dev.inmo.tgbotapi.types.update.CallbackQueryUpdate
1211
import dev.inmo.tgbotapi.types.update.MessageUpdate
1312
import dev.inmo.tgbotapi.types.update.abstracts.Update
1413
import dev.inmo.tgbotapi.utils.extensions.escapeMarkdownV2Common
@@ -25,7 +24,7 @@ class CurrenciesUpdateProcessor(
2524
}
2625

2726
override suspend fun process(update: Update) {
28-
val update = update as? MessageUpdate ?: return
27+
@Suppress("NAME_SHADOWING") val update = update as? MessageUpdate ?: return
2928
val message = update.data as? ContentMessage<*> ?: return
3029
val content = message.content as? TextContent ?: return
3130

gradle/libs.versions.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[versions]
2-
coroutines = "1.5.2"
2+
coroutines = "1.6.4"
33

44
aws-lambda-java-events = "3.10.0"
55
aws-lambda-java-core = "1.2.1"

herald/build.gradle.kts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ application {
99
}
1010

1111
dependencies {
12+
implementation(platform(libs.ktor.bom))
13+
1214
implementation(libs.kotlinx.serialization.core)
1315
implementation(libs.kaml)
1416
implementation(libs.tgbotapi.extensions.api)

herald/src/main/kotlin/by/jprof/telegram/bot/herald/App.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import by.jprof.telegram.bot.herald.impl.post
44
import by.jprof.telegram.bot.herald.impl.postFile
55
import by.jprof.telegram.bot.herald.impl.send
66

7-
suspend fun main(args: Array<String>) {
7+
suspend fun main() {
88
val postFile = postFile() ?: run { println("No post for today"); return }
99

1010
println("Today's post: $postFile")

times/src/main/kotlin/by/jprof/telegram/bot/times/TimeCommandUpdateProcessor.kt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,14 @@ import dev.inmo.tgbotapi.types.message.abstracts.Message
1919
import dev.inmo.tgbotapi.types.message.abstracts.PossiblyReplyMessage
2020
import dev.inmo.tgbotapi.types.message.content.TextContent
2121
import dev.inmo.tgbotapi.types.update.abstracts.Update
22+
import dev.inmo.tgbotapi.utils.PreviewFeature
2223
import java.time.Instant
2324
import java.time.LocalDateTime
2425
import java.time.ZoneId
2526
import java.time.ZoneOffset
2627
import org.apache.logging.log4j.LogManager
2728

29+
@OptIn(PreviewFeature::class)
2830
class TimeCommandUpdateProcessor(
2931
private val timeZoneDAO: TimeZoneDAO,
3032
private val bot: RequestsExecutor,
@@ -34,7 +36,7 @@ class TimeCommandUpdateProcessor(
3436
}
3537

3638
override suspend fun process(update: Update) {
37-
val update = update.asBaseMessageUpdate() ?: return
39+
@Suppress("NAME_SHADOWING") val update = update.asBaseMessageUpdate() ?: return
3840
val message = update.data.asContentMessage() ?: return
3941
val text = message.content.asTextContent() ?: return
4042

@@ -52,7 +54,7 @@ class TimeCommandUpdateProcessor(
5254
}
5355

5456
private suspend fun replyText(message: Message): String {
55-
val message = (message as? PossiblyReplyMessage)?.replyTo ?: return ""
57+
@Suppress("NAME_SHADOWING") val message = (message as? PossiblyReplyMessage)?.replyTo ?: return ""
5658
val author = (message as? FromUser)?.user ?: return ""
5759
val timeZone = timeZoneDAO.get(author.id.chatId, message.chat.id.chatId) ?: return ""
5860
val messageTime = Instant.ofEpochMilli(message.date.unixMillisLong).toLocalDateTime(timeZone) ?: return ""

times/src/main/kotlin/by/jprof/telegram/bot/times/TimeZoneCommandUpdateProcessor.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,10 @@ import dev.inmo.tgbotapi.bot.RequestsExecutor
1313
import dev.inmo.tgbotapi.extensions.api.send.reply
1414
import dev.inmo.tgbotapi.types.ParseMode.MarkdownV2
1515
import dev.inmo.tgbotapi.types.update.abstracts.Update
16+
import dev.inmo.tgbotapi.utils.PreviewFeature
1617
import org.apache.logging.log4j.LogManager
1718

19+
@OptIn(PreviewFeature::class)
1820
class TimeZoneCommandUpdateProcessor(
1921
private val timeZoneDAO: TimeZoneDAO,
2022
private val bot: RequestsExecutor,

0 commit comments

Comments
 (0)