Skip to content

Commit ad703b6

Browse files
committed
name change for annotation
1 parent 3ab8bdb commit ad703b6

File tree

3 files changed

+15
-15
lines changed

3 files changed

+15
-15
lines changed
Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,23 +11,23 @@ import com.pinterest.ktlint.rule.engine.core.api.RuleId
1111
import org.jetbrains.kotlin.com.intellij.lang.ASTNode
1212

1313
/**
14-
* Creates a ktlint rule that forces APIs annotated with @DeprecatedUntilVersion to also be annotated with @Deprecated.
14+
* Creates a ktlint rule that forces APIs annotated with @PlannedRemoval to also be annotated with @Deprecated.
1515
*/
16-
class DeprecatedUntilVersionRule : Rule(RuleId("$RULE_SET:deprecated-until-version"), About()) {
16+
class PlannedRemovalRule : Rule(RuleId("$RULE_SET:planned-removal"), About()) {
1717
override fun beforeVisitChildNodes(
1818
node: ASTNode,
1919
autoCorrect: Boolean,
2020
emit: (offset: Int, errorMessage: String, canBeAutoCorrected: Boolean) -> Unit,
2121
) {
2222
if (node.elementType == ElementType.MODIFIER_LIST) {
2323
val annotations = node.getChildren(null).filter { it.elementType == ElementType.ANNOTATION_ENTRY }
24-
val deprecated = annotations.any { it.text.startsWith("@Deprecated") && !it.text.contains("@DeprecatedUntilVersion") }
25-
val deprecatedUntilVersion = annotations.any { it.text.startsWith("@DeprecatedUntilVersion") }
24+
val deprecated = annotations.any { it.text.startsWith("@Deprecated") }
25+
val plannedRemoval = annotations.any { it.text.startsWith("@PlannedRemoval") }
2626

27-
if (deprecatedUntilVersion && !deprecated) {
27+
if (plannedRemoval && !deprecated) {
2828
emit(
2929
node.startOffset,
30-
"APIs annotated with @DeprecatedUntilVersion must also be annotated with @Deprecated",
30+
"APIs annotated with @PlannedRemoval must also be annotated with @Deprecated",
3131
false,
3232
)
3333
}

ktlint/style-rules/src/main/kotlin/software/aws/ktlint/rules/StyleRuleSetProvider.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,6 @@ class StyleRuleSetProvider : RuleSetProviderV3(RuleSetId(RULE_SET)) {
1515
RuleProvider { CopyrightHeaderRule() },
1616
RuleProvider { ExpressionBodyRule() },
1717
RuleProvider { MultilineIfElseBlockRule() },
18-
RuleProvider { DeprecatedUntilVersionRule() },
18+
RuleProvider { PlannedRemovalRule() },
1919
)
2020
}
Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@ import com.pinterest.ktlint.rule.engine.core.api.RuleProvider
1111
import kotlin.test.Test
1212
import kotlin.test.assertEquals
1313

14-
class DeprecatedUntilVersionRuleTest {
14+
class PlannedRemovalRuleTest {
1515
val ruleEngine = KtLintRuleEngine(
1616
setOf(
17-
RuleProvider { DeprecatedUntilVersionRule() },
17+
RuleProvider { PlannedRemovalRule() },
1818
),
1919
)
2020

@@ -34,7 +34,7 @@ class DeprecatedUntilVersionRuleTest {
3434
false,
3535
hasLintingErrors(
3636
"""
37-
@DeprecatedUntilVersion(1, 2)
37+
@PlannedRemoval(1, 2)
3838
@Deprecated
3939
class Foo {}
4040
""".trimIndent(),
@@ -46,7 +46,7 @@ class DeprecatedUntilVersionRuleTest {
4646
hasLintingErrors(
4747
"""
4848
@Deprecated
49-
@DeprecatedUntilVersion(1, 2)
49+
@PlannedRemoval(1, 2)
5050
class Foo {}
5151
""".trimIndent(),
5252
),
@@ -66,7 +66,7 @@ class DeprecatedUntilVersionRuleTest {
6666
true,
6767
hasLintingErrors(
6868
"""
69-
@DeprecatedUntilVersion(1, 2)
69+
@PlannedRemoval(1, 2)
7070
class Foo {}
7171
""".trimIndent(),
7272
),
@@ -76,7 +76,7 @@ class DeprecatedUntilVersionRuleTest {
7676
true,
7777
hasLintingErrors(
7878
"""
79-
@DeprecatedUntilVersion(1, 2)
79+
@PlannedRemoval(1, 2)
8080
class Foo {}
8181
8282
@Deprecated
@@ -89,10 +89,10 @@ class DeprecatedUntilVersionRuleTest {
8989
true,
9090
hasLintingErrors(
9191
"""
92-
@DeprecatedUntilVersion(1, 2)
92+
@PlannedRemoval(1, 2)
9393
class Foo {}
9494
95-
@DeprecatedUntilVersion(1, 2)
95+
@PlannedRemoval(1, 2)
9696
class Bar {}
9797
""".trimIndent(),
9898
),

0 commit comments

Comments
 (0)