Fixed SonarCloud code smells
This commit is contained in:
parent
adaff5ec38
commit
d700aa06df
6 changed files with 47 additions and 34 deletions
1
.idea/misc.xml
generated
1
.idea/misc.xml
generated
|
@ -1,4 +1,3 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project version="4">
|
<project version="4">
|
||||||
<component name="ExternalStorageConfigurationManager" enabled="true" />
|
<component name="ExternalStorageConfigurationManager" enabled="true" />
|
||||||
<component name="FrameworkDetectionExcludesConfiguration">
|
<component name="FrameworkDetectionExcludesConfiguration">
|
||||||
|
|
|
@ -42,7 +42,6 @@ import org.slf4j.Logger
|
||||||
import java.io.*
|
import java.io.*
|
||||||
import java.net.HttpURLConnection
|
import java.net.HttpURLConnection
|
||||||
import java.net.URL
|
import java.net.URL
|
||||||
import java.net.URLEncoder
|
|
||||||
import java.nio.file.Files
|
import java.nio.file.Files
|
||||||
import java.nio.file.Paths
|
import java.nio.file.Paths
|
||||||
import java.time.LocalDateTime
|
import java.time.LocalDateTime
|
||||||
|
@ -125,14 +124,19 @@ object Utils {
|
||||||
*/
|
*/
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
fun String?.colorize(color: String): String {
|
fun String?.colorize(color: String): String {
|
||||||
return if (isNullOrEmpty()) {
|
return when {
|
||||||
""
|
isNullOrEmpty() -> {
|
||||||
} else if (color == DEFAULT_COLOR) {
|
""
|
||||||
this
|
}
|
||||||
} else if (Colors.BOLD == color || Colors.REVERSE == color) {
|
color == DEFAULT_COLOR -> {
|
||||||
color + this + color
|
this
|
||||||
} else {
|
}
|
||||||
color + this + Colors.NORMAL
|
Colors.BOLD == color || Colors.REVERSE == color -> {
|
||||||
|
color + this + color
|
||||||
|
}
|
||||||
|
else -> {
|
||||||
|
color + this + Colors.NORMAL
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -129,7 +129,7 @@ class Ignore : AbstractCommand() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ignored.size > 0) {
|
if (ignored.isNotEmpty()) {
|
||||||
event.sendMessage("The following nicks are ignored:")
|
event.sendMessage("The following nicks are ignored:")
|
||||||
event.sendList(ignored.sorted(), 8, isIndent = true)
|
event.sendList(ignored.sorted(), 8, isIndent = true)
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -85,18 +85,23 @@ class Tell(private val serialObject: String) : AbstractCommand() {
|
||||||
|
|
||||||
override fun commandResponse(channel: String, args: String, event: GenericMessageEvent) {
|
override fun commandResponse(channel: String, args: String, event: GenericMessageEvent) {
|
||||||
if (isEnabled()) {
|
if (isEnabled()) {
|
||||||
if (args.isBlank()) {
|
when {
|
||||||
helpResponse(channel, args, event)
|
args.isBlank() -> {
|
||||||
} else if (args.startsWith(View.VIEW_CMD)) {
|
helpResponse(channel, args, event)
|
||||||
if (event.isChannelOp(channel) && "${View.VIEW_CMD} $TELL_ALL_KEYWORD" == args) {
|
}
|
||||||
viewAll(event)
|
args.startsWith(View.VIEW_CMD) -> {
|
||||||
} else {
|
if (event.isChannelOp(channel) && "${View.VIEW_CMD} $TELL_ALL_KEYWORD" == args) {
|
||||||
viewMessages(event)
|
viewAll(event)
|
||||||
|
} else {
|
||||||
|
viewMessages(event)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
args.startsWith("$TELL_DEL_KEYWORD ") -> {
|
||||||
|
deleteMessage(channel, args, event)
|
||||||
|
}
|
||||||
|
else -> {
|
||||||
|
newMessage(channel, args, event)
|
||||||
}
|
}
|
||||||
} else if (args.startsWith("$TELL_DEL_KEYWORD ")) {
|
|
||||||
deleteMessage(channel, args, event)
|
|
||||||
} else {
|
|
||||||
newMessage(channel, args, event)
|
|
||||||
}
|
}
|
||||||
if (clean()) {
|
if (clean()) {
|
||||||
save()
|
save()
|
||||||
|
|
|
@ -141,7 +141,7 @@ class FeedsManager private constructor() {
|
||||||
.append("\"><b>")
|
.append("\"><b>")
|
||||||
.append(channel)
|
.append(channel)
|
||||||
.append("</b></a>")
|
.append("</b></a>")
|
||||||
if (comments.size > 0) {
|
if (comments.isNotEmpty()) {
|
||||||
buff.append(" <br/><br/>")
|
buff.append(" <br/><br/>")
|
||||||
for (j in comments.indices) {
|
for (j in comments.indices) {
|
||||||
if (j > 0) {
|
if (j > 0) {
|
||||||
|
|
|
@ -74,19 +74,24 @@ class CurrencyConverter : AbstractModule() {
|
||||||
override fun commandResponse(channel: String, cmd: String, args: String, event: GenericMessageEvent) {
|
override fun commandResponse(channel: String, cmd: String, args: String, event: GenericMessageEvent) {
|
||||||
reload(properties[API_KEY_PROP])
|
reload(properties[API_KEY_PROP])
|
||||||
|
|
||||||
if (SYMBOLS.isEmpty()) {
|
when {
|
||||||
event.respond(EMPTY_SYMBOLS_TABLE)
|
SYMBOLS.isEmpty() -> {
|
||||||
} else if (args.matches("\\d+([,\\d]+)?(\\.\\d+)? [a-zA-Z]{3}+ (to|in) [a-zA-Z]{3}+".toRegex())) {
|
event.respond(EMPTY_SYMBOLS_TABLE)
|
||||||
val msg = convertCurrency(properties[API_KEY_PROP], args)
|
}
|
||||||
event.respond(msg.msg)
|
args.matches("\\d+([,\\d]+)?(\\.\\d+)? [a-zA-Z]{3}+ (to|in) [a-zA-Z]{3}+".toRegex()) -> {
|
||||||
if (msg.isError) {
|
val msg = convertCurrency(properties[API_KEY_PROP], args)
|
||||||
|
event.respond(msg.msg)
|
||||||
|
if (msg.isError) {
|
||||||
|
helpResponse(event)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
args.contains(CODES_KEYWORD) -> {
|
||||||
|
event.sendMessage("The supported currency codes are:")
|
||||||
|
event.sendList(SYMBOLS.keys.toList(), 11, isIndent = true)
|
||||||
|
}
|
||||||
|
else -> {
|
||||||
helpResponse(event)
|
helpResponse(event)
|
||||||
}
|
}
|
||||||
} else if (args.contains(CODES_KEYWORD)) {
|
|
||||||
event.sendMessage("The supported currency codes are:")
|
|
||||||
event.sendList(SYMBOLS.keys.toList(), 11, isIndent = true)
|
|
||||||
} else {
|
|
||||||
helpResponse(event)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue