Change the Kotlin language version to 2.1

This commit is contained in:
Erik C. Thauvin 2025-05-07 14:15:01 -07:00
parent 5bedd323ca
commit dd68ef111b
Signed by: erik
GPG key ID: 776702A6A2DA330E
10 changed files with 21 additions and 24 deletions

View file

@ -72,8 +72,8 @@ public class MobibotBuild extends Project {
javaRelease = 17;
downloadSources = true;
autoDownloadPurge = true;
downloadSources = true;
repositories = List.of(
MAVEN_LOCAL,
@ -168,7 +168,7 @@ public class MobibotBuild extends Project {
public void compile() throws Exception {
releaseInfo();
var op = new CompileKotlinOperation().fromProject(this);
op.compileOptions().progressive(true).verbose(true);
op.compileOptions().languageVersion("2.1").progressive(true).verbose(true);
op.execute();
}

View file

@ -125,10 +125,10 @@ class Mobibot(nickname: String, val channel: String, logsDirPath: String, p: Pro
).use { fis ->
p.load(fis)
}
} catch (ignore: FileNotFoundException) {
} catch (_: FileNotFoundException) {
System.err.println("Unable to find properties file.")
exitProcess(1)
} catch (ignore: IOException) {
} catch (_: IOException) {
System.err.println("Unable to open properties file.")
exitProcess(1)
}
@ -147,7 +147,7 @@ class Mobibot(nickname: String, val channel: String, logsDirPath: String, p: Pro
), true
)
System.setOut(stdout)
} catch (ignore: IOException) {
} catch (_: IOException) {
System.err.println("Unable to open output (stdout) log file.")
exitProcess(1)
}
@ -158,7 +158,7 @@ class Mobibot(nickname: String, val channel: String, logsDirPath: String, p: Pro
), true
)
System.setErr(stderr)
} catch (ignore: IOException) {
} catch (_: IOException) {
System.err.println("Unable to open error (stderr) log file.")
exitProcess(1)
}

View file

@ -331,7 +331,7 @@ object Utils {
}
/**
* Send a formatted commands/modules, etc. list.
* Send a formatted list to the channel.
*/
@JvmStatic
@JvmOverloads
@ -394,7 +394,7 @@ object Utils {
fun String.toIntOrDefault(defaultValue: Int): Int {
return try {
toInt()
} catch (e: NumberFormatException) {
} catch (_: NumberFormatException) {
defaultValue
}
}

View file

@ -146,7 +146,7 @@ class LinksManager : AbstractCommand() {
pinboard.addPin(event.bot().serverHostname, entry)
// Queue link for posting to social media.
// Queue the entry for posting to social media.
socialManager.queueEntry(index)
entries.save()
@ -179,7 +179,7 @@ class LinksManager : AbstractCommand() {
if (title.isNotBlank()) {
return title
}
} catch (ignore: IOException) {
} catch (_: IOException) {
// Do nothing
}
return Constants.NO_TITLE
@ -193,7 +193,7 @@ class LinksManager : AbstractCommand() {
"Duplicate".bold() + " >> " + printLink(entries.links.indexOf(match), match)
)
true
} catch (ignore: NoSuchElementException) {
} catch (_: NoSuchElementException) {
false
}
}

View file

@ -89,7 +89,7 @@ class View : AbstractCommand() {
if (start > entries.links.size) {
start = 0
}
} catch (ignore: NumberFormatException) {
} catch (_: NumberFormatException) {
// Do nothing
}
}

View file

@ -72,7 +72,7 @@ class CryptoPrices : AbstractModule() {
val price = currentPrice(args.split(' '))
val amount = try {
price.toCurrency()
} catch (ignore: IllegalArgumentException) {
} catch (_: IllegalArgumentException) {
price.amount
}
event.respond("${price.base} current price is $amount [${CURRENCIES[price.currency]}]")

View file

@ -82,7 +82,7 @@ class StockQuote : AbstractModule() {
if (info.isNotEmpty()) {
throw ModuleException(debugMessage, info.unescapeXml())
}
} catch (ignore: JSONException) {
} catch (_: JSONException) {
// Do nothing
}
try {
@ -94,7 +94,7 @@ class StockQuote : AbstractModule() {
if (error.isNotEmpty()) {
throw ModuleException(debugMessage, error.unescapeXml())
}
} catch (ignore: JSONException) {
} catch (_: JSONException) {
// Do nothing
}
json

View file

@ -59,7 +59,7 @@ class ChatGpt2Test : LocalProperties() {
fun chat() {
assertThat(
ChatGpt2.chat(
"return only the code for javascript function to make a request with XMLHttpRequest",
"javascript function to make a request with XMLHttpRequest, just code",
apiKey,
50
)

View file

@ -51,7 +51,7 @@ class Gemini2Test : LocalProperties() {
fun chatHttpRequestInJavascript() {
assertThat(
Gemini2.chat(
"return only the code for a javascript function to make a request with XMLHttpRequest",
"javascript function to make a request with XMLHttpRequest, just code",
apiKey,
maxTokens
)
@ -62,8 +62,8 @@ class Gemini2Test : LocalProperties() {
@DisableOnCi
fun chatEncodeUrlInJava() {
assertThat(
Gemini2.chat("how do I encode a URL in java?", apiKey, 60)
).isNotNull().contains("URLEncoder")
Gemini2.chat("encode a url in java, one line, just code", apiKey, 60)
).isNotNull().contains("UrlEncoder", true)
}
}