58 lines
1.8 KiB
Diff
58 lines
1.8 KiB
Diff
From c346bb5b779e1f07a30f74ad07b28f89e1922b3c Mon Sep 17 00:00:00 2001
|
|
From: Weizhen Wang <wangweizhen@pingcap.com>
|
|
Date: Sat, 27 Aug 2022 16:20:25 +0800
|
|
Subject: [PATCH] update
|
|
|
|
Signed-off-by: Weizhen Wang <wangweizhen@pingcap.com>
|
|
---
|
|
errcheck/analyzer.go | 12 +++++++++++-
|
|
1 file changed, 11 insertions(+), 1 deletion(-)
|
|
|
|
diff --git a/errcheck/analyzer.go b/errcheck/analyzer.go
|
|
index 68593cc..2e3fd28 100644
|
|
--- a/errcheck/analyzer.go
|
|
+++ b/errcheck/analyzer.go
|
|
@@ -5,6 +5,7 @@ import (
|
|
"go/ast"
|
|
"reflect"
|
|
"regexp"
|
|
+ "strings"
|
|
|
|
"golang.org/x/tools/go/analysis"
|
|
)
|
|
@@ -20,6 +21,7 @@ var (
|
|
argBlank bool
|
|
argAsserts bool
|
|
argExcludeFile string
|
|
+ argExcludes string
|
|
argExcludeOnly bool
|
|
)
|
|
|
|
@@ -27,6 +29,7 @@ func init() {
|
|
Analyzer.Flags.BoolVar(&argBlank, "blank", false, "if true, check for errors assigned to blank identifier")
|
|
Analyzer.Flags.BoolVar(&argAsserts, "assert", false, "if true, check for ignored type assertion results")
|
|
Analyzer.Flags.StringVar(&argExcludeFile, "exclude", "", "Path to a file containing a list of functions to exclude from checking")
|
|
+ Analyzer.Flags.StringVar(&argExcludes, "excludes", "", "Contents of the exclude file as a string (overrides -exclude)")
|
|
Analyzer.Flags.BoolVar(&argExcludeOnly, "excludeonly", false, "Use only excludes from exclude file")
|
|
}
|
|
|
|
@@ -38,7 +41,14 @@ func runAnalyzer(pass *analysis.Pass) (interface{}, error) {
|
|
exclude[name] = true
|
|
}
|
|
}
|
|
- if argExcludeFile != "" {
|
|
+ if argExcludes != "" {
|
|
+ for _, name := range strings.Split(argExcludes, "\n") {
|
|
+ if strings.HasPrefix(name, "//") || name == "" {
|
|
+ continue
|
|
+ }
|
|
+ exclude[name] = true
|
|
+ }
|
|
+ } else if argExcludeFile != "" {
|
|
excludes, err := ReadExcludes(argExcludeFile)
|
|
if err != nil {
|
|
return nil, fmt.Errorf("Could not read exclude file: %v\n", err)
|
|
--
|
|
2.30.1 (Apple Git-130)
|
|
|