Skip to content

Commit 5f8891b

Browse files
committed
lint: add rules and apply formatting
Signed-off-by: Rohit Ashiwal <rashiwal@amazon.com>
1 parent 2b8991f commit 5f8891b

File tree

515 files changed

+14166
-12333
lines changed

Some content is hidden

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

515 files changed

+14166
-12333
lines changed

.editorconfig

+10-3
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,16 @@
33
root = true
44

55
[*.{kt,kts}]
6+
ktlint_code_style = intellij_idea
67
# we have detekt also checking for max line length. Disable the linter and use only one tool to check for max line length.
7-
88
# See https://github.com/arturbosch/detekt
9-
max_line_length=off
9+
ktlint_standard_max-line-length = disabled
10+
ktlint_ignore_back_ticked_identifier = true
11+
12+
ktlint_standard_function-naming = disabled
13+
ktlint_standard_property-naming = disabled
14+
ktlint_standard_function-signature = disabled
15+
ktlint_standard_value-argument-comment = disabled
16+
ktlint_standard_argument-list-wrapping = disabled
17+
ktlint_standard_value-parameter-comment = disabled
1018

11-
disabled_rules=import-ordering

detekt.yml

+2-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ style:
1111
ForbiddenComment:
1212
active: false
1313
MaxLineLength:
14-
maxLineLength: 150
14+
maxLineLength: 160
1515
excludes: ['**/test/**']
1616
FunctionOnlyReturningConstant:
1717
active: false
@@ -20,6 +20,7 @@ complexity:
2020
LargeClass:
2121
excludes: ['**/test/**']
2222
LongMethod:
23+
threshold: 80
2324
excludes: ['**/test/**']
2425
LongParameterList:
2526
excludes: ['**/test/**']

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

-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ import org.opensearch.indexmanagement.spi.indexstatemanagement.StatusChecker
1414
* SPI for IndexManagement
1515
*/
1616
interface IndexManagementExtension {
17-
1817
/**
1918
* List of action parsers that are supported by the extension, each of the action parser will parse the policy action into the defined action.
2019
* The ActionParser provides the ability to parse the action

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

+1-2
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,8 @@ import java.time.Instant
1919

2020
abstract class Action(
2121
val type: String,
22-
val actionIndex: Int
22+
val actionIndex: Int,
2323
) : ToXContentObject, Writeable {
24-
2524
var configTimeout: ActionTimeout? = null
2625
var configRetry: ActionRetry? = ActionRetry(DEFAULT_RETRIES)
2726
var customAction: Boolean = false

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

-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import org.opensearch.core.common.io.stream.StreamInput
99
import org.opensearch.core.xcontent.XContentParser
1010

1111
abstract class ActionParser(var customAction: Boolean = false) {
12-
1312
/**
1413
* The action type parser will parse
1514
*/

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

-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ import org.opensearch.indexmanagement.spi.indexstatemanagement.model.ISMIndexMet
2121
* else uses the default i.e cluster state
2222
*/
2323
interface IndexMetadataService {
24-
2524
/**
2625
* Returns the index metadata needed for ISM
2726
*/

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ package org.opensearch.indexmanagement.spi.indexstatemanagement
88
import org.opensearch.cluster.ClusterState
99

1010
interface StatusChecker {
11-
1211
/**
1312
* checks and returns the status of the extension
1413
*/
@@ -19,7 +18,8 @@ interface StatusChecker {
1918

2019
enum class Status(private val value: String) {
2120
ENABLED("enabled"),
22-
DISABLED("disabled");
21+
DISABLED("disabled"),
22+
;
2323

2424
override fun toString(): String {
2525
return value

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ import java.time.Instant
1616
import java.util.Locale
1717

1818
abstract class Step(val name: String, val isSafeToDisableOn: Boolean = true) {
19-
2019
var context: StepContext? = null
2120
private set
2221

@@ -56,7 +55,8 @@ abstract class Step(val name: String, val isSafeToDisableOn: Boolean = true) {
5655
STARTING("starting"),
5756
CONDITION_NOT_MET("condition_not_met"),
5857
FAILED("failed"),
59-
COMPLETED("completed");
58+
COMPLETED("completed"),
59+
;
6060

6161
override fun toString(): String {
6262
return status

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

+4-4
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,18 @@
66
package org.opensearch.indexmanagement.spi.indexstatemanagement
77

88
import org.opensearch.cluster.service.ClusterService
9+
import org.opensearch.common.settings.Settings
910
import org.opensearch.core.common.io.stream.StreamInput
1011
import org.opensearch.core.common.io.stream.StreamOutput
1112
import org.opensearch.core.common.io.stream.Writeable
12-
import org.opensearch.common.settings.Settings
1313
import org.opensearch.monitor.jvm.JvmService
1414
import java.util.Locale
1515

1616
abstract class Validate(
1717
val settings: Settings,
1818
val clusterService: ClusterService,
19-
val jvmService: JvmService
19+
val jvmService: JvmService,
2020
) {
21-
2221
var validationStatus = ValidationStatus.PASSED
2322
var validationMessage: String? = "Starting Validation"
2423

@@ -27,7 +26,8 @@ abstract class Validate(
2726
enum class ValidationStatus(val status: String) : Writeable {
2827
PASSED("passed"),
2928
RE_VALIDATING("re_validating"),
30-
FAILED("failed");
29+
FAILED("failed"),
30+
;
3131

3232
override fun toString(): String {
3333
return status

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

+5-6
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,17 @@
55

66
package org.opensearch.indexmanagement.spi.indexstatemanagement.model
77

8+
import org.opensearch.common.xcontent.LoggingDeprecationHandler
9+
import org.opensearch.common.xcontent.XContentType
810
import org.opensearch.core.common.Strings
911
import org.opensearch.core.common.io.stream.StreamInput
1012
import org.opensearch.core.common.io.stream.StreamOutput
1113
import org.opensearch.core.common.io.stream.Writeable
12-
import org.opensearch.common.xcontent.LoggingDeprecationHandler
1314
import org.opensearch.core.xcontent.NamedXContentRegistry
1415
import org.opensearch.core.xcontent.ToXContent
1516
import org.opensearch.core.xcontent.ToXContentFragment
1617
import org.opensearch.core.xcontent.XContentBuilder
1718
import org.opensearch.core.xcontent.XContentParser
18-
import org.opensearch.common.xcontent.XContentType
1919
import org.opensearch.core.xcontent.XContentParserUtils
2020
import org.opensearch.indexmanagement.spi.indexstatemanagement.model.ManagedIndexMetaData.Companion.NAME
2121
import org.opensearch.indexmanagement.spi.indexstatemanagement.model.ManagedIndexMetaData.Companion.START_TIME
@@ -29,9 +29,8 @@ data class ActionMetaData(
2929
val failed: Boolean,
3030
val consumedRetries: Int,
3131
val lastRetryTime: Long?,
32-
val actionProperties: ActionProperties?
32+
val actionProperties: ActionProperties?,
3333
) : Writeable, ToXContentFragment {
34-
3534
override fun writeTo(out: StreamOutput) {
3635
out.writeString(name)
3736
out.writeOptionalLong(startTime)
@@ -89,7 +88,7 @@ data class ActionMetaData(
8988
requireNotNull(failed) { "$FAILED is null" },
9089
requireNotNull(consumedRetries) { "$CONSUMED_RETRIES is null" },
9190
lastRetryTime,
92-
actionProperties
91+
actionProperties,
9392
)
9493
}
9594

@@ -139,7 +138,7 @@ data class ActionMetaData(
139138
requireNotNull(failed) { "$FAILED is null" },
140139
requireNotNull(consumedRetries) { "$CONSUMED_RETRIES is null" },
141140
lastRetryTime,
142-
actionProperties
141+
actionProperties,
143142
)
144143
}
145144
}

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

+4-4
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,17 @@ import org.opensearch.core.xcontent.XContentParser.Token
1616
import org.opensearch.core.xcontent.XContentParserUtils.ensureExpectedToken
1717
import org.opensearch.indexmanagement.spi.indexstatemanagement.addObject
1818

19-
/** Properties that will persist across steps of a single Action. Will be stored in the [ActionMetaData]. */
2019
// TODO: Create namespaces to group properties together
20+
21+
/** Properties that will persist across steps of a single Action. Will be stored in the [ActionMetaData]. */
2122
data class ActionProperties(
2223
val maxNumSegments: Int? = null,
2324
val snapshotName: String? = null,
2425
val rollupId: String? = null,
2526
val hasRollupFailed: Boolean? = null,
2627
val shrinkActionProperties: ShrinkActionProperties? = null,
27-
val transformActionProperties: TransformActionProperties? = null
28+
val transformActionProperties: TransformActionProperties? = null,
2829
) : Writeable, ToXContentFragment {
29-
3030
override fun writeTo(out: StreamOutput) {
3131
out.writeOptionalInt(maxNumSegments)
3232
out.writeOptionalString(snapshotName)
@@ -94,6 +94,6 @@ data class ActionProperties(
9494
MAX_NUM_SEGMENTS("max_num_segments"),
9595
SNAPSHOT_NAME("snapshot_name"),
9696
ROLLUP_ID("rollup_id"),
97-
HAS_ROLLUP_FAILED("has_rollup_failed")
97+
HAS_ROLLUP_FAILED("has_rollup_failed"),
9898
}
9999
}

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

+15-12
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@
66
package org.opensearch.indexmanagement.spi.indexstatemanagement.model
77

88
import org.apache.logging.log4j.LogManager
9+
import org.opensearch.common.unit.TimeValue
910
import org.opensearch.core.common.io.stream.StreamInput
1011
import org.opensearch.core.common.io.stream.StreamOutput
1112
import org.opensearch.core.common.io.stream.Writeable
12-
import org.opensearch.common.unit.TimeValue
1313
import org.opensearch.core.xcontent.ToXContent
1414
import org.opensearch.core.xcontent.ToXContentFragment
1515
import org.opensearch.core.xcontent.XContentBuilder
@@ -23,10 +23,11 @@ import kotlin.math.pow
2323
data class ActionRetry(
2424
val count: Long,
2525
val backoff: Backoff = Backoff.EXPONENTIAL,
26-
val delay: TimeValue = TimeValue.timeValueMinutes(1)
26+
val delay: TimeValue = TimeValue.timeValueMinutes(1),
2727
) : ToXContentFragment, Writeable {
28-
29-
init { require(count >= 0) { "Count for ActionRetry must be a non-negative number" } }
28+
init {
29+
require(count >= 0) { "Count for ActionRetry must be a non-negative number" }
30+
}
3031

3132
override fun toXContent(builder: XContentBuilder, params: ToXContent.Params): XContentBuilder {
3233
builder
@@ -42,7 +43,7 @@ data class ActionRetry(
4243
constructor(sin: StreamInput) : this(
4344
count = sin.readLong(),
4445
backoff = sin.readEnum(Backoff::class.java),
45-
delay = sin.readTimeValue()
46+
delay = sin.readTimeValue(),
4647
)
4748

4849
@Throws(IOException::class)
@@ -80,7 +81,7 @@ data class ActionRetry(
8081
return ActionRetry(
8182
count = requireNotNull(count) { "ActionRetry count is null" },
8283
backoff = backoff,
83-
delay = delay
84+
delay = delay,
8485
)
8586
}
8687
}
@@ -90,20 +91,21 @@ data class ActionRetry(
9091
"exponential",
9192
{ consumedRetries, timeValue ->
9293
(2.0.pow(consumedRetries - 1)).toLong() * timeValue.millis
93-
}
94+
},
9495
),
9596
CONSTANT(
9697
"constant",
9798
{ _, timeValue ->
9899
timeValue.millis
99-
}
100+
},
100101
),
101102
LINEAR(
102103
"linear",
103104
{ consumedRetries, timeValue ->
104105
consumedRetries * timeValue.millis
105-
}
106-
);
106+
},
107+
),
108+
;
107109

108110
private val logger = LogManager.getLogger(javaClass)
109111

@@ -120,8 +122,9 @@ data class ActionRetry(
120122

121123
if (actionMetaData.consumedRetries > 0) {
122124
if (actionMetaData.lastRetryTime != null) {
123-
val remainingTime = getNextRetryTime(actionMetaData.consumedRetries, actionRetry.delay) -
124-
(Instant.now().toEpochMilli() - actionMetaData.lastRetryTime)
125+
val remainingTime =
126+
getNextRetryTime(actionMetaData.consumedRetries, actionRetry.delay) -
127+
(Instant.now().toEpochMilli() - actionMetaData.lastRetryTime)
125128

126129
return Pair(remainingTime > 0, remainingTime)
127130
}

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

+2-3
Original file line numberDiff line numberDiff line change
@@ -5,25 +5,24 @@
55

66
package org.opensearch.indexmanagement.spi.indexstatemanagement.model
77

8+
import org.opensearch.common.unit.TimeValue
89
import org.opensearch.core.common.io.stream.StreamInput
910
import org.opensearch.core.common.io.stream.StreamOutput
1011
import org.opensearch.core.common.io.stream.Writeable
11-
import org.opensearch.common.unit.TimeValue
1212
import org.opensearch.core.xcontent.ToXContent
1313
import org.opensearch.core.xcontent.ToXContentFragment
1414
import org.opensearch.core.xcontent.XContentBuilder
1515
import org.opensearch.core.xcontent.XContentParser
1616
import java.io.IOException
1717

1818
data class ActionTimeout(val timeout: TimeValue) : ToXContentFragment, Writeable {
19-
2019
override fun toXContent(builder: XContentBuilder, params: ToXContent.Params): XContentBuilder {
2120
return builder.field(TIMEOUT_FIELD, timeout.stringRep)
2221
}
2322

2423
@Throws(IOException::class)
2524
constructor(sin: StreamInput) : this(
26-
timeout = sin.readTimeValue()
25+
timeout = sin.readTimeValue(),
2726
)
2827

2928
@Throws(IOException::class)

0 commit comments

Comments
 (0)