Update module spf13/viper to v1.7.0 (#494)
Update module spf13/viper to v1.7.0 Reviewed-on: https://kolaente.dev/vikunja/api/pulls/494
This commit is contained in:
25
vendor/honnef.co/go/tools/stylecheck/names.go
vendored
25
vendor/honnef.co/go/tools/stylecheck/names.go
vendored
@ -9,7 +9,8 @@ import (
|
||||
"strings"
|
||||
"unicode"
|
||||
|
||||
"honnef.co/go/tools/lint"
|
||||
"golang.org/x/tools/go/analysis"
|
||||
"honnef.co/go/tools/config"
|
||||
. "honnef.co/go/tools/lint/lintdsl"
|
||||
)
|
||||
|
||||
@ -21,7 +22,7 @@ var knownNameExceptions = map[string]bool{
|
||||
"kWh": true,
|
||||
}
|
||||
|
||||
func (c *Checker) CheckNames(j *lint.Job) {
|
||||
func CheckNames(pass *analysis.Pass) (interface{}, error) {
|
||||
// A large part of this function is copied from
|
||||
// github.com/golang/lint, Copyright (c) 2013 The Go Authors,
|
||||
// licensed under the BSD 3-clause license.
|
||||
@ -45,7 +46,7 @@ func (c *Checker) CheckNames(j *lint.Job) {
|
||||
|
||||
// Handle two common styles from other languages that don't belong in Go.
|
||||
if len(id.Name) >= 5 && allCaps(id.Name) && strings.Contains(id.Name, "_") {
|
||||
j.Errorf(id, "should not use ALL_CAPS in Go names; use CamelCase instead")
|
||||
ReportfFG(pass, id.Pos(), "should not use ALL_CAPS in Go names; use CamelCase instead")
|
||||
return
|
||||
}
|
||||
|
||||
@ -55,10 +56,10 @@ func (c *Checker) CheckNames(j *lint.Job) {
|
||||
}
|
||||
|
||||
if len(id.Name) > 2 && strings.Contains(id.Name[1:len(id.Name)-1], "_") {
|
||||
j.Errorf(id, "should not use underscores in Go names; %s %s should be %s", thing, id.Name, should)
|
||||
ReportfFG(pass, id.Pos(), "should not use underscores in Go names; %s %s should be %s", thing, id.Name, should)
|
||||
return
|
||||
}
|
||||
j.Errorf(id, "%s %s should be %s", thing, id.Name, should)
|
||||
ReportfFG(pass, id.Pos(), "%s %s should be %s", thing, id.Name, should)
|
||||
}
|
||||
checkList := func(fl *ast.FieldList, thing string, initialisms map[string]bool) {
|
||||
if fl == nil {
|
||||
@ -71,17 +72,18 @@ func (c *Checker) CheckNames(j *lint.Job) {
|
||||
}
|
||||
}
|
||||
|
||||
initialisms := make(map[string]bool, len(j.Pkg.Config.Initialisms))
|
||||
for _, word := range j.Pkg.Config.Initialisms {
|
||||
il := config.For(pass).Initialisms
|
||||
initialisms := make(map[string]bool, len(il))
|
||||
for _, word := range il {
|
||||
initialisms[word] = true
|
||||
}
|
||||
for _, f := range j.Pkg.Syntax {
|
||||
for _, f := range pass.Files {
|
||||
// Package names need slightly different handling than other names.
|
||||
if !strings.HasSuffix(f.Name.Name, "_test") && strings.Contains(f.Name.Name, "_") {
|
||||
j.Errorf(f, "should not use underscores in package names")
|
||||
ReportfFG(pass, f.Pos(), "should not use underscores in package names")
|
||||
}
|
||||
if strings.IndexFunc(f.Name.Name, unicode.IsUpper) != -1 {
|
||||
j.Errorf(f, "should not use MixedCaps in package name; %s should be %s", f.Name.Name, strings.ToLower(f.Name.Name))
|
||||
ReportfFG(pass, f.Pos(), "should not use MixedCaps in package name; %s should be %s", f.Name.Name, strings.ToLower(f.Name.Name))
|
||||
}
|
||||
|
||||
ast.Inspect(f, func(node ast.Node) bool {
|
||||
@ -104,7 +106,7 @@ func (c *Checker) CheckNames(j *lint.Job) {
|
||||
return true
|
||||
}
|
||||
|
||||
if IsInTest(j, v) && (strings.HasPrefix(v.Name.Name, "Example") || strings.HasPrefix(v.Name.Name, "Test") || strings.HasPrefix(v.Name.Name, "Benchmark")) {
|
||||
if IsInTest(pass, v) && (strings.HasPrefix(v.Name.Name, "Example") || strings.HasPrefix(v.Name.Name, "Test") || strings.HasPrefix(v.Name.Name, "Benchmark")) {
|
||||
return true
|
||||
}
|
||||
|
||||
@ -173,6 +175,7 @@ func (c *Checker) CheckNames(j *lint.Job) {
|
||||
return true
|
||||
})
|
||||
}
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
// lintName returns a different name if it should be different.
|
||||
|
Reference in New Issue
Block a user