Skip to content

Commit

Permalink
Renamed member-or-type-annotation rule to annotation
Browse files Browse the repository at this point in the history
  • Loading branch information
Stanley Shyiko committed Feb 4, 2019
1 parent 7448e8b commit 651325a
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import org.jetbrains.kotlin.psi.KtAnnotationEntry
import org.jetbrains.kotlin.psi.psiUtil.children
import org.jetbrains.kotlin.psi.psiUtil.startOffset

class MemberOrTypeAnnotationRule : Rule("member-or-type-annotation") {
class AnnotationRule : Rule("annotation") {

companion object {
const val multipleAnnotationsOnSameLineAsAnnotatedConstructErrorMessage =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ import com.github.shyiko.ktlint.test.lint
import org.assertj.core.api.Assertions.assertThat
import org.testng.annotations.Test

class MemberOrTypeAnnotationRuleTest {
class AnnotationRuleTest {

@Test
fun `lint single annotation may be placed on line before annotated construct`() {
assertThat(
MemberOrTypeAnnotationRule().lint(
AnnotationRule().lint(
"""
@FunctionalInterface class A {
@JvmField
Expand All @@ -30,13 +30,13 @@ class MemberOrTypeAnnotationRuleTest {
var x: String
}
""".trimIndent()
assertThat(MemberOrTypeAnnotationRule().format(code)).isEqualTo(code)
assertThat(AnnotationRule().format(code)).isEqualTo(code)
}

@Test
fun `lint single annotation may be placed on same line as annotated construct`() {
assertThat(
MemberOrTypeAnnotationRule().lint(
AnnotationRule().lint(
"""
@FunctionalInterface class A {
@JvmField var x: String
Expand All @@ -57,13 +57,13 @@ class MemberOrTypeAnnotationRuleTest {
@Test fun myTest() {}
}
""".trimIndent()
assertThat(MemberOrTypeAnnotationRule().format(code)).isEqualTo(code)
assertThat(AnnotationRule().format(code)).isEqualTo(code)
}

@Test
fun `lint multiple annotations should not be placed on same line as annotated construct`() {
assertThat(
MemberOrTypeAnnotationRule().lint(
AnnotationRule().lint(
"""
class A {
@JvmField @Volatile var x: String
Expand All @@ -75,16 +75,16 @@ class MemberOrTypeAnnotationRuleTest {
)
).containsExactly(
LintError(
2, 5, "member-or-type-annotation",
MemberOrTypeAnnotationRule.multipleAnnotationsOnSameLineAsAnnotatedConstructErrorMessage
2, 5, "annotation",
AnnotationRule.multipleAnnotationsOnSameLineAsAnnotatedConstructErrorMessage
)
)
}

@Test
fun `format multiple annotations should not be placed on same line as annotated construct`() {
assertThat(
MemberOrTypeAnnotationRule().format(
AnnotationRule().format(
"""
class A {
@JvmField @Volatile var x: String
Expand All @@ -109,7 +109,7 @@ class MemberOrTypeAnnotationRuleTest {

@Test
fun `format multiple annotations should not be placed on same line as annotated construct (with no previous whitespace)`() {
assertThat(MemberOrTypeAnnotationRule().format("@JvmField @Volatile var x: String"))
assertThat(AnnotationRule().format("@JvmField @Volatile var x: String"))
.isEqualTo(
"""
@JvmField @Volatile
Expand All @@ -121,7 +121,7 @@ class MemberOrTypeAnnotationRuleTest {
@Test
fun `format multiple annotations should not be placed on same line as annotated construct (with no previous indent)`() {
assertThat(
MemberOrTypeAnnotationRule().format(
AnnotationRule().format(
"""
@JvmField @Volatile var x: String
Expand All @@ -139,7 +139,7 @@ class MemberOrTypeAnnotationRuleTest {
@Test
fun `lint annotations with params should not be placed on same line before annotated construct`() {
assertThat(
MemberOrTypeAnnotationRule().lint(
AnnotationRule().lint(
"""
class A {
@JvmName("xJava") var x: String
Expand All @@ -151,16 +151,16 @@ class MemberOrTypeAnnotationRuleTest {
)
).containsExactly(
LintError(
2, 5, "member-or-type-annotation",
MemberOrTypeAnnotationRule.annotationsWithParametersAreNotOnSeparateLinesErrorMessage
2, 5, "annotation",
AnnotationRule.annotationsWithParametersAreNotOnSeparateLinesErrorMessage
)
)
}

@Test
fun `format annotations with params should not be placed on same line before annotated construct`() {
assertThat(
MemberOrTypeAnnotationRule().format(
AnnotationRule().format(
"""
class A {
@JvmName("xJava") var x: String
Expand All @@ -186,7 +186,7 @@ class MemberOrTypeAnnotationRuleTest {
@Test
fun `lint multiple annotations with params should not be placed on same line before annotated construct`() {
assertThat(
MemberOrTypeAnnotationRule().lint(
AnnotationRule().lint(
"""
@Retention(SOURCE) @Target(FUNCTION, PROPERTY_SETTER, FIELD) annotation class A
Expand All @@ -197,20 +197,20 @@ class MemberOrTypeAnnotationRuleTest {
)
).containsExactly(
LintError(
1, 1, "member-or-type-annotation",
MemberOrTypeAnnotationRule.multipleAnnotationsOnSameLineAsAnnotatedConstructErrorMessage
1, 1, "annotation",
AnnotationRule.multipleAnnotationsOnSameLineAsAnnotatedConstructErrorMessage
),
LintError(
1, 1, "member-or-type-annotation",
MemberOrTypeAnnotationRule.annotationsWithParametersAreNotOnSeparateLinesErrorMessage
1, 1, "annotation",
AnnotationRule.annotationsWithParametersAreNotOnSeparateLinesErrorMessage
)
)
}

@Test
fun `format multiple annotations with params should not be placed on same line before annotated construct`() {
assertThat(
MemberOrTypeAnnotationRule().format(
AnnotationRule().format(
"""
@Retention(SOURCE) @Target(FUNCTION, PROPERTY_SETTER, FIELD) annotation class A
Expand All @@ -235,7 +235,7 @@ class MemberOrTypeAnnotationRuleTest {
@Test
fun `lint annotation after keyword`() {
assertThat(
MemberOrTypeAnnotationRule().lint(
AnnotationRule().lint(
"""
class A {
private @Test fun myTest() {}
Expand All @@ -252,13 +252,13 @@ class MemberOrTypeAnnotationRuleTest {
private @Test fun myTest() {}
}
""".trimIndent()
assertThat(MemberOrTypeAnnotationRule().format(code)).isEqualTo(code)
assertThat(AnnotationRule().format(code)).isEqualTo(code)
}

@Test
fun `lint multi-line annotation`() {
assertThat(
MemberOrTypeAnnotationRule().lint(
AnnotationRule().lint(
"""
class A {
@JvmField @Volatile @Annotation(
Expand All @@ -274,12 +274,12 @@ class MemberOrTypeAnnotationRuleTest {
)
).containsExactly(
LintError(
2, 5, "member-or-type-annotation",
MemberOrTypeAnnotationRule.multipleAnnotationsOnSameLineAsAnnotatedConstructErrorMessage
2, 5, "annotation",
AnnotationRule.multipleAnnotationsOnSameLineAsAnnotatedConstructErrorMessage
),
LintError(
2, 5, "member-or-type-annotation",
MemberOrTypeAnnotationRule.annotationsWithParametersAreNotOnSeparateLinesErrorMessage
2, 5, "annotation",
AnnotationRule.annotationsWithParametersAreNotOnSeparateLinesErrorMessage
)
)
}
Expand All @@ -298,7 +298,7 @@ class MemberOrTypeAnnotationRuleTest {
) val a: Any
}
""".trimIndent()
assertThat(MemberOrTypeAnnotationRule().format(code)).isEqualTo(
assertThat(AnnotationRule().format(code)).isEqualTo(
"""
class A {
@JvmField
Expand Down

0 comments on commit 651325a

Please sign in to comment.