From 4816f60a63b9224921aba26c7eba065c3116c0e8 Mon Sep 17 00:00:00 2001 From: Sean Li Date: Tue, 6 Feb 2024 14:34:50 -0800 Subject: [PATCH] bumping ktlint and resolving conflicts Signed-off-by: Sean Li --- build.gradle | 3 ++- .../observability/ObservabilityPlugin.kt | 2 +- .../observability/metrics/Metrics.kt | 15 +++++++---- .../observability/model/SavedQuery.kt | 4 +-- .../observability/model/SavedVisualization.kt | 12 ++++----- .../observability/model/Timestamp.kt | 2 +- .../observability/settings/PluginSettings.kt | 27 ++++++++++++------- .../observability/PluginRestTestCase.kt | 3 ++- .../opensearch/observability/TestHelpers.kt | 2 ++ 9 files changed, 44 insertions(+), 26 deletions(-) diff --git a/build.gradle b/build.gradle index c9963f929..41e6cdae9 100644 --- a/build.gradle +++ b/build.gradle @@ -129,6 +129,7 @@ configurations.all { force "com.fasterxml.jackson.dataformat:jackson-dataformat-cbor:${versions.jackson}" force "org.mockito:mockito-core:${versions.mockito}" force "org.yaml:snakeyaml:${versions.snakeyaml}" + force "org.slf4j:slf4j-api:2.0.0" } } @@ -187,7 +188,7 @@ dependencies { testImplementation "org.mockito:mockito-junit-jupiter:${versions.mockito}" testImplementation "com.google.code.gson:gson:2.8.9" - ktlint "com.pinterest:ktlint:0.45.0" + ktlint "com.pinterest:ktlint:0.47.1" } javadoc.enabled = false // turn off javadoc as it barfs on Kotlin code diff --git a/src/main/kotlin/org/opensearch/observability/ObservabilityPlugin.kt b/src/main/kotlin/org/opensearch/observability/ObservabilityPlugin.kt index c6a30c81e..1c27612f1 100644 --- a/src/main/kotlin/org/opensearch/observability/ObservabilityPlugin.kt +++ b/src/main/kotlin/org/opensearch/observability/ObservabilityPlugin.kt @@ -92,7 +92,7 @@ class ObservabilityPlugin : Plugin(), ActionPlugin { ): List { return listOf( ObservabilityRestHandler(), - ObservabilityStatsRestHandler(), + ObservabilityStatsRestHandler() ) } diff --git a/src/main/kotlin/org/opensearch/observability/metrics/Metrics.kt b/src/main/kotlin/org/opensearch/observability/metrics/Metrics.kt index 07b310e2e..01ac57cfd 100644 --- a/src/main/kotlin/org/opensearch/observability/metrics/Metrics.kt +++ b/src/main/kotlin/org/opensearch/observability/metrics/Metrics.kt @@ -27,19 +27,24 @@ enum class Metrics(val metricName: String, val counter: Counter<*>) { OBSERVABILITY_EXCEPTIONS_VERSION_CONFLICT_ENGINE_EXCEPTION("exception.version_conflict_engine", RollingCounter()), OBSERVABILITY_EXCEPTIONS_INDEX_NOT_FOUND_EXCEPTION("exception.index_not_found", RollingCounter()), OBSERVABILITY_EXCEPTIONS_INVALID_INDEX_NAME_EXCEPTION( - "exception.invalid_index_name", RollingCounter() + "exception.invalid_index_name", + RollingCounter() ), OBSERVABILITY_EXCEPTIONS_ILLEGAL_ARGUMENT_EXCEPTION( - "exception.illegal_argument", RollingCounter() + "exception.illegal_argument", + RollingCounter() ), OBSERVABILITY_EXCEPTIONS_ILLEGAL_STATE_EXCEPTION( - "exception.illegal_state", RollingCounter() + "exception.illegal_state", + RollingCounter() ), OBSERVABILITY_EXCEPTIONS_IO_EXCEPTION( - "exception.io", RollingCounter() + "exception.io", + RollingCounter() ), OBSERVABILITY_EXCEPTIONS_INTERNAL_SERVER_ERROR( - "exception.internal_server_error", RollingCounter() + "exception.internal_server_error", + RollingCounter() ), OBSERVABILITY_SECURITY_PERMISSION_ERROR("security_permission_error", RollingCounter()), diff --git a/src/main/kotlin/org/opensearch/observability/model/SavedQuery.kt b/src/main/kotlin/org/opensearch/observability/model/SavedQuery.kt index 37a7b00e2..8dc655dd3 100644 --- a/src/main/kotlin/org/opensearch/observability/model/SavedQuery.kt +++ b/src/main/kotlin/org/opensearch/observability/model/SavedQuery.kt @@ -241,7 +241,7 @@ internal data class SavedQuery( internal data class Token( val name: String, - val type: String, + val type: String ) : BaseModel { internal companion object { private const val NAME_TAG = "name" @@ -291,7 +291,7 @@ internal data class SavedQuery( */ constructor(input: StreamInput) : this( name = input.readString(), - type = input.readString(), + type = input.readString() ) /** diff --git a/src/main/kotlin/org/opensearch/observability/model/SavedVisualization.kt b/src/main/kotlin/org/opensearch/observability/model/SavedVisualization.kt index 0dbd09956..a29f00624 100644 --- a/src/main/kotlin/org/opensearch/observability/model/SavedVisualization.kt +++ b/src/main/kotlin/org/opensearch/observability/model/SavedVisualization.kt @@ -69,7 +69,7 @@ internal data class SavedVisualization( val subType: String?, val metricType: String? = null, val unitsOfMeasure: String? = null, - val selectedLabels: SelectedLabels? = null, + val selectedLabels: SelectedLabels? = null ) : BaseObjectData { internal companion object { @@ -155,7 +155,7 @@ internal data class SavedVisualization( subType, metricType, unitsOfMeasure, - selectedLabels, + selectedLabels ) } } @@ -186,7 +186,7 @@ internal data class SavedVisualization( subType = input.readString(), metricType = input.readOptionalString(), unitsOfMeasure = input.readOptionalString(), - selectedLabels = input.readOptionalWriteable(SelectedLabels.reader), + selectedLabels = input.readOptionalWriteable(SelectedLabels.reader) ) /** @@ -231,7 +231,7 @@ internal data class SavedVisualization( } internal data class Token( - val label: String, + val label: String ) : BaseModel { internal companion object { private const val LABEL_TAG = "label" @@ -276,7 +276,7 @@ internal data class SavedVisualization( * @param input StreamInput stream to deserialize data from. */ constructor(input: StreamInput) : this( - label = input.readString(), + label = input.readString() ) /** @@ -299,7 +299,7 @@ internal data class SavedVisualization( } internal data class SelectedLabels( - val labels: List?, + val labels: List? ) : BaseModel { internal companion object { private const val LABELS_TAG = "labels" diff --git a/src/main/kotlin/org/opensearch/observability/model/Timestamp.kt b/src/main/kotlin/org/opensearch/observability/model/Timestamp.kt index c5c5cd7f5..ad0b2a3d2 100644 --- a/src/main/kotlin/org/opensearch/observability/model/Timestamp.kt +++ b/src/main/kotlin/org/opensearch/observability/model/Timestamp.kt @@ -34,7 +34,7 @@ internal data class Timestamp( val name: String?, val index: String?, val type: String?, - val dslType: String?, + val dslType: String? ) : BaseObjectData { internal companion object { diff --git a/src/main/kotlin/org/opensearch/observability/settings/PluginSettings.kt b/src/main/kotlin/org/opensearch/observability/settings/PluginSettings.kt index 6f99371ef..9a95f0a56 100644 --- a/src/main/kotlin/org/opensearch/observability/settings/PluginSettings.kt +++ b/src/main/kotlin/org/opensearch/observability/settings/PluginSettings.kt @@ -283,61 +283,70 @@ internal object PluginSettings { OPERATION_TIMEOUT_MS_KEY, defaultSettings[OPERATION_TIMEOUT_MS_KEY]!!.toLong(), MINIMUM_OPERATION_TIMEOUT_MS, - NodeScope, Dynamic + NodeScope, + Dynamic ) private val JOB_LOCK_DURATION_S: Setting = Setting.intSetting( JOB_LOCK_DURATION_S_KEY, defaultSettings[JOB_LOCK_DURATION_S_KEY]!!.toInt(), MINIMUM_JOB_LOCK_DURATION_S, - NodeScope, Dynamic + NodeScope, + Dynamic ) private val MIN_POLLING_DURATION_S: Setting = Setting.intSetting( MIN_POLLING_DURATION_S_KEY, defaultSettings[MIN_POLLING_DURATION_S_KEY]!!.toInt(), MINIMUM_MIN_POLLING_DURATION_S, - NodeScope, Dynamic + NodeScope, + Dynamic ) private val MAX_POLLING_DURATION_S: Setting = Setting.intSetting( MAX_POLLING_DURATION_S_KEY, defaultSettings[MAX_POLLING_DURATION_S_KEY]!!.toInt(), MINIMUM_MAX_POLLING_DURATION_S, - NodeScope, Dynamic + NodeScope, + Dynamic ) private val MAX_LOCK_RETRIES: Setting = Setting.intSetting( MAX_LOCK_RETRIES_KEY, defaultSettings[MAX_LOCK_RETRIES_KEY]!!.toInt(), MINIMUM_LOCK_RETRIES, - NodeScope, Dynamic + NodeScope, + Dynamic ) private val DEFAULT_ITEMS_QUERY_COUNT: Setting = Setting.intSetting( DEFAULT_ITEMS_QUERY_COUNT_KEY, defaultSettings[DEFAULT_ITEMS_QUERY_COUNT_KEY]!!.toInt(), MINIMUM_ITEMS_QUERY_COUNT, - NodeScope, Dynamic + NodeScope, + Dynamic ) private val ADMIN_ACCESS: Setting = Setting.simpleString( ADMIN_ACCESS_KEY, defaultSettings[ADMIN_ACCESS_KEY]!!, - NodeScope, Dynamic + NodeScope, + Dynamic ) private val FILTER_BY: Setting = Setting.simpleString( FILTER_BY_KEY, defaultSettings[FILTER_BY_KEY]!!, - NodeScope, Dynamic + NodeScope, + Dynamic ) private val IGNORED_ROLES: Setting> = Setting.listSetting( IGNORE_ROLE_KEY, DEFAULT_IGNORED_ROLES, { it }, - NodeScope, Dynamic + NodeScope, + Dynamic ) /** diff --git a/src/test/kotlin/org/opensearch/observability/PluginRestTestCase.kt b/src/test/kotlin/org/opensearch/observability/PluginRestTestCase.kt index 680c2067b..91ffe7e59 100644 --- a/src/test/kotlin/org/opensearch/observability/PluginRestTestCase.kt +++ b/src/test/kotlin/org/opensearch/observability/PluginRestTestCase.kt @@ -62,7 +62,8 @@ abstract class PluginRestTestCase : OpenSearchRestTestCase() { val response = client().performRequest(Request("GET", "/_cat/indices?format=json&expand_wildcards=all")) val xContentType = MediaType.fromMediaType(response.entity.contentType) xContentType.xContent().createParser( - NamedXContentRegistry.EMPTY, DeprecationHandler.THROW_UNSUPPORTED_OPERATION, + NamedXContentRegistry.EMPTY, + DeprecationHandler.THROW_UNSUPPORTED_OPERATION, response.entity.content ).use { parser -> for (index in parser.list()) { diff --git a/src/test/kotlin/org/opensearch/observability/TestHelpers.kt b/src/test/kotlin/org/opensearch/observability/TestHelpers.kt index 7815ccaeb..fea533a53 100644 --- a/src/test/kotlin/org/opensearch/observability/TestHelpers.kt +++ b/src/test/kotlin/org/opensearch/observability/TestHelpers.kt @@ -73,6 +73,7 @@ fun constructNotebookRequest(name: String = "test notebook"): String { } """.trimIndent() } + @Suppress("MaxLineLength") fun constructSavedQueryRequest(name: String = "test saved query"): String { return """ @@ -101,6 +102,7 @@ fun constructSavedQueryRequest(name: String = "test saved query"): String { } """.trimIndent() } + @Suppress("MaxLineLength") fun constructSavedVisualizationRequest(name: String = "test saved visualization"): String { return """