@@ -74,7 +74,7 @@ type WrapcheckConfig struct {
74
74
// to a underlying interface name, will ignore unwrapped errors returned from a
75
75
// function whose call is defined on the given interface.
76
76
//
77
- // For example, an ignoreInterfaceRegexps of `[]string{"Transac(tor|tion)"}`` will ignore errors
77
+ // For example, an ignoreInterfaceRegexps of `[]string{"Transac(tor|tion)"}` will ignore errors
78
78
// returned from any function whose call is defined on a interface named 'Transactor'
79
79
// or 'Transaction' due to the name matching the regular expression `Transac(tor|tion)`.
80
80
IgnoreInterfaceRegexps []string `mapstructure:"ignoreInterfaceRegexps" yaml:"ignoreInterfaceRegexps"`
@@ -112,7 +112,6 @@ func run(cfg WrapcheckConfig) func(*analysis.Pass) (interface{}, error) {
112
112
}
113
113
if err == nil {
114
114
ignorePackageGlobs , err = compileGlobs (cfg .IgnorePackageGlobs )
115
-
116
115
}
117
116
118
117
return func (pass * analysis.Pass ) (interface {}, error ) {
@@ -305,7 +304,7 @@ func isFromOtherPkg(pass *analysis.Pass, sel *ast.SelectorExpr, pkgGlobs []glob.
305
304
// `=`. This does not include `var` statements. This function will return nil if
306
305
// the only declaration is a `var` (aka ValueSpec) declaration.
307
306
func prevErrAssign (pass * analysis.Pass , file * ast.File , returnIdent * ast.Ident ) * ast.AssignStmt {
308
- // A slice containing all the assignments which contain an identifer
307
+ // A slice containing all the assignments which contain an identifier
309
308
// referring to the source declaration of the error. This is to catch
310
309
// cases where err is defined once, and then reassigned multiple times
311
310
// within the same block. In these cases, we should check the method of
@@ -399,14 +398,14 @@ func isUnresolved(file *ast.File, ident *ast.Ident) bool {
399
398
// compileRegexps compiles a set of regular expressions returning them for use,
400
399
// or the first encountered error due to an invalid expression.
401
400
func compileRegexps (regexps []string ) ([]* regexp.Regexp , error ) {
402
- var compiledRegexps []* regexp.Regexp
403
- for _ , reg := range regexps {
401
+ compiledRegexps := make ( []* regexp.Regexp , len ( regexps ))
402
+ for idx , reg := range regexps {
404
403
re , err := regexp .Compile (reg )
405
404
if err != nil {
406
405
return nil , fmt .Errorf ("unable to compile regexp %s: %v\n " , reg , err )
407
406
}
408
407
409
- compiledRegexps = append ( compiledRegexps , re )
408
+ compiledRegexps [ idx ] = re
410
409
}
411
410
412
411
return compiledRegexps , nil
@@ -415,14 +414,14 @@ func compileRegexps(regexps []string) ([]*regexp.Regexp, error) {
415
414
// compileGlobs compiles a set of globs, returning them for use,
416
415
// or the first encountered error due to an invalid expression.
417
416
func compileGlobs (globs []string ) ([]glob.Glob , error ) {
418
- var compiledGlobs []glob.Glob
419
- for _ , globString := range globs {
417
+ compiledGlobs := make ( []glob.Glob , len ( globs ))
418
+ for idx , globString := range globs {
420
419
glob , err := glob .Compile (globString )
421
420
if err != nil {
422
421
return nil , fmt .Errorf ("unable to compile globs %s: %v\n " , glob , err )
423
422
}
424
423
425
- compiledGlobs = append ( compiledGlobs , glob )
424
+ compiledGlobs [ idx ] = glob
426
425
}
427
426
return compiledGlobs , nil
428
427
}
0 commit comments