diff options
27 files changed, 78 insertions, 51 deletions
diff --git a/kvision-modules/kvision-bootstrap-datetime/src/main/kotlin/pl/treksoft/kvision/form/time/DateTimeInput.kt b/kvision-modules/kvision-bootstrap-datetime/src/main/kotlin/pl/treksoft/kvision/form/time/DateTimeInput.kt index 178fbeaa..f9f170a9 100644 --- a/kvision-modules/kvision-bootstrap-datetime/src/main/kotlin/pl/treksoft/kvision/form/time/DateTimeInput.kt +++ b/kvision-modules/kvision-bootstrap-datetime/src/main/kotlin/pl/treksoft/kvision/form/time/DateTimeInput.kt @@ -241,8 +241,7 @@ open class DateTimeInput( override fun afterDestroy() { if (initialized) { - val comp = getElementJQueryD()?.data("DateTimePicker") - if (comp != null) comp.destroy() + getElementJQueryD()?.data("DateTimePicker")?.destroy() initialized = false } } @@ -314,6 +313,7 @@ open class DateTimeInput( private fun initEventHandlers() { this.getElementJQuery()?.on("dp.change") { e, _ -> val moment = e.asDynamic().date + @Suppress("UnsafeCastFromDynamic") if (moment) { this.value = moment.toDate() } else { diff --git a/kvision-modules/kvision-bootstrap-select/src/main/kotlin/pl/treksoft/kvision/KVManagerSelect.kt b/kvision-modules/kvision-bootstrap-select/src/main/kotlin/pl/treksoft/kvision/KVManagerSelect.kt index 09f92a0d..c1e7e244 100644 --- a/kvision-modules/kvision-bootstrap-select/src/main/kotlin/pl/treksoft/kvision/KVManagerSelect.kt +++ b/kvision-modules/kvision-bootstrap-select/src/main/kotlin/pl/treksoft/kvision/KVManagerSelect.kt @@ -50,7 +50,7 @@ internal object KVManagerSelect { require("./js/locales/ajax-bootstrap-select/ajax-bootstrap-select.sr-SP.min.js") require("./js/locales/ajax-bootstrap-select/ajax-bootstrap-select.tr-TR.min.js") js("$.fn.selectpicker.Constructor.BootstrapVersion = '4';") - js("$.fn.selectpicker.Constructor.DEFAULTS.styleBase = 'form-control';"); + js("$.fn.selectpicker.Constructor.DEFAULTS.styleBase = 'form-control';") js("$.fn.selectpicker.Constructor.DEFAULTS.style = '';") } diff --git a/kvision-modules/kvision-bootstrap/src/main/kotlin/pl/treksoft/kvision/dropdown/DropDown.kt b/kvision-modules/kvision-bootstrap/src/main/kotlin/pl/treksoft/kvision/dropdown/DropDown.kt index 342a8e84..891cd226 100644 --- a/kvision-modules/kvision-bootstrap/src/main/kotlin/pl/treksoft/kvision/dropdown/DropDown.kt +++ b/kvision-modules/kvision-bootstrap/src/main/kotlin/pl/treksoft/kvision/dropdown/DropDown.kt @@ -377,12 +377,10 @@ internal class DropDownButton( } override fun getSnClass(): List<StringBoolPair> { - return if (forNavbar) { - listOf("nav-link" to true, "dropdown-toggle" to true) - } else if (forDropDown) { - super.getSnClass() + listOf("dropdown-item" to true, "dropdown-toggle" to true) - } else { - super.getSnClass() + ("dropdown-toggle" to true) + return when { + forNavbar -> listOf("nav-link" to true, "dropdown-toggle" to true) + forDropDown -> super.getSnClass() + listOf("dropdown-item" to true, "dropdown-toggle" to true) + else -> super.getSnClass() + ("dropdown-toggle" to true) } } diff --git a/kvision-modules/kvision-bootstrap/src/main/kotlin/pl/treksoft/kvision/modal/Modal.kt b/kvision-modules/kvision-bootstrap/src/main/kotlin/pl/treksoft/kvision/modal/Modal.kt index 08fc7aa8..b064e30c 100644 --- a/kvision-modules/kvision-bootstrap/src/main/kotlin/pl/treksoft/kvision/modal/Modal.kt +++ b/kvision-modules/kvision-bootstrap/src/main/kotlin/pl/treksoft/kvision/modal/Modal.kt @@ -25,7 +25,6 @@ import com.github.snabbdom.VNode import pl.treksoft.kvision.core.Component import pl.treksoft.kvision.core.Container import pl.treksoft.kvision.core.StringBoolPair -import pl.treksoft.kvision.core.StringPair import pl.treksoft.kvision.core.Widget import pl.treksoft.kvision.html.Button import pl.treksoft.kvision.html.TAG diff --git a/kvision-modules/kvision-bootstrap/src/main/kotlin/pl/treksoft/kvision/navbar/Navbar.kt b/kvision-modules/kvision-bootstrap/src/main/kotlin/pl/treksoft/kvision/navbar/Navbar.kt index 92f8832d..68975f8d 100644 --- a/kvision-modules/kvision-bootstrap/src/main/kotlin/pl/treksoft/kvision/navbar/Navbar.kt +++ b/kvision-modules/kvision-bootstrap/src/main/kotlin/pl/treksoft/kvision/navbar/Navbar.kt @@ -29,7 +29,6 @@ import pl.treksoft.kvision.core.StringBoolPair import pl.treksoft.kvision.core.StringPair import pl.treksoft.kvision.html.Link import pl.treksoft.kvision.html.Span -import pl.treksoft.kvision.html.div import pl.treksoft.kvision.html.span import pl.treksoft.kvision.panel.SimplePanel diff --git a/kvision-modules/kvision-bootstrap/src/main/kotlin/pl/treksoft/kvision/window/Window.kt b/kvision-modules/kvision-bootstrap/src/main/kotlin/pl/treksoft/kvision/window/Window.kt index b993b649..861127fa 100644 --- a/kvision-modules/kvision-bootstrap/src/main/kotlin/pl/treksoft/kvision/window/Window.kt +++ b/kvision-modules/kvision-bootstrap/src/main/kotlin/pl/treksoft/kvision/window/Window.kt @@ -24,7 +24,6 @@ package pl.treksoft.kvision.window import com.github.snabbdom.VNode import org.w3c.dom.events.Event import org.w3c.dom.events.MouseEvent -import pl.treksoft.kvision.KVManager import pl.treksoft.kvision.KVManagerBootstrap import pl.treksoft.kvision.core.Component import pl.treksoft.kvision.core.Container diff --git a/kvision-modules/kvision-chart/src/main/kotlin/pl/treksoft/kvision/chart/Chart.kt b/kvision-modules/kvision-chart/src/main/kotlin/pl/treksoft/kvision/chart/Chart.kt index 29cc80c2..55718918 100644 --- a/kvision-modules/kvision-chart/src/main/kotlin/pl/treksoft/kvision/chart/Chart.kt +++ b/kvision-modules/kvision-chart/src/main/kotlin/pl/treksoft/kvision/chart/Chart.kt @@ -23,6 +23,7 @@ package pl.treksoft.kvision.chart import com.github.snabbdom.VNode import pl.treksoft.kvision.chart.js.Chart.ChartConfiguration +import pl.treksoft.kvision.chart.js.PluginServiceGlobalRegistration import pl.treksoft.kvision.chart.js.Chart as JsChart import pl.treksoft.kvision.core.Container import pl.treksoft.kvision.core.Widget @@ -112,11 +113,13 @@ open class Chart( companion object { fun registerPlugin(plugin: dynamic) { - JsChart.plugins.register(plugin) + @Suppress("UNCHECKED_CAST_TO_EXTERNAL_INTERFACE") + JsChart.plugins.register(plugin as PluginServiceGlobalRegistration) } fun unregisterPlugin(plugin: dynamic) { - JsChart.plugins.unregister(plugin) + @Suppress("UNCHECKED_CAST_TO_EXTERNAL_INTERFACE") + JsChart.plugins.unregister(plugin as PluginServiceGlobalRegistration) } } } diff --git a/kvision-modules/kvision-common-annotations/src/main/kotlin/pl/treksoft/kvision/annotations/Annotations.kt b/kvision-modules/kvision-common-annotations/src/main/kotlin/pl/treksoft/kvision/annotations/Annotations.kt index 02026f56..22cf570b 100644 --- a/kvision-modules/kvision-common-annotations/src/main/kotlin/pl/treksoft/kvision/annotations/Annotations.kt +++ b/kvision-modules/kvision-common-annotations/src/main/kotlin/pl/treksoft/kvision/annotations/Annotations.kt @@ -22,5 +22,4 @@ package pl.treksoft.kvision.annotations @Target(AnnotationTarget.CLASS) -annotation class KVService() - +annotation class KVService diff --git a/kvision-modules/kvision-cordova/src/main/kotlin/pl/treksoft/kvision/cordova/Battery.kt b/kvision-modules/kvision-cordova/src/main/kotlin/pl/treksoft/kvision/cordova/Battery.kt index 656a519a..8078353b 100644 --- a/kvision-modules/kvision-cordova/src/main/kotlin/pl/treksoft/kvision/cordova/Battery.kt +++ b/kvision-modules/kvision-cordova/src/main/kotlin/pl/treksoft/kvision/cordova/Battery.kt @@ -65,7 +65,7 @@ object Battery { */ suspend fun getStatus(): BatteryStatus { return suspendCoroutine { continuation -> - addStatusListener(Battery.BatteryEvent.BATTERY_STATUS) { status -> + addStatusListener(BatteryEvent.BATTERY_STATUS) { status -> continuation.resume(status) } } diff --git a/kvision-modules/kvision-cordova/src/main/kotlin/pl/treksoft/kvision/cordova/File.kt b/kvision-modules/kvision-cordova/src/main/kotlin/pl/treksoft/kvision/cordova/File.kt index 944042fa..5d24ac9f 100644 --- a/kvision-modules/kvision-cordova/src/main/kotlin/pl/treksoft/kvision/cordova/File.kt +++ b/kvision-modules/kvision-cordova/src/main/kotlin/pl/treksoft/kvision/cordova/File.kt @@ -169,8 +169,8 @@ object File { ): Result<FileSystem, FileException> { return suspendCoroutine { continuation -> val type = when (fileSystemType) { - File.FileSystemType.TEMPORARY -> LocalFileSystem.TEMPORARY - File.FileSystemType.PERSISTENT -> LocalFileSystem.PERSISTENT + FileSystemType.TEMPORARY -> LocalFileSystem.TEMPORARY + FileSystemType.PERSISTENT -> LocalFileSystem.PERSISTENT } addDeviceReadyListener { window.asDynamic().requestFileSystem(type, size, { fs -> diff --git a/kvision-modules/kvision-cordova/src/main/kotlin/pl/treksoft/kvision/cordova/MediaCapture.kt b/kvision-modules/kvision-cordova/src/main/kotlin/pl/treksoft/kvision/cordova/MediaCapture.kt index fda81da7..be291620 100644 --- a/kvision-modules/kvision-cordova/src/main/kotlin/pl/treksoft/kvision/cordova/MediaCapture.kt +++ b/kvision-modules/kvision-cordova/src/main/kotlin/pl/treksoft/kvision/cordova/MediaCapture.kt @@ -84,7 +84,7 @@ suspend fun MediaFile.getFormatData(): MediaFileData? { /** * Exception class for media capture errors. */ -class CaptureException(val code: MediaCapture.CaptureErrorCode) : Exception("Capture exception: $code") +class CaptureException(code: MediaCapture.CaptureErrorCode) : Exception("Capture exception: $code") /** * Main media capture object. diff --git a/kvision-modules/kvision-cordova/src/main/kotlin/pl/treksoft/kvision/cordova/Screen.kt b/kvision-modules/kvision-cordova/src/main/kotlin/pl/treksoft/kvision/cordova/Screen.kt index a33b2453..2ad009f9 100644 --- a/kvision-modules/kvision-cordova/src/main/kotlin/pl/treksoft/kvision/cordova/Screen.kt +++ b/kvision-modules/kvision-cordova/src/main/kotlin/pl/treksoft/kvision/cordova/Screen.kt @@ -65,7 +65,7 @@ object Screen { return Orientation.values().find { @Suppress("UnsafeCastFromDynamic") it.type == type - } ?: Screen.Orientation.ANY + } ?: Orientation.ANY } /** diff --git a/kvision-modules/kvision-pace/src/main/kotlin/pl/treksoft/kvision/pace/Pace.kt b/kvision-modules/kvision-pace/src/main/kotlin/pl/treksoft/kvision/pace/Pace.kt index 8905ce2c..3a732c1e 100644 --- a/kvision-modules/kvision-pace/src/main/kotlin/pl/treksoft/kvision/pace/Pace.kt +++ b/kvision-modules/kvision-pace/src/main/kotlin/pl/treksoft/kvision/pace/Pace.kt @@ -148,7 +148,10 @@ class PaceOptions( class Pace { companion object { - fun init(@Suppress("UNUSED_PARAMETER") req: dynamic = require("pace-progressbar/themes/blue/pace-theme-flash.css")) { + fun init( + @Suppress("UNUSED_PARAMETER") req: dynamic = + require("pace-progressbar/themes/blue/pace-theme-flash.css") + ) { } fun setOptions(options: PaceOptions) { diff --git a/kvision-modules/kvision-redux-kotlin/src/main/kotlin/pl/treksoft/kvision/redux/ReduxStore.kt b/kvision-modules/kvision-redux-kotlin/src/main/kotlin/pl/treksoft/kvision/redux/ReduxStore.kt index c4889567..7625ed7a 100644 --- a/kvision-modules/kvision-redux-kotlin/src/main/kotlin/pl/treksoft/kvision/redux/ReduxStore.kt +++ b/kvision-modules/kvision-redux-kotlin/src/main/kotlin/pl/treksoft/kvision/redux/ReduxStore.kt @@ -67,7 +67,7 @@ class ReduxStore<S : Any, A : RAction>( initialState: S, vararg middlewares: Middleware<S> ) : ObservableState<S> { - @Suppress("UNCHECKED_CAST") + @Suppress("UNCHECKED_CAST", "SpreadOperator") private val store: Store<S> = createStore({ s: S, a: Any -> if (a == ActionTypes.INIT || a == ActionTypes.REPLACE) { s diff --git a/kvision-modules/kvision-remote/src/main/kotlin/pl/treksoft/kvision/types/Date.kt b/kvision-modules/kvision-remote/src/main/kotlin/pl/treksoft/kvision/types/Date.kt index 90fdd2df..ca323264 100644 --- a/kvision-modules/kvision-remote/src/main/kotlin/pl/treksoft/kvision/types/Date.kt +++ b/kvision-modules/kvision-remote/src/main/kotlin/pl/treksoft/kvision/types/Date.kt @@ -57,6 +57,7 @@ internal object JsonDateSerializer : KSerializer<Date> { } } +@Suppress("ComplexMethod", "MagicNumber") internal fun String.toDateInternal(): Date { val dt = this.split(':', 'T', '-', '+') val utcCheck = this[length - 1] == 'Z' @@ -89,6 +90,7 @@ internal fun String.toDateInternal(): Date { } internal fun Date.toStringInternal(): String { + @Suppress("MagicNumber") val tz = this.getTimezoneOffset() / 60 val sign = if (tz > 0) "-" else "+" return "" + this.getFullYear() + "-" + ("0" + (this.getMonth() + 1)).takeLast(2) + "-" + diff --git a/kvision-modules/kvision-server-jooby/src/main/kotlin/pl/treksoft/kvision/remote/KVServiceManager.kt b/kvision-modules/kvision-server-jooby/src/main/kotlin/pl/treksoft/kvision/remote/KVServiceManager.kt index 6bb28059..bb682351 100644 --- a/kvision-modules/kvision-server-jooby/src/main/kotlin/pl/treksoft/kvision/remote/KVServiceManager.kt +++ b/kvision-modules/kvision-server-jooby/src/main/kotlin/pl/treksoft/kvision/remote/KVServiceManager.kt @@ -423,6 +423,7 @@ actual open class KVServiceManager<T : Any> actual constructor(val serviceClass: routes.add { call(HttpMethod.POST, "/kv/$routeDef") { req, res -> val jsonRpcRequest = req.body(JsonRpcRequest::class.java) + @Suppress("MagicNumber") if (jsonRpcRequest.params.size == 3) { val param1 = getParameter<String?>(jsonRpcRequest.params[0]) val param2 = getParameter<String?>(jsonRpcRequest.params[1]) diff --git a/kvision-modules/kvision-server-jooby/src/main/kotlin/pl/treksoft/kvision/types/Date.kt b/kvision-modules/kvision-server-jooby/src/main/kotlin/pl/treksoft/kvision/types/Date.kt index f041465b..58636fcc 100644 --- a/kvision-modules/kvision-server-jooby/src/main/kotlin/pl/treksoft/kvision/types/Date.kt +++ b/kvision-modules/kvision-server-jooby/src/main/kotlin/pl/treksoft/kvision/types/Date.kt @@ -87,6 +87,7 @@ class LocalDateTimeDeserializer : JsonDeserializer<LocalDateTime>() { override fun deserialize(p: JsonParser, ctx: DeserializationContext): LocalDateTime? { val str = p.text try { + @Suppress("MagicNumber") return LocalDateTime.parse(str.dropLast(6), DateTimeFormatter.ISO_LOCAL_DATE_TIME) } catch (e: DateTimeParseException) { System.err.println(e) @@ -113,6 +114,7 @@ class LocalDateDeserializer : JsonDeserializer<LocalDate>() { override fun deserialize(p: JsonParser, ctx: DeserializationContext): LocalDate? { val str = p.text try { + @Suppress("MagicNumber") return LocalDate.parse(str.dropLast(6), DateTimeFormatter.ISO_LOCAL_DATE_TIME) } catch (e: DateTimeParseException) { System.err.println(e) @@ -139,6 +141,7 @@ class LocalTimeDeserializer : JsonDeserializer<LocalTime>() { override fun deserialize(p: JsonParser, ctx: DeserializationContext): LocalTime? { val str = p.text try { + @Suppress("MagicNumber") return LocalTime.parse(str.dropLast(6), DateTimeFormatter.ISO_LOCAL_DATE_TIME) } catch (e: DateTimeParseException) { System.err.println(e) @@ -164,11 +167,11 @@ class OffsetDateTimeDeserializer : JsonDeserializer<OffsetDateTime>() { @Throws(IOException::class) override fun deserialize(p: JsonParser, ctx: DeserializationContext): OffsetDateTime? { val str = p.text - try { - return OffsetDateTime.parse(str, DateTimeFormatter.ISO_OFFSET_DATE_TIME) + return try { + OffsetDateTime.parse(str, DateTimeFormatter.ISO_OFFSET_DATE_TIME) } catch (e: DateTimeParseException) { System.err.println(e) - return null + null } } } @@ -190,11 +193,11 @@ class OffsetTimeDeserializer : JsonDeserializer<OffsetTime>() { @Throws(IOException::class) override fun deserialize(p: JsonParser, ctx: DeserializationContext): OffsetTime? { val str = p.text - try { - return OffsetTime.parse(str, DateTimeFormatter.ISO_OFFSET_DATE_TIME) + return try { + OffsetTime.parse(str, DateTimeFormatter.ISO_OFFSET_DATE_TIME) } catch (e: DateTimeParseException) { System.err.println(e) - return null + null } } } diff --git a/kvision-modules/kvision-server-ktor/src/main/kotlin/pl/treksoft/kvision/remote/KVServiceManager.kt b/kvision-modules/kvision-server-ktor/src/main/kotlin/pl/treksoft/kvision/remote/KVServiceManager.kt index 4d19e301..e4a48bc3 100644 --- a/kvision-modules/kvision-server-ktor/src/main/kotlin/pl/treksoft/kvision/remote/KVServiceManager.kt +++ b/kvision-modules/kvision-server-ktor/src/main/kotlin/pl/treksoft/kvision/remote/KVServiceManager.kt @@ -389,6 +389,7 @@ actual open class KVServiceManager<T : Any> actual constructor(val serviceClass: * @param function a function of the receiver * @param route a route */ + @Suppress("EmptyCatchBlock") protected actual inline fun <reified PAR1 : Any, reified PAR2 : Any> bind( noinline function: suspend T.(ReceiveChannel<PAR1>, SendChannel<PAR2>) -> Unit, route: String? @@ -449,6 +450,7 @@ actual open class KVServiceManager<T : Any> actual constructor(val serviceClass: addRoute(HttpMethod.POST, "/kv/$routeDef") { val service = call.injector.createChildInjector(DummyWsSessionModule()).getInstance(serviceClass.java) val jsonRpcRequest = call.receive<JsonRpcRequest>() + @Suppress("MagicNumber") if (jsonRpcRequest.params.size == 3) { val param1 = getParameter<String?>(jsonRpcRequest.params[0]) val param2 = getParameter<String?>(jsonRpcRequest.params[1]) diff --git a/kvision-modules/kvision-server-ktor/src/main/kotlin/pl/treksoft/kvision/types/Date.kt b/kvision-modules/kvision-server-ktor/src/main/kotlin/pl/treksoft/kvision/types/Date.kt index f041465b..58636fcc 100644 --- a/kvision-modules/kvision-server-ktor/src/main/kotlin/pl/treksoft/kvision/types/Date.kt +++ b/kvision-modules/kvision-server-ktor/src/main/kotlin/pl/treksoft/kvision/types/Date.kt @@ -87,6 +87,7 @@ class LocalDateTimeDeserializer : JsonDeserializer<LocalDateTime>() { override fun deserialize(p: JsonParser, ctx: DeserializationContext): LocalDateTime? { val str = p.text try { + @Suppress("MagicNumber") return LocalDateTime.parse(str.dropLast(6), DateTimeFormatter.ISO_LOCAL_DATE_TIME) } catch (e: DateTimeParseException) { System.err.println(e) @@ -113,6 +114,7 @@ class LocalDateDeserializer : JsonDeserializer<LocalDate>() { override fun deserialize(p: JsonParser, ctx: DeserializationContext): LocalDate? { val str = p.text try { + @Suppress("MagicNumber") return LocalDate.parse(str.dropLast(6), DateTimeFormatter.ISO_LOCAL_DATE_TIME) } catch (e: DateTimeParseException) { System.err.println(e) @@ -139,6 +141,7 @@ class LocalTimeDeserializer : JsonDeserializer<LocalTime>() { override fun deserialize(p: JsonParser, ctx: DeserializationContext): LocalTime? { val str = p.text try { + @Suppress("MagicNumber") return LocalTime.parse(str.dropLast(6), DateTimeFormatter.ISO_LOCAL_DATE_TIME) } catch (e: DateTimeParseException) { System.err.println(e) @@ -164,11 +167,11 @@ class OffsetDateTimeDeserializer : JsonDeserializer<OffsetDateTime>() { @Throws(IOException::class) override fun deserialize(p: JsonParser, ctx: DeserializationContext): OffsetDateTime? { val str = p.text - try { - return OffsetDateTime.parse(str, DateTimeFormatter.ISO_OFFSET_DATE_TIME) + return try { + OffsetDateTime.parse(str, DateTimeFormatter.ISO_OFFSET_DATE_TIME) } catch (e: DateTimeParseException) { System.err.println(e) - return null + null } } } @@ -190,11 +193,11 @@ class OffsetTimeDeserializer : JsonDeserializer<OffsetTime>() { @Throws(IOException::class) override fun deserialize(p: JsonParser, ctx: DeserializationContext): OffsetTime? { val str = p.text - try { - return OffsetTime.parse(str, DateTimeFormatter.ISO_OFFSET_DATE_TIME) + return try { + OffsetTime.parse(str, DateTimeFormatter.ISO_OFFSET_DATE_TIME) } catch (e: DateTimeParseException) { System.err.println(e) - return null + null } } } diff --git a/kvision-modules/kvision-server-spring-boot/src/main/kotlin/pl/treksoft/kvision/remote/KVServiceManager.kt b/kvision-modules/kvision-server-spring-boot/src/main/kotlin/pl/treksoft/kvision/remote/KVServiceManager.kt index 295ec8fb..fb6b6210 100644 --- a/kvision-modules/kvision-server-spring-boot/src/main/kotlin/pl/treksoft/kvision/remote/KVServiceManager.kt +++ b/kvision-modules/kvision-server-spring-boot/src/main/kotlin/pl/treksoft/kvision/remote/KVServiceManager.kt @@ -514,6 +514,7 @@ actual open class KVServiceManager<T : Any> actual constructor(val serviceClass: val service = ctx.getBean(serviceClass.java) initializeService(service, req) val jsonRpcRequest = req.awaitBody<JsonRpcRequest>() + @Suppress("MagicNumber") if (jsonRpcRequest.params.size == 3) { val param1 = getParameter<String?>(jsonRpcRequest.params[0]) val param2 = getParameter<String?>(jsonRpcRequest.params[1]) diff --git a/kvision-modules/kvision-server-spring-boot/src/main/kotlin/pl/treksoft/kvision/remote/Security.kt b/kvision-modules/kvision-server-spring-boot/src/main/kotlin/pl/treksoft/kvision/remote/Security.kt index 328e384d..7a9084dc 100644 --- a/kvision-modules/kvision-server-spring-boot/src/main/kotlin/pl/treksoft/kvision/remote/Security.kt +++ b/kvision-modules/kvision-server-spring-boot/src/main/kotlin/pl/treksoft/kvision/remote/Security.kt @@ -29,6 +29,7 @@ import org.springframework.security.web.server.util.matcher.ServerWebExchangeMat /** * A function to gather paths for spring security matchers. */ +@Suppress("SpreadOperator", "MaxLineLength") fun ServerHttpSecurity.AuthorizeExchangeSpec.serviceMatchers(vararg services: KVServiceManager<*>): ServerHttpSecurity.AuthorizeExchangeSpec.Access { return this.matchers(*getServerWebExchangeMatcher(*services)) } @@ -36,6 +37,7 @@ fun ServerHttpSecurity.AuthorizeExchangeSpec.serviceMatchers(vararg services: KV /** * A function to gather paths for spring security matchers. */ +@Suppress("SpreadOperator") fun serviceMatchers(vararg services: KVServiceManager<*>): ServerWebExchangeMatcher { return ServerWebExchangeMatchers.matchers(*getServerWebExchangeMatcher(*services)) } @@ -43,6 +45,7 @@ fun serviceMatchers(vararg services: KVServiceManager<*>): ServerWebExchangeMatc /** * A function to gather paths for spring security matchers. */ +@Suppress("SpreadOperator") fun getServerWebExchangeMatcher(vararg services: KVServiceManager<*>): Array<ServerWebExchangeMatcher> { val matchers = mutableListOf<ServerWebExchangeMatcher>() val getPaths = services.flatMap { it.getRequests.keys }.toTypedArray() diff --git a/kvision-modules/kvision-server-spring-boot/src/main/kotlin/pl/treksoft/kvision/types/Date.kt b/kvision-modules/kvision-server-spring-boot/src/main/kotlin/pl/treksoft/kvision/types/Date.kt index f041465b..58636fcc 100644 --- a/kvision-modules/kvision-server-spring-boot/src/main/kotlin/pl/treksoft/kvision/types/Date.kt +++ b/kvision-modules/kvision-server-spring-boot/src/main/kotlin/pl/treksoft/kvision/types/Date.kt @@ -87,6 +87,7 @@ class LocalDateTimeDeserializer : JsonDeserializer<LocalDateTime>() { override fun deserialize(p: JsonParser, ctx: DeserializationContext): LocalDateTime? { val str = p.text try { + @Suppress("MagicNumber") return LocalDateTime.parse(str.dropLast(6), DateTimeFormatter.ISO_LOCAL_DATE_TIME) } catch (e: DateTimeParseException) { System.err.println(e) @@ -113,6 +114,7 @@ class LocalDateDeserializer : JsonDeserializer<LocalDate>() { override fun deserialize(p: JsonParser, ctx: DeserializationContext): LocalDate? { val str = p.text try { + @Suppress("MagicNumber") return LocalDate.parse(str.dropLast(6), DateTimeFormatter.ISO_LOCAL_DATE_TIME) } catch (e: DateTimeParseException) { System.err.println(e) @@ -139,6 +141,7 @@ class LocalTimeDeserializer : JsonDeserializer<LocalTime>() { override fun deserialize(p: JsonParser, ctx: DeserializationContext): LocalTime? { val str = p.text try { + @Suppress("MagicNumber") return LocalTime.parse(str.dropLast(6), DateTimeFormatter.ISO_LOCAL_DATE_TIME) } catch (e: DateTimeParseException) { System.err.println(e) @@ -164,11 +167,11 @@ class OffsetDateTimeDeserializer : JsonDeserializer<OffsetDateTime>() { @Throws(IOException::class) override fun deserialize(p: JsonParser, ctx: DeserializationContext): OffsetDateTime? { val str = p.text - try { - return OffsetDateTime.parse(str, DateTimeFormatter.ISO_OFFSET_DATE_TIME) + return try { + OffsetDateTime.parse(str, DateTimeFormatter.ISO_OFFSET_DATE_TIME) } catch (e: DateTimeParseException) { System.err.println(e) - return null + null } } } @@ -190,11 +193,11 @@ class OffsetTimeDeserializer : JsonDeserializer<OffsetTime>() { @Throws(IOException::class) override fun deserialize(p: JsonParser, ctx: DeserializationContext): OffsetTime? { val str = p.text - try { - return OffsetTime.parse(str, DateTimeFormatter.ISO_OFFSET_DATE_TIME) + return try { + OffsetTime.parse(str, DateTimeFormatter.ISO_OFFSET_DATE_TIME) } catch (e: DateTimeParseException) { System.err.println(e) - return null + null } } } diff --git a/kvision-tools/kvision-compiler-plugin/src/main/kotlin/pl/treksoft/kvision/plugin/KVProcessor.kt b/kvision-tools/kvision-compiler-plugin/src/main/kotlin/pl/treksoft/kvision/plugin/KVProcessor.kt index bf01b463..eba66a9b 100644 --- a/kvision-tools/kvision-compiler-plugin/src/main/kotlin/pl/treksoft/kvision/plugin/KVProcessor.kt +++ b/kvision-tools/kvision-compiler-plugin/src/main/kotlin/pl/treksoft/kvision/plugin/KVProcessor.kt @@ -53,6 +53,7 @@ class KVProcessor : AbstractProcessor() { } } + @Suppress("MaxLineLength", "ComplexMethod", "NestedBlockDepth") override fun process(roundEnvironment: RoundEnvironment) { val isCommon = this.configuration.kotlinSourceRoots.find { !it.isCommon } == null if (isCommon) { @@ -85,8 +86,10 @@ class KVProcessor : AbstractProcessor() { appendln(" GlobalScope.launch(start = CoroutineStart.UNDISPATCHED) {") cl.methods().forEach { when { - it.returnType.toString().startsWith("RemoteData") -> appendln(" bindTabulatorRemote($iName::${it.name})") - it.returnType.toString() == "List<RemoteOption>" -> appendln(" bindSelectRemote($iName::${it.name})") + it.returnType.toString().startsWith("RemoteData") -> + appendln(" bindTabulatorRemote($iName::${it.name})") + it.returnType.toString() == "List<RemoteOption>" -> + appendln(" bindSelectRemote($iName::${it.name})") else -> appendln(" bind($iName::${it.name})") } } @@ -180,15 +183,15 @@ class KVProcessor : AbstractProcessor() { } private fun getParameterList(params: List<ParameterDescriptor>): String { - return params.map { + return params.joinToString(", ") { "${it.name.asString()}: ${it.type}" - }.joinToString(", ") + } } private fun getParameterNames(params: List<ParameterDescriptor>): String { - return params.map { + return params.joinToString(", ") { it.name.asString() - }.joinToString(", ") + } } private fun getTypes(type: KotlinType): Set<String> { diff --git a/src/main/kotlin/pl/treksoft/kvision/core/Widget.kt b/src/main/kotlin/pl/treksoft/kvision/core/Widget.kt index 9b3e9226..ad1bd626 100644 --- a/src/main/kotlin/pl/treksoft/kvision/core/Widget.kt +++ b/src/main/kotlin/pl/treksoft/kvision/core/Widget.kt @@ -445,7 +445,9 @@ open class Widget(classes: Set<String> = setOf()) : StyledComponent(), Component open fun enableTooltip(options: TooltipOptions = TooltipOptions()): Widget { this.tooltipOptions = options val tooltipFun = getElementJQueryD()?.tooltip - if (tooltipFun != undefined) getElementJQueryD()?.tooltip(options.copy(title = options.title?.let { translate(it) }).toJs()) + if (tooltipFun != undefined) getElementJQueryD()?.tooltip( + options.copy(title = options.title?.let { translate(it) }).toJs() + ) return this } @@ -638,7 +640,9 @@ open class Widget(classes: Set<String> = setOf()) : StyledComponent(), Component this.tooltipOptions?.let { @Suppress("UnsafeCastFromDynamic") val tooltipFun = getElementJQueryD()?.tooltip - if (tooltipFun != undefined) getElementJQueryD()?.tooltip(it.copy(title = it.title?.let { translate(it) }).toJs()) + if (tooltipFun != undefined) getElementJQueryD()?.tooltip( + it.copy(title = it.title?.let { translate(it) }).toJs() + ) } this.popoverOptions?.let { @Suppress("UnsafeCastFromDynamic") diff --git a/src/main/kotlin/pl/treksoft/kvision/html/List.kt b/src/main/kotlin/pl/treksoft/kvision/html/List.kt index af8957ce..cdd18cfc 100644 --- a/src/main/kotlin/pl/treksoft/kvision/html/List.kt +++ b/src/main/kotlin/pl/treksoft/kvision/html/List.kt @@ -94,7 +94,7 @@ open class ListTag( } } - @Suppress("ComplexCondition") + @Suppress("ComplexCondition", "ComplexMethod") override fun childrenVNodes(): Array<VNode> { val childrenElements = children.filter { it.visible } val res = when (type) { diff --git a/src/main/kotlin/pl/treksoft/kvision/panel/Root.kt b/src/main/kotlin/pl/treksoft/kvision/panel/Root.kt index 111d4738..8847a3c6 100644 --- a/src/main/kotlin/pl/treksoft/kvision/panel/Root.kt +++ b/src/main/kotlin/pl/treksoft/kvision/panel/Root.kt @@ -222,6 +222,7 @@ class Root : SimplePanel { * @param init an initializer extension function * @return the created Root container */ +@Suppress("unused") fun Application.root(id: String, fixed: Boolean = false, init: Root.() -> Unit): Root { return Root(id, fixed, init) } @@ -234,6 +235,7 @@ fun Application.root(id: String, fixed: Boolean = false, init: Root.() -> Unit): * @param init an initializer extension function * @return the created Root container */ +@Suppress("unused") fun Application.root(element: HTMLElement, fixed: Boolean = false, init: Root.() -> Unit): Root { return Root(element, fixed, init) } diff --git a/src/main/kotlin/pl/treksoft/kvision/table/Table.kt b/src/main/kotlin/pl/treksoft/kvision/table/Table.kt index 114e3dfa..6c48157d 100644 --- a/src/main/kotlin/pl/treksoft/kvision/table/Table.kt +++ b/src/main/kotlin/pl/treksoft/kvision/table/Table.kt @@ -70,7 +70,7 @@ enum class TheadType(internal val type: String) { * @param headerNames a list of table headers names * @param types a set of table types * @param caption table caption - * @param responsive determines if the table is responsive + * @param responsiveType determines if the table is responsive * @param classes a set of CSS class names * @param init an initializer extension function */ |