Skip to content

Commit

Permalink
Updates so detektDebug passes
Browse files Browse the repository at this point in the history
  • Loading branch information
tcobbs-bentley committed Mar 11, 2024
1 parent 7492ba6 commit 95909e3
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ fun <K, V> Map<K, V>.getOptionalDouble(key: K) =
* `null`.
*/
inline fun <reified K: Any, reified V: Any> Map<*,*>.checkEntriesAre(): Map<K, V>? =
this.takeIf {
this.takeIf { _ ->
all { it.key is K && it.value is V }
}?.let {
@Suppress("UNCHECKED_CAST")
Expand All @@ -107,7 +107,7 @@ inline fun <reified K: Any, reified V: Any> Map<*,*>.ensureEntriesAre(): Map<K,
* @return The receiver specialized with `T` if the item types match, otherwise `null`.
*/
inline fun <reified T> List<*>.checkItemsAre(): List<T>? =
this.takeIf {
this.takeIf { _ ->
all { it is T }
}?.let {
@Suppress("UNCHECKED_CAST")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ abstract class ITMActionable(nativeUI: ITMNativeUI): ITMNativeUIComponent(native
style?.takeIf {
it.isNotEmpty()
}?.let {
Style.valueOf(style.replaceFirstChar { it.uppercase() })
Style.valueOf(it.replaceFirstChar { char -> char.uppercase() })
} ?: Default
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,14 @@ class ITMAlert(nativeUI: ITMNativeUI): ITMActionable(nativeUI) {
handler = coMessenger.registerQueryHandler("Bentley_ITM_presentAlert", ::handleQuery)
}

private fun toAlertActionsOrItems(actions: List<Action>): Pair<Array<Action?>, MutableList<CharSequence>?> {
private fun toAlertActionsOrItems(actions: List<Action>): Pair<Array<Action?>, List<CharSequence>?> {
var index = 0
var neutralAction: Action? = null
var negativeAction: Action? = null
var positiveAction: Action? = null
var items: MutableList<CharSequence>? = null
var items: List<CharSequence>? = null
if (actions.size > 3) {
items = mutableListOf()
actions.forEach {
items += it.styledTitle
}
items = actions.map { it.styledTitle }
} else {
// Note: The mapping of actions to buttons is documented in mobile-sdk-core.
if (actions.size == 3) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,8 @@ class JSONValue private constructor(value: Any?) {
*/
val anyValue: Any?
get() = when (value) {
is JSONObject -> objectValue!!.toMap()
is JSONArray -> arrayValue!!.toList()
is JSONObject -> objectValue?.toMap()
is JSONArray -> arrayValue?.toList()
else -> value
}

Expand Down Expand Up @@ -220,26 +220,26 @@ class JSONValue private constructor(value: Any?) {
* receiver is not an object, or the key does not exist, throws an exception. This allows the
* subscript operator to be directly used on [JSONValue].
*/
operator fun get(key: String): Any = objectValue!!.get(key)
operator fun get(key: String): Any = (objectValue as JSONObject).get(key)

/**
* If the receiver is an object, maps `name` to `value`, clobbering any name/value mapping with
* the same name.
* the same name. If the receiver is not an object, throws an exception.
*/
fun put(key: String, value: Any?): JSONObject = objectValue!!.put(key, value)
fun put(key: String, value: Any?): JSONObject = (objectValue as JSONObject).put(key, value)

/**
* If the receiver is an array, returns the value at the specified index in the array. If the
* receiver is not an array, throws an exception. This allows the subscript operator to be used
* directly on [JSONValue].
*/
operator fun get(index: Int): Any = arrayValue!!.get(index)
operator fun get(index: Int): Any = (arrayValue as JSONArray).get(index)

/**
* If the receiver is an array, sets the value at `index` to `value`, null-padding the array to
* the required length if necessary..
* the required length if necessary. If the receiver is not an array, throws an exception.
*/
fun put(index: Int, value: Any?): JSONArray = arrayValue!!.put(index, value)
fun put(index: Int, value: Any?): JSONArray = (arrayValue as JSONArray).put(index, value)

/**
* If the receiver is an object, returns the optional value of the specified key in the object
Expand Down

0 comments on commit 95909e3

Please sign in to comment.