From 105f68ab88cf46eddc6bd07ad1df368bc663ab5b Mon Sep 17 00:00:00 2001 From: Weizhen Wang Date: Wed, 22 Jun 2022 19:56:27 +0800 Subject: [PATCH] refactor skipAnalyzer Signed-off-by: Weizhen Wang --- build/linter/util/util.go | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/build/linter/util/util.go b/build/linter/util/util.go index 612f9487a776f..d438ea0057a6e 100644 --- a/build/linter/util/util.go +++ b/build/linter/util/util.go @@ -25,10 +25,11 @@ import ( "honnef.co/go/tools/analysis/report" ) -type SkipType int +// +type skipType int const ( - SkipNone SkipType = iota + skipNone skipType = iota skipLinter skipFile ) @@ -36,13 +37,13 @@ const ( // Directive is a comment of the form '//lint: [arguments...]' and `//nolint:`. // 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, " ") @@ -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}