@@ -7,16 +7,40 @@ final class AllPublicDeclarationsHaveDocumentationTests: LintOrFormatRuleTestCas
7
7
assertLint (
8
8
AllPublicDeclarationsHaveDocumentation . self,
9
9
"""
10
- 1️⃣public func lightswitchRave() {
11
- }
10
+ 1️⃣public func lightswitchRave() {}
11
+ /// Comment.
12
+ public func lightswitchRave() {}
13
+ func lightswitchRave() {}
12
14
13
- 2️⃣public var isSblounskched: Int {
14
- return 0
15
- }
15
+ 2️⃣public var isSblounskched: Int { return 0 }
16
+ /// Comment.
17
+ public var isSblounskched: Int { return 0 }
18
+ var isSblounskched: Int { return 0 }
16
19
17
- /// Everybody to the limit.
18
- public func fhqwhgads() {
19
- }
20
+ 3️⃣public struct Foo {}
21
+ /// Comment.
22
+ public struct Foo {}
23
+ struct Foo {}
24
+
25
+ 4️⃣public actor Bar {}
26
+ /// Comment.
27
+ public actor Bar {}
28
+ actor Bar {}
29
+
30
+ 5️⃣public class Baz {}
31
+ /// Comment.
32
+ public class Baz {}
33
+ class Baz {}
34
+
35
+ 6️⃣public enum Qux {}
36
+ /// Comment.
37
+ public enum Qux {}
38
+ enum Qux {}
39
+
40
+ 7️⃣public typealias MyType = Int
41
+ /// Comment.
42
+ public typealias MyType = Int
43
+ typealias MyType = Int
20
44
21
45
/**
22
46
* Determines if an email was delorted.
@@ -28,6 +52,138 @@ final class AllPublicDeclarationsHaveDocumentationTests: LintOrFormatRuleTestCas
28
52
findings: [
29
53
FindingSpec ( " 1️⃣ " , message: " add a documentation comment for 'lightswitchRave()' " ) ,
30
54
FindingSpec ( " 2️⃣ " , message: " add a documentation comment for 'isSblounskched' " ) ,
55
+ FindingSpec ( " 3️⃣ " , message: " add a documentation comment for 'Foo' " ) ,
56
+ FindingSpec ( " 4️⃣ " , message: " add a documentation comment for 'Bar' " ) ,
57
+ FindingSpec ( " 5️⃣ " , message: " add a documentation comment for 'Baz' " ) ,
58
+ FindingSpec ( " 6️⃣ " , message: " add a documentation comment for 'Qux' " ) ,
59
+ FindingSpec ( " 7️⃣ " , message: " add a documentation comment for 'MyType' " )
60
+ ]
61
+ )
62
+ }
63
+
64
+ func testNestedDecls( ) {
65
+ assertLint (
66
+ AllPublicDeclarationsHaveDocumentation . self,
67
+ """
68
+ /// Comment.
69
+ public struct MyContainer {
70
+ 1️⃣public func lightswitchRave() {}
71
+ /// Comment.
72
+ public func lightswitchRave() {}
73
+ func lightswitchRave() {}
74
+
75
+ 2️⃣public var isSblounskched: Int { return 0 }
76
+ /// Comment.
77
+ public var isSblounskched: Int { return 0 }
78
+ var isSblounskched: Int { return 0 }
79
+
80
+ 3️⃣public struct Foo {}
81
+ /// Comment.
82
+ public struct Foo {}
83
+ struct Foo {}
84
+
85
+ 4️⃣public actor Bar {}
86
+ /// Comment.
87
+ public actor Bar {}
88
+ actor Bar {}
89
+
90
+ 5️⃣public class Baz {}
91
+ /// Comment.
92
+ public class Baz {}
93
+ class Baz {}
94
+
95
+ 6️⃣public enum Qux {}
96
+ /// Comment.
97
+ public enum Qux {}
98
+ enum Qux {}
99
+
100
+ 7️⃣public typealias MyType = Int
101
+ /// Comment.
102
+ public typealias MyType = Int
103
+ typealias MyType = Int
104
+
105
+ }
106
+ """ ,
107
+ findings: [
108
+ FindingSpec ( " 1️⃣ " , message: " add a documentation comment for 'lightswitchRave()' " ) ,
109
+ FindingSpec ( " 2️⃣ " , message: " add a documentation comment for 'isSblounskched' " ) ,
110
+ FindingSpec ( " 3️⃣ " , message: " add a documentation comment for 'Foo' " ) ,
111
+ FindingSpec ( " 4️⃣ " , message: " add a documentation comment for 'Bar' " ) ,
112
+ FindingSpec ( " 5️⃣ " , message: " add a documentation comment for 'Baz' " ) ,
113
+ FindingSpec ( " 6️⃣ " , message: " add a documentation comment for 'Qux' " ) ,
114
+ FindingSpec ( " 7️⃣ " , message: " add a documentation comment for 'MyType' " )
115
+ ]
116
+ )
117
+ }
118
+
119
+ func testNestedInStruct( ) {
120
+ assertLint (
121
+ AllPublicDeclarationsHaveDocumentation . self,
122
+ """
123
+ /// Comment.
124
+ public struct MyContainer {
125
+ 1️⃣public typealias MyType = Int
126
+ /// Comment.
127
+ public typealias MyType = Int
128
+ typealias MyType = Int
129
+ }
130
+ """ ,
131
+ findings: [
132
+ FindingSpec ( " 1️⃣ " , message: " add a documentation comment for 'MyType' " ) ,
133
+ ]
134
+ )
135
+ }
136
+
137
+ func testNestedInClass( ) {
138
+ assertLint (
139
+ AllPublicDeclarationsHaveDocumentation . self,
140
+ """
141
+ /// Comment.
142
+ public class MyContainer {
143
+ 1️⃣public typealias MyType = Int
144
+ /// Comment.
145
+ public typealias MyType = Int
146
+ typealias MyType = Int
147
+ }
148
+ """ ,
149
+ findings: [
150
+ FindingSpec ( " 1️⃣ " , message: " add a documentation comment for 'MyType' " ) ,
151
+ ]
152
+ )
153
+ }
154
+
155
+ func testNestedInEnum( ) {
156
+ assertLint (
157
+ AllPublicDeclarationsHaveDocumentation . self,
158
+ """
159
+ /// Comment.
160
+ public enum MyContainer {
161
+ 1️⃣public typealias MyType = Int
162
+ /// Comment.
163
+ public typealias MyType = Int
164
+ typealias MyType = Int
165
+ }
166
+ """ ,
167
+ findings: [
168
+ FindingSpec ( " 1️⃣ " , message: " add a documentation comment for 'MyType' " ) ,
169
+ ]
170
+ )
171
+ }
172
+
173
+ func testNestedInActor( ) {
174
+ assertLint (
175
+ AllPublicDeclarationsHaveDocumentation . self,
176
+ """
177
+ /// Comment.
178
+ public actor MyContainer {
179
+ 1️⃣public typealias MyType = Int
180
+ /// Comment.
181
+ public typealias MyType = Int
182
+ typealias MyType = Int
183
+ }
184
+ """ ,
185
+ findings: [
186
+ FindingSpec ( " 1️⃣ " , message: " add a documentation comment for 'MyType' " ) ,
31
187
]
32
188
)
33
189
}
0 commit comments