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">
|
||||
<component name="ExternalStorageConfigurationManager" enabled="true" />
|
||||
<component name="FrameworkDetectionExcludesConfiguration">
|
||||
|
|
|
@ -42,7 +42,6 @@ import org.slf4j.Logger
|
|||
import java.io.*
|
||||
import java.net.HttpURLConnection
|
||||
import java.net.URL
|
||||
import java.net.URLEncoder
|
||||
import java.nio.file.Files
|
||||
import java.nio.file.Paths
|
||||
import java.time.LocalDateTime
|
||||
|
@ -125,16 +124,21 @@ object Utils {
|
|||
*/
|
||||
@JvmStatic
|
||||
fun String?.colorize(color: String): String {
|
||||
return if (isNullOrEmpty()) {
|
||||
return when {
|
||||
isNullOrEmpty() -> {
|
||||
""
|
||||
} else if (color == DEFAULT_COLOR) {
|
||||
}
|
||||
color == DEFAULT_COLOR -> {
|
||||
this
|
||||
} else if (Colors.BOLD == color || Colors.REVERSE == color) {
|
||||
}
|
||||
Colors.BOLD == color || Colors.REVERSE == color -> {
|
||||
color + this + color
|
||||
} else {
|
||||
}
|
||||
else -> {
|
||||
color + this + Colors.NORMAL
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Makes the given string cyan.
|
||||
|
|
|
@ -129,7 +129,7 @@ class Ignore : AbstractCommand() {
|
|||
}
|
||||
}
|
||||
|
||||
if (ignored.size > 0) {
|
||||
if (ignored.isNotEmpty()) {
|
||||
event.sendMessage("The following nicks are ignored:")
|
||||
event.sendList(ignored.sorted(), 8, isIndent = true)
|
||||
} else {
|
||||
|
|
|
@ -85,19 +85,24 @@ class Tell(private val serialObject: String) : AbstractCommand() {
|
|||
|
||||
override fun commandResponse(channel: String, args: String, event: GenericMessageEvent) {
|
||||
if (isEnabled()) {
|
||||
if (args.isBlank()) {
|
||||
when {
|
||||
args.isBlank() -> {
|
||||
helpResponse(channel, args, event)
|
||||
} else if (args.startsWith(View.VIEW_CMD)) {
|
||||
}
|
||||
args.startsWith(View.VIEW_CMD) -> {
|
||||
if (event.isChannelOp(channel) && "${View.VIEW_CMD} $TELL_ALL_KEYWORD" == args) {
|
||||
viewAll(event)
|
||||
} else {
|
||||
viewMessages(event)
|
||||
}
|
||||
} else if (args.startsWith("$TELL_DEL_KEYWORD ")) {
|
||||
}
|
||||
args.startsWith("$TELL_DEL_KEYWORD ") -> {
|
||||
deleteMessage(channel, args, event)
|
||||
} else {
|
||||
}
|
||||
else -> {
|
||||
newMessage(channel, args, event)
|
||||
}
|
||||
}
|
||||
if (clean()) {
|
||||
save()
|
||||
}
|
||||
|
|
|
@ -141,7 +141,7 @@ class FeedsManager private constructor() {
|
|||
.append("\"><b>")
|
||||
.append(channel)
|
||||
.append("</b></a>")
|
||||
if (comments.size > 0) {
|
||||
if (comments.isNotEmpty()) {
|
||||
buff.append(" <br/><br/>")
|
||||
for (j in comments.indices) {
|
||||
if (j > 0) {
|
||||
|
|
|
@ -74,21 +74,26 @@ class CurrencyConverter : AbstractModule() {
|
|||
override fun commandResponse(channel: String, cmd: String, args: String, event: GenericMessageEvent) {
|
||||
reload(properties[API_KEY_PROP])
|
||||
|
||||
if (SYMBOLS.isEmpty()) {
|
||||
when {
|
||||
SYMBOLS.isEmpty() -> {
|
||||
event.respond(EMPTY_SYMBOLS_TABLE)
|
||||
} else if (args.matches("\\d+([,\\d]+)?(\\.\\d+)? [a-zA-Z]{3}+ (to|in) [a-zA-Z]{3}+".toRegex())) {
|
||||
}
|
||||
args.matches("\\d+([,\\d]+)?(\\.\\d+)? [a-zA-Z]{3}+ (to|in) [a-zA-Z]{3}+".toRegex()) -> {
|
||||
val msg = convertCurrency(properties[API_KEY_PROP], args)
|
||||
event.respond(msg.msg)
|
||||
if (msg.isError) {
|
||||
helpResponse(event)
|
||||
}
|
||||
} else if (args.contains(CODES_KEYWORD)) {
|
||||
}
|
||||
args.contains(CODES_KEYWORD) -> {
|
||||
event.sendMessage("The supported currency codes are:")
|
||||
event.sendList(SYMBOLS.keys.toList(), 11, isIndent = true)
|
||||
} else {
|
||||
}
|
||||
else -> {
|
||||
helpResponse(event)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun helpResponse(event: GenericMessageEvent): Boolean {
|
||||
reload(properties[API_KEY_PROP])
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue