-
Notifications
You must be signed in to change notification settings - Fork 0
/
formatter.go
45 lines (40 loc) · 960 Bytes
/
formatter.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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
package new_line
import (
"go/ast"
"golang.org/x/tools/go/analysis"
"golang.org/x/tools/go/analysis/passes/inspect"
"golang.org/x/tools/go/ast/inspector"
)
const Doc = `new_line`
var Analyzer = &analysis.Analyzer{
Name: "new_line",
Doc: Doc,
Run: run,
Requires: []*analysis.Analyzer{inspect.Analyzer},
}
func run(pass *analysis.Pass) (interface{}, error) {
nodeFilter := []ast.Node{(*ast.FuncDecl)(nil)}
pass.ResultOf[inspect.Analyzer].(*inspector.Inspector).Preorder(nodeFilter, func(n ast.Node) {
e := n.(*ast.FuncDecl)
pass.Report(analysis.Diagnostic{
Pos: e.Pos(),
End: e.Pos(),
Category: "func",
Message: "new_line",
SuggestedFixes: []analysis.SuggestedFix{
{
Message: "many arguments",
TextEdits: []analysis.TextEdit{
{
Pos: e.Pos(),
End: e.Pos(),
NewText: []byte("\n"),
},
},
},
},
Related: nil,
})
})
return nil, nil
}