-
-
Notifications
You must be signed in to change notification settings - Fork 758
/
KDocReferencesNonPublicPropertySpec.kt
96 lines (87 loc) · 2.79 KB
/
KDocReferencesNonPublicPropertySpec.kt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
package io.gitlab.arturbosch.detekt.rules.documentation
import io.gitlab.arturbosch.detekt.test.compileAndLint
import org.assertj.core.api.Assertions.assertThat
import org.junit.jupiter.api.Test
class KDocReferencesNonPublicPropertySpec {
val subject = KDocReferencesNonPublicProperty()
inner class `KDocReferencesNonPublicProperty rule` {
@Test
fun `reports referenced non-public properties`() {
val code = """
/**
* Comment
* [prop1] - non-public property
* [prop2] - public property
*/
class Test {
private val prop1 = 0
val prop2 = 0
}
""".trimIndent()
assertThat(subject.compileAndLint(code)).hasSize(1)
}
@Test
fun `reports referenced non-public properties in private class`() {
val code = """
/**
* Comment
* [prop1] - non-public property
* [prop2] - public property
*/
private class Test {
private val prop1 = 0
val prop2 = 0
}
""".trimIndent()
assertThat(subject.compileAndLint(code)).hasSize(1)
}
@Test
fun `reports referenced non-public properties in nested objects`() {
val code = """
/**
* Comment
* [prop1] - non-public property
* [A.prop2] - non-public property
* [A.B.prop3] - non-public property
* [A.C.prop4] - non-public property
*/
class Test {
private val prop1 = 0
object A {
private val prop2 = 0
private object B {
val prop3 = 0
}
object C {
private val prop4 = 0
}
}
}
""".trimIndent()
assertThat(subject.compileAndLint(code)).hasSize(4)
}
@Test
fun `does not report referenced public properties in nested objects`() {
val code = """
/**
* Comment
* [prop1] - public property
* [A.B.prop2] - public property
* [C.prop3] - public property
*/
class Test {
val prop1 = 0
object A {
object B {
val prop2 = 0
}
}
object C {
val prop3 = 0
}
}
""".trimIndent()
assertThat(subject.compileAndLint(code)).isEmpty()
}
}
}