Skip to content

Commit

Permalink
refactor skipAnalyzer
Browse files Browse the repository at this point in the history
Signed-off-by: Weizhen Wang <[email protected]>
  • Loading branch information
hawkingrei committed Jun 22, 2022
1 parent edb6ba2 commit 105f68a
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions build/linter/util/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,24 +25,25 @@ import (
"honnef.co/go/tools/analysis/report"
)

type SkipType int
//
type skipType int

const (
SkipNone SkipType = iota
skipNone skipType = iota
skipLinter
skipFile
)

// Directive is a comment of the form '//lint:<command> [arguments...]' and `//nolint:<command>`.
// It represents instructions to the static analysis tool.
type Directive struct {
Command SkipType
Command skipType
Linters []string
Directive *ast.Comment
Node ast.Node
}

func parseDirective(s string) (cmd SkipType, args []string) {
func parseDirective(s string) (cmd skipType, args []string) {
if strings.HasPrefix(s, "//lint:") {
s = strings.TrimPrefix(s, "//lint:")
fields := strings.Split(s, " ")
Expand All @@ -52,7 +53,7 @@ func parseDirective(s string) (cmd SkipType, args []string) {
case "file-ignore":
return skipFile, fields[1:]
}
return SkipNone, nil
return skipNone, nil
}
s = strings.TrimPrefix(s, "//nolint: ")
return skipLinter, []string{s}
Expand Down

0 comments on commit 105f68a

Please sign in to comment.