@@ -138,33 +138,6 @@ func sortIssues(iss []Issue) {
138
138
})
139
139
}
140
140
141
- // checkTopLevel checks all top-level comments.
142
- func checkTopLevel (file * ast.File , fset * token.FileSet ) (issues []Issue ) {
143
- for _ , group := range file .Comments {
144
- if iss , ok := check (fset , group , topLevelColumn ); ! ok {
145
- issues = append (issues , iss )
146
- }
147
- }
148
- return issues
149
- }
150
-
151
- // checkDeclarations checks top level declaration comments.
152
- func checkDeclarations (file * ast.File , fset * token.FileSet ) (issues []Issue ) {
153
- for _ , decl := range file .Decls {
154
- switch d := decl .(type ) {
155
- case * ast.GenDecl :
156
- if iss , ok := check (fset , d .Doc , topLevelColumn ); ! ok {
157
- issues = append (issues , iss )
158
- }
159
- case * ast.FuncDecl :
160
- if iss , ok := check (fset , d .Doc , topLevelColumn ); ! ok {
161
- issues = append (issues , iss )
162
- }
163
- }
164
- }
165
- return issues
166
- }
167
-
168
141
// checkBlocks checks comments inside top level blocks (var (...), const (...), etc).
169
142
func checkBlocks (file * ast.File , fset * token.FileSet ) (issues []Issue ) {
170
143
for _ , decl := range file .Decls {
@@ -193,6 +166,33 @@ func checkBlocks(file *ast.File, fset *token.FileSet) (issues []Issue) {
193
166
return issues
194
167
}
195
168
169
+ // checkTopLevel checks all top-level comments.
170
+ func checkTopLevel (file * ast.File , fset * token.FileSet ) (issues []Issue ) {
171
+ for _ , group := range file .Comments {
172
+ if iss , ok := check (fset , group , topLevelColumn ); ! ok {
173
+ issues = append (issues , iss )
174
+ }
175
+ }
176
+ return issues
177
+ }
178
+
179
+ // checkDeclarations checks top level declaration comments.
180
+ func checkDeclarations (file * ast.File , fset * token.FileSet ) (issues []Issue ) {
181
+ for _ , decl := range file .Decls {
182
+ switch d := decl .(type ) {
183
+ case * ast.GenDecl :
184
+ if iss , ok := check (fset , d .Doc , topLevelColumn ); ! ok {
185
+ issues = append (issues , iss )
186
+ }
187
+ case * ast.FuncDecl :
188
+ if iss , ok := check (fset , d .Doc , topLevelColumn ); ! ok {
189
+ issues = append (issues , iss )
190
+ }
191
+ }
192
+ }
193
+ return issues
194
+ }
195
+
196
196
func check (fset * token.FileSet , group * ast.CommentGroup , level int ) (iss Issue , ok bool ) {
197
197
if group == nil || len (group .List ) == 0 {
198
198
return Issue {}, true
0 commit comments