From d379a31eebffc8b951a7266b1b8f1ad6d505afa7 Mon Sep 17 00:00:00 2001 From: Sean Li Date: Thu, 8 Feb 2024 15:36:20 -0800 Subject: [PATCH] bumping ktlint and resolving conflicts (#1792) (#1794) Signed-off-by: Sean Li (cherry picked from commit 34f64904519b0f2d57eb3587ccbd1e58dc9a3ebb) --- build.gradle | 3 ++- .../observability/ObservabilityPlugin.kt | 2 +- .../observability/metrics/Metrics.kt | 17 +++++++----- .../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, 45 insertions(+), 27 deletions(-) diff --git a/build.gradle b/build.gradle index 73a037fa1..d6908daaa 100644 --- a/build.gradle +++ b/build.gradle @@ -154,6 +154,7 @@ configurations.all { force "com.fasterxml.jackson.dataformat:jackson-dataformat-cbor:${jackson_version}" force "org.mockito:mockito-core:4.6.1" force "org.yaml:snakeyaml:2.0" + force "org.slf4j:slf4j-api:2.0.0" } } @@ -212,7 +213,7 @@ dependencies { testImplementation "org.mockito:mockito-junit-jupiter:4.3.1" 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 4af2d6dec..98832d2bd 100644 --- a/src/main/kotlin/org/opensearch/observability/ObservabilityPlugin.kt +++ b/src/main/kotlin/org/opensearch/observability/ObservabilityPlugin.kt @@ -98,7 +98,7 @@ class ObservabilityPlugin : Plugin(), ActionPlugin, ClusterPlugin { ): 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 584ca8300..3ce790728 100644 --- a/src/main/kotlin/org/opensearch/observability/metrics/Metrics.kt +++ b/src/main/kotlin/org/opensearch/observability/metrics/Metrics.kt @@ -30,19 +30,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() ), // ==== REST endpoint metrics ==== // @@ -155,6 +160,6 @@ enum class Metrics(val metricName: String, val counter: Counter<*>) { */ enum class Action { CREATE, - UPDATE, + UPDATE } } 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 4e8a3ea0f..ef21b4391 100644 --- a/src/test/kotlin/org/opensearch/observability/PluginRestTestCase.kt +++ b/src/test/kotlin/org/opensearch/observability/PluginRestTestCase.kt @@ -78,7 +78,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.value) 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 """