Skip to content

Commit 49da816

Browse files
authored
[Backport 2.x] bump ktlint 1.1.0 to 1.5.0 (#1338)
* bump ktlint from 1.1.0 to 1.5.0 (#1336) Signed-off-by: Shivansh Arora <hishiv@amazon.com> * appease ktlint Signed-off-by: Shivansh Arora <hishiv@amazon.com> . Signed-off-by: Shivansh Arora <hishiv@amazon.com> --------- Signed-off-by: Shivansh Arora <hishiv@amazon.com>
1 parent a4a3188 commit 49da816

File tree

237 files changed

+1946
-2606
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

237 files changed

+1946
-2606
lines changed

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ dependencies {
216216
testImplementation "com.nhaarman.mockitokotlin2:mockito-kotlin:2.2.0"
217217
testImplementation "org.mockito:mockito-core:${versions.mockito}"
218218

219-
add("ktlint", "com.pinterest.ktlint:ktlint-cli:1.1.0") {
219+
add("ktlint", "com.pinterest.ktlint:ktlint-cli:1.5.0") {
220220
attributes {
221221
attribute(Bundling.BUNDLING_ATTRIBUTE, objects.named(Bundling, Bundling.EXTERNAL))
222222
}

spi/src/main/kotlin/org.opensearch.indexmanagement.spi/IndexManagementExtension.kt

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,7 @@ interface IndexManagementExtension {
2727
* should represent if the extension is enabled or disabled, and should not represent extension health or the availability of some extension
2828
* dependency.
2929
*/
30-
fun statusChecker(): StatusChecker {
31-
return DefaultStatusChecker()
32-
}
30+
fun statusChecker(): StatusChecker = DefaultStatusChecker()
3331

3432
/**
3533
* Name of the extension
@@ -41,17 +39,13 @@ interface IndexManagementExtension {
4139
* indices provide the metadata service that can provide the index metadata for these indices. An extension need to label the metadata service
4240
* with a type string which is used to distinguish indices in IndexManagement plugin
4341
*/
44-
fun getIndexMetadataService(): Map<String, IndexMetadataService> {
45-
return mapOf()
46-
}
42+
fun getIndexMetadataService(): Map<String, IndexMetadataService> = mapOf()
4743

4844
/**
4945
* Caution: Experimental and can be removed in future
5046
*
5147
* If extension wants IndexManagement to determine cluster state indices UUID based on custom index setting if
5248
* present of cluster state override this method.
5349
*/
54-
fun overrideClusterStateIndexUuidSetting(): String? {
55-
return null
56-
}
50+
fun overrideClusterStateIndexUuidSetting(): String? = null
5751
}

spi/src/main/kotlin/org.opensearch.indexmanagement.spi/indexstatemanagement/Action.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ import java.time.Instant
2020
abstract class Action(
2121
val type: String,
2222
val actionIndex: Int,
23-
) : ToXContentObject, Writeable {
23+
) : ToXContentObject,
24+
Writeable {
2425

2526
var configTimeout: ActionTimeout? = null
2627
var configRetry: ActionRetry? = ActionRetry(DEFAULT_RETRIES)

spi/src/main/kotlin/org.opensearch.indexmanagement.spi/indexstatemanagement/StatusChecker.kt

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,15 @@ interface StatusChecker {
1212
/**
1313
* checks and returns the status of the extension
1414
*/
15-
fun check(clusterState: ClusterState): Status {
16-
return Status.ENABLED
17-
}
15+
fun check(clusterState: ClusterState): Status = Status.ENABLED
1816
}
1917

2018
enum class Status(private val value: String) {
2119
ENABLED("enabled"),
2220
DISABLED("disabled"),
2321
;
2422

25-
override fun toString(): String {
26-
return value
27-
}
23+
override fun toString(): String = value
2824
}
2925

3026
class DefaultStatusChecker : StatusChecker

spi/src/main/kotlin/org.opensearch.indexmanagement.spi/indexstatemanagement/Step.kt

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -38,16 +38,14 @@ abstract class Step(val name: String, val isSafeToDisableOn: Boolean = true) {
3838

3939
abstract fun isIdempotent(): Boolean
4040

41-
final fun getStepStartTime(metadata: ManagedIndexMetaData): Instant {
42-
return when {
43-
metadata.stepMetaData == null -> Instant.now()
44-
metadata.stepMetaData.name != this.name -> Instant.now()
45-
// The managed index metadata is a historical snapshot of the metadata and refers to what has happened from the previous
46-
// execution, so if we ever see it as COMPLETED it means we are always going to be in a new step, this specifically
47-
// helps with the Transition -> Transition (empty state) sequence which the above do not capture
48-
metadata.stepMetaData.stepStatus == StepStatus.COMPLETED -> Instant.now()
49-
else -> Instant.ofEpochMilli(metadata.stepMetaData.startTime)
50-
}
41+
final fun getStepStartTime(metadata: ManagedIndexMetaData): Instant = when {
42+
metadata.stepMetaData == null -> Instant.now()
43+
metadata.stepMetaData.name != this.name -> Instant.now()
44+
// The managed index metadata is a historical snapshot of the metadata and refers to what has happened from the previous
45+
// execution, so if we ever see it as COMPLETED it means we are always going to be in a new step, this specifically
46+
// helps with the Transition -> Transition (empty state) sequence which the above do not capture
47+
metadata.stepMetaData.stepStatus == StepStatus.COMPLETED -> Instant.now()
48+
else -> Instant.ofEpochMilli(metadata.stepMetaData.startTime)
5149
}
5250

5351
final fun getStartingStepMetaData(metadata: ManagedIndexMetaData): StepMetaData = StepMetaData(name, getStepStartTime(metadata).toEpochMilli(), StepStatus.STARTING)
@@ -60,18 +58,14 @@ abstract class Step(val name: String, val isSafeToDisableOn: Boolean = true) {
6058
TIMED_OUT("timed_out"),
6159
;
6260

63-
override fun toString(): String {
64-
return status
65-
}
61+
override fun toString(): String = status
6662

6763
override fun writeTo(out: StreamOutput) {
6864
out.writeString(status)
6965
}
7066

7167
companion object {
72-
fun read(streamInput: StreamInput): StepStatus {
73-
return valueOf(streamInput.readString().uppercase(Locale.ROOT))
74-
}
68+
fun read(streamInput: StreamInput): StepStatus = valueOf(streamInput.readString().uppercase(Locale.ROOT))
7569
}
7670
}
7771
}

spi/src/main/kotlin/org.opensearch.indexmanagement.spi/indexstatemanagement/Validate.kt

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,18 +30,14 @@ abstract class Validate(
3030
FAILED("failed"),
3131
;
3232

33-
override fun toString(): String {
34-
return status
35-
}
33+
override fun toString(): String = status
3634

3735
override fun writeTo(out: StreamOutput) {
3836
out.writeString(status)
3937
}
4038

4139
companion object {
42-
fun read(streamInput: StreamInput): ValidationStatus {
43-
return valueOf(streamInput.readString().uppercase(Locale.ROOT))
44-
}
40+
fun read(streamInput: StreamInput): ValidationStatus = valueOf(streamInput.readString().uppercase(Locale.ROOT))
4541
}
4642
}
4743
}

spi/src/main/kotlin/org.opensearch.indexmanagement.spi/indexstatemanagement/model/ActionMetaData.kt

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ data class ActionMetaData(
3030
val consumedRetries: Int,
3131
val lastRetryTime: Long?,
3232
val actionProperties: ActionProperties?,
33-
) : Writeable, ToXContentFragment {
33+
) : Writeable,
34+
ToXContentFragment {
3435

3536
override fun writeTo(out: StreamOutput) {
3637
out.writeString(name)
@@ -61,9 +62,7 @@ data class ActionMetaData(
6162
return builder
6263
}
6364

64-
fun getMapValueString(): String {
65-
return Strings.toString(XContentType.JSON, this)
66-
}
65+
fun getMapValueString(): String = Strings.toString(XContentType.JSON, this)
6766

6867
companion object {
6968
const val ACTION = "action"

spi/src/main/kotlin/org.opensearch.indexmanagement.spi/indexstatemanagement/model/ActionProperties.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ data class ActionProperties(
2525
val hasRollupFailed: Boolean? = null,
2626
val shrinkActionProperties: ShrinkActionProperties? = null,
2727
val transformActionProperties: TransformActionProperties? = null,
28-
) : Writeable, ToXContentFragment {
28+
) : Writeable,
29+
ToXContentFragment {
2930

3031
override fun writeTo(out: StreamOutput) {
3132
out.writeOptionalInt(maxNumSegments)

spi/src/main/kotlin/org.opensearch.indexmanagement.spi/indexstatemanagement/model/ActionRetry.kt

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ data class ActionRetry(
2424
val count: Long,
2525
val backoff: Backoff = Backoff.EXPONENTIAL,
2626
val delay: TimeValue = TimeValue.timeValueMinutes(1),
27-
) : ToXContentFragment, Writeable {
27+
) : ToXContentFragment,
28+
Writeable {
2829

2930
init {
3031
require(count >= 0) { "Count for ActionRetry must be a non-negative number" }
@@ -110,9 +111,7 @@ data class ActionRetry(
110111

111112
private val logger = LogManager.getLogger(javaClass)
112113

113-
override fun toString(): String {
114-
return type
115-
}
114+
override fun toString(): String = type
116115

117116
@Suppress("ReturnCount")
118117
fun shouldBackoff(actionMetaData: ActionMetaData?, actionRetry: ActionRetry?): Pair<Boolean, Long?> {

spi/src/main/kotlin/org.opensearch.indexmanagement.spi/indexstatemanagement/model/ActionTimeout.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@ import org.opensearch.core.xcontent.XContentBuilder
1515
import org.opensearch.core.xcontent.XContentParser
1616
import java.io.IOException
1717

18-
data class ActionTimeout(val timeout: TimeValue) : ToXContentFragment, Writeable {
18+
data class ActionTimeout(val timeout: TimeValue) :
19+
ToXContentFragment,
20+
Writeable {
1921

20-
override fun toXContent(builder: XContentBuilder, params: ToXContent.Params): XContentBuilder {
21-
return builder.field(TIMEOUT_FIELD, timeout.stringRep)
22-
}
22+
override fun toXContent(builder: XContentBuilder, params: ToXContent.Params): XContentBuilder = builder.field(TIMEOUT_FIELD, timeout.stringRep)
2323

2424
@Throws(IOException::class)
2525
constructor(sin: StreamInput) : this(

0 commit comments

Comments
 (0)