forked from go-toolset/pepperlint
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rule_file.go
28 lines (23 loc) · 666 Bytes
/
rule_file.go
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
package pepperlint
import (
"go/ast"
)
// FileRules is a list of type FileRule.
type FileRules []FileRule
// ValidateFile will iterate through the list of array types and call
// ValidateFile. If an error is returned, then that error will be added
// to the batch of errors.
func (rules FileRules) ValidateFile(stmt *ast.File) error {
batchError := NewBatchError()
for _, rule := range rules {
if err := rule.ValidateFile(stmt); err != nil {
batchError.Add(err)
}
}
return batchError.Return()
}
// FileRule represents an interface that will allow for validation
// to occur on an ast.File.
type FileRule interface {
ValidateFile(*ast.File) error
}