diff --git a/build.gradle b/build.gradle index b4aed72..9380b95 100644 --- a/build.gradle +++ b/build.gradle @@ -1,7 +1,7 @@ plugins { id 'application' id 'checkstyle' - id 'com.github.ben-manes.versions' version '0.38.0' + id 'com.github.ben-manes.versions' version '0.39.0' id 'idea' id 'io.gitlab.arturbosch.detekt' version '1.17.1' id 'jacoco' diff --git a/config/detekt/baseline.xml b/config/detekt/baseline.xml index 6b6b2e0..0b6f182 100644 --- a/config/detekt/baseline.xml +++ b/config/detekt/baseline.xml @@ -39,7 +39,6 @@ NestedBlockDepth:WorldTime.kt$WorldTime$override fun commandResponse( sender: String, cmd: String, args: String, isPrivate: Boolean ) ReturnCount:Addons.kt$Addons$ fun exec(sender: String, login: String, cmd: String, args: String, isOp: Boolean, isPrivate: Boolean): Boolean ReturnCount:Addons.kt$Addons$ fun help(sender: String, topic: String, isOp: Boolean, isPrivate: Boolean): Boolean - SwallowedException:CryptoPrices.kt$CryptoPrices$catch (e: IllegalArgumentException) { price.amount } ThrowsCount:GoogleSearch.kt$GoogleSearch.Companion$ @JvmStatic @Throws(ModuleException::class) fun searchGoogle(query: String, apiKey: String?, cseKey: String?): List<Message> ThrowsCount:StockQuote.kt$StockQuote.Companion$ @JvmStatic @Throws(ModuleException::class) fun getQuote(symbol: String, apiKey: String?): List<Message> ThrowsCount:StockQuote.kt$StockQuote.Companion$@Throws(ModuleException::class) private fun getJsonResponse(response: String, debugMessage: String): JSONObject diff --git a/src/main/kotlin/net/thauvin/erik/mobibot/modules/CryptoPrices.kt b/src/main/kotlin/net/thauvin/erik/mobibot/modules/CryptoPrices.kt index 8f98fa7..c4b2fcd 100644 --- a/src/main/kotlin/net/thauvin/erik/mobibot/modules/CryptoPrices.kt +++ b/src/main/kotlin/net/thauvin/erik/mobibot/modules/CryptoPrices.kt @@ -33,14 +33,11 @@ package net.thauvin.erik.mobibot.modules import net.thauvin.erik.crypto.CryptoException import net.thauvin.erik.crypto.CryptoPrice -import net.thauvin.erik.crypto.CryptoPrice.Companion.marketPrice +import net.thauvin.erik.crypto.CryptoPrice.Companion.spotPrice import net.thauvin.erik.mobibot.Mobibot import net.thauvin.erik.mobibot.Utils.helpFormat import net.thauvin.erik.mobibot.msg.PublicMessage -import java.text.NumberFormat -import java.util.Currency - /** * The Cryptocurrency Prices module. */ @@ -56,7 +53,7 @@ class CryptoPrices(bot: Mobibot) : ThreadedModule(bot) { val price = currentPrice(args.split(' ')) val amount = try { price.toCurrency() - } catch (e: IllegalArgumentException) { + } catch (ignore: IllegalArgumentException) { price.amount } send(sender, PublicMessage("${price.base}: $amount [${price.currency}]")) @@ -82,9 +79,9 @@ class CryptoPrices(bot: Mobibot) : ThreadedModule(bot) { */ fun currentPrice(args: List): CryptoPrice { return if (args.size == 2) - marketPrice(args[0], args[1]) + spotPrice(args[0], args[1]) else - marketPrice(args[0]) + spotPrice(args[0]) } } diff --git a/src/test/kotlin/net/thauvin/erik/mobibot/modules/CryptoPricesTest.kt b/src/test/kotlin/net/thauvin/erik/mobibot/modules/CryptoPricesTest.kt index f046b59..98a72cb 100644 --- a/src/test/kotlin/net/thauvin/erik/mobibot/modules/CryptoPricesTest.kt +++ b/src/test/kotlin/net/thauvin/erik/mobibot/modules/CryptoPricesTest.kt @@ -45,11 +45,11 @@ class CryptoPricesTest { var price = currentPrice(listOf("BTC")) assertThat(price.base).describedAs("is BTC").isEqualTo("BTC") assertThat(price.currency).describedAs("is USD").isEqualTo("USD") - assertThat(price.amount).describedAs("BTC > 0").isGreaterThan(0.00) + assertThat(price.amount.signum() > 0).describedAs("BTC > 0").isTrue price = currentPrice(listOf("ETH", "EUR")) assertThat(price.base).describedAs("is ETH").isEqualTo("ETH") assertThat(price.currency).describedAs("is EUR").isEqualTo("EUR") - assertThat(price.amount).describedAs("ETH > 0").isGreaterThan(0.00) + assertThat(price.amount.signum() > 0).describedAs("ETH > 0").isTrue } } diff --git a/version.properties b/version.properties index 854ee64..68e52a4 100644 --- a/version.properties +++ b/version.properties @@ -1,9 +1,9 @@ #Generated by the Semver Plugin for Gradle -#Tue May 25 18:01:58 PDT 2021 -version.buildmeta=848 +#Fri May 28 11:26:02 PDT 2021 +version.buildmeta=854 version.major=0 version.minor=8 version.patch=0 version.prerelease=beta version.project=mobibot -version.semver=0.8.0-beta+848 +version.semver=0.8.0-beta+854