.gitignore added
[dotfiles/.git] / .config / coc / extensions / coc-go-data / tools / pkg / mod / honnef.co / go / tools@v0.1.1 / lintcmd / directives.go
1 package lintcmd
2
3 import (
4         "strings"
5
6         "honnef.co/go/tools/lintcmd/runner"
7 )
8
9 func parseDirectives(dirs []runner.SerializedDirective) ([]ignore, []problem) {
10         var ignores []ignore
11         var problems []problem
12
13         for _, dir := range dirs {
14                 cmd := dir.Command
15                 args := dir.Arguments
16                 switch cmd {
17                 case "ignore", "file-ignore":
18                         if len(args) < 2 {
19                                 p := problem{
20                                         Diagnostic: runner.Diagnostic{
21                                                 Position: dir.NodePosition,
22                                                 Message:  "malformed linter directive; missing the required reason field?",
23                                                 Category: "compile",
24                                         },
25                                         Severity: severityError,
26                                 }
27                                 problems = append(problems, p)
28                                 continue
29                         }
30                 default:
31                         // unknown directive, ignore
32                         continue
33                 }
34                 checks := strings.Split(args[0], ",")
35                 pos := dir.NodePosition
36                 var ig ignore
37                 switch cmd {
38                 case "ignore":
39                         ig = &lineIgnore{
40                                 File:   pos.Filename,
41                                 Line:   pos.Line,
42                                 Checks: checks,
43                                 Pos:    dir.DirectivePosition,
44                         }
45                 case "file-ignore":
46                         ig = &fileIgnore{
47                                 File:   pos.Filename,
48                                 Checks: checks,
49                         }
50                 }
51                 ignores = append(ignores, ig)
52         }
53
54         return ignores, problems
55 }