Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build(deps): bump honnef.co/go/tools from 0.1.1 to 0.1.3 #2

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion go.mod
Expand Up @@ -15,7 +15,7 @@ require (
google.golang.org/grpc v1.35.0
google.golang.org/protobuf v1.25.0
gopkg.in/yaml.v2 v2.4.0
honnef.co/go/tools v0.1.1
honnef.co/go/tools v0.1.3
)

// Replace directives from github.com/cilium/cilium. Keep in sync when updating Cilium!
Expand Down
4 changes: 2 additions & 2 deletions go.sum

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 13 additions & 0 deletions vendor/honnef.co/go/tools/go/ir/exits.go
Expand Up @@ -58,6 +58,19 @@ func (b *builder) buildExits(fn *Function) {
// via the first argument. We don't currently support
// call-site-specific exit information.
}
case "github.com/golang/glog":
switch obj.(*types.Func).FullName() {
case "github.com/golang/glog.Exit",
"github.com/golang/glog.ExitDepth",
"github.com/golang/glog.Exitf",
"github.com/golang/glog.Exitln",
"github.com/golang/glog.Fatal",
"github.com/golang/glog.FatalDepth",
"github.com/golang/glog.Fatalf",
"github.com/golang/glog.Fatalln":
// all of these call os.Exit after logging
fn.NoReturn = AlwaysExits
}
}
}

Expand Down
4 changes: 2 additions & 2 deletions vendor/honnef.co/go/tools/lintcmd/version/version.go
Expand Up @@ -7,8 +7,8 @@ import (
"runtime"
)

const Version = "2020.2.1"
const MachineVersion = "v0.1.1"
const Version = "2020.2.3"
const MachineVersion = "v0.1.3"

// version returns a version descriptor and reports whether the
// version is a known release.
Expand Down
122 changes: 67 additions & 55 deletions vendor/honnef.co/go/tools/pattern/match.go
Expand Up @@ -9,52 +9,56 @@ import (
)

var tokensByString = map[string]Token{
"INT": Token(token.INT),
"FLOAT": Token(token.FLOAT),
"IMAG": Token(token.IMAG),
"CHAR": Token(token.CHAR),
"STRING": Token(token.STRING),
"+": Token(token.ADD),
"-": Token(token.SUB),
"*": Token(token.MUL),
"/": Token(token.QUO),
"%": Token(token.REM),
"&": Token(token.AND),
"|": Token(token.OR),
"^": Token(token.XOR),
"<<": Token(token.SHL),
">>": Token(token.SHR),
"&^": Token(token.AND_NOT),
"+=": Token(token.ADD_ASSIGN),
"-=": Token(token.SUB_ASSIGN),
"*=": Token(token.MUL_ASSIGN),
"/=": Token(token.QUO_ASSIGN),
"%=": Token(token.REM_ASSIGN),
"&=": Token(token.AND_ASSIGN),
"|=": Token(token.OR_ASSIGN),
"^=": Token(token.XOR_ASSIGN),
"<<=": Token(token.SHL_ASSIGN),
">>=": Token(token.SHR_ASSIGN),
"&^=": Token(token.AND_NOT_ASSIGN),
"&&": Token(token.LAND),
"||": Token(token.LOR),
"<-": Token(token.ARROW),
"++": Token(token.INC),
"--": Token(token.DEC),
"==": Token(token.EQL),
"<": Token(token.LSS),
">": Token(token.GTR),
"=": Token(token.ASSIGN),
"!": Token(token.NOT),
"!=": Token(token.NEQ),
"<=": Token(token.LEQ),
">=": Token(token.GEQ),
":=": Token(token.DEFINE),
"...": Token(token.ELLIPSIS),
"IMPORT": Token(token.IMPORT),
"VAR": Token(token.VAR),
"TYPE": Token(token.TYPE),
"CONST": Token(token.CONST),
"INT": Token(token.INT),
"FLOAT": Token(token.FLOAT),
"IMAG": Token(token.IMAG),
"CHAR": Token(token.CHAR),
"STRING": Token(token.STRING),
"+": Token(token.ADD),
"-": Token(token.SUB),
"*": Token(token.MUL),
"/": Token(token.QUO),
"%": Token(token.REM),
"&": Token(token.AND),
"|": Token(token.OR),
"^": Token(token.XOR),
"<<": Token(token.SHL),
">>": Token(token.SHR),
"&^": Token(token.AND_NOT),
"+=": Token(token.ADD_ASSIGN),
"-=": Token(token.SUB_ASSIGN),
"*=": Token(token.MUL_ASSIGN),
"/=": Token(token.QUO_ASSIGN),
"%=": Token(token.REM_ASSIGN),
"&=": Token(token.AND_ASSIGN),
"|=": Token(token.OR_ASSIGN),
"^=": Token(token.XOR_ASSIGN),
"<<=": Token(token.SHL_ASSIGN),
">>=": Token(token.SHR_ASSIGN),
"&^=": Token(token.AND_NOT_ASSIGN),
"&&": Token(token.LAND),
"||": Token(token.LOR),
"<-": Token(token.ARROW),
"++": Token(token.INC),
"--": Token(token.DEC),
"==": Token(token.EQL),
"<": Token(token.LSS),
">": Token(token.GTR),
"=": Token(token.ASSIGN),
"!": Token(token.NOT),
"!=": Token(token.NEQ),
"<=": Token(token.LEQ),
">=": Token(token.GEQ),
":=": Token(token.DEFINE),
"...": Token(token.ELLIPSIS),
"IMPORT": Token(token.IMPORT),
"VAR": Token(token.VAR),
"TYPE": Token(token.TYPE),
"CONST": Token(token.CONST),
"BREAK": Token(token.BREAK),
"CONTINUE": Token(token.CONTINUE),
"GOTO": Token(token.GOTO),
"FALLTHROUGH": Token(token.FALLTHROUGH),
}

func maybeToken(node Node) (Node, bool) {
Expand Down Expand Up @@ -438,26 +442,28 @@ func (tok Token) Match(m *Matcher, node interface{}) (interface{}, bool) {
}

func (Nil) Match(m *Matcher, node interface{}) (interface{}, bool) {
return nil, isNil(node)
return nil, isNil(node) || reflect.ValueOf(node).IsNil()
}

func (builtin Builtin) Match(m *Matcher, node interface{}) (interface{}, bool) {
ident, ok := node.(*ast.Ident)
r, ok := match(m, Ident(builtin), node)
if !ok {
return nil, false
}
ident := r.(*ast.Ident)
obj := m.TypesInfo.ObjectOf(ident)
if obj != types.Universe.Lookup(ident.Name) {
return nil, false
}
return match(m, builtin.Name, ident.Name)
return ident, true
}

func (obj Object) Match(m *Matcher, node interface{}) (interface{}, bool) {
ident, ok := node.(*ast.Ident)
r, ok := match(m, Ident(obj), node)
if !ok {
return nil, false
}
ident := r.(*ast.Ident)

id := m.TypesInfo.ObjectOf(ident)
_, ok = match(m, obj.Name, ident.Name)
Expand All @@ -467,9 +473,15 @@ func (obj Object) Match(m *Matcher, node interface{}) (interface{}, bool) {
func (fn Function) Match(m *Matcher, node interface{}) (interface{}, bool) {
var name string
var obj types.Object
switch node := node.(type) {

r, ok := match(m, Or{Nodes: []Node{Ident{Any{}}, SelectorExpr{Any{}, Any{}}}}, node)
if !ok {
return nil, false
}

switch r := r.(type) {
case *ast.Ident:
obj = m.TypesInfo.ObjectOf(node)
obj = m.TypesInfo.ObjectOf(r)
switch obj := obj.(type) {
case *types.Func:
// OPT(dh): optimize this similar to code.FuncName
Expand All @@ -481,16 +493,16 @@ func (fn Function) Match(m *Matcher, node interface{}) (interface{}, bool) {
}
case *ast.SelectorExpr:
var ok bool
obj, ok = m.TypesInfo.ObjectOf(node.Sel).(*types.Func)
obj, ok = m.TypesInfo.ObjectOf(r.Sel).(*types.Func)
if !ok {
return nil, false
}
// OPT(dh): optimize this similar to code.FuncName
name = obj.(*types.Func).FullName()
default:
return nil, false
panic("unreachable")
}
_, ok := match(m, fn.Name, name)
_, ok = match(m, fn.Name, name)
return obj, ok
}

Expand Down
38 changes: 24 additions & 14 deletions vendor/honnef.co/go/tools/staticcheck/lint.go
Expand Up @@ -1384,6 +1384,13 @@ func CheckUnsafePrintf(pass *analysis.Pass) (interface{}, error) {
return
}

if _, ok := pass.TypesInfo.TypeOf(call.Args[arg]).(*types.Tuple); ok {
// the called function returns multiple values and got
// splatted into the call. for all we know, it is
// returning good arguments.
return
}

alt := name[:len(name)-1]
report.Report(pass, call,
"printf-style function with dynamic format string and no further arguments should use print-style function instead",
Expand Down Expand Up @@ -2807,19 +2814,13 @@ func isIota(obj types.Object) bool {
func CheckNonOctalFileMode(pass *analysis.Pass) (interface{}, error) {
fn := func(node ast.Node) {
call := node.(*ast.CallExpr)
sig, ok := pass.TypesInfo.TypeOf(call.Fun).(*types.Signature)
if !ok {
return
}
n := sig.Params().Len()
for i := 0; i < n; i++ {
typ := sig.Params().At(i).Type()
if !typeutil.IsType(typ, "os.FileMode") {
for _, arg := range call.Args {
lit, ok := arg.(*ast.BasicLit)
if !ok {
continue
}

lit, ok := call.Args[i].(*ast.BasicLit)
if !ok {
if !typeutil.IsType(pass.TypesInfo.TypeOf(lit), "os.FileMode") &&
!typeutil.IsType(pass.TypesInfo.TypeOf(lit), "io/fs.FileMode") {
continue
}
if len(lit.Value) == 3 &&
Expand All @@ -2832,8 +2833,8 @@ func CheckNonOctalFileMode(pass *analysis.Pass) (interface{}, error) {
if err != nil {
continue
}
report.Report(pass, call.Args[i], fmt.Sprintf("file mode '%s' evaluates to %#o; did you mean '0%s'?", lit.Value, v, lit.Value),
report.Fixes(edit.Fix("fix octal literal", edit.ReplaceWithString(pass.Fset, call.Args[i], "0"+lit.Value))))
report.Report(pass, arg, fmt.Sprintf("file mode '%s' evaluates to %#o; did you mean '0%s'?", lit.Value, v, lit.Value),
report.Fixes(edit.Fix("fix octal literal", edit.ReplaceWithString(pass.Fset, arg, "0"+lit.Value))))
}
}
}
Expand Down Expand Up @@ -3068,7 +3069,16 @@ func checkCalls(pass *analysis.Pass, rules map[string]CallCheck) (interface{}, e
for idx, arg := range call.Args {
for _, e := range arg.invalids {
if astcall != nil {
report.Report(pass, astcall.Args[idx], e)
if idx < len(astcall.Args) {
report.Report(pass, astcall.Args[idx], e)
} else {
// this is an instance of fn1(fn2()) where fn2
// returns multiple values. Report the error
// at the next-best position that we have, the
// first argument. An example of a check that
// triggers this is checkEncodingBinaryRules.
report.Report(pass, astcall.Args[0], e)
}
} else {
report.Report(pass, site, e)
}
Expand Down
3 changes: 3 additions & 0 deletions vendor/honnef.co/go/tools/stylecheck/lint.go
Expand Up @@ -608,6 +608,9 @@ func CheckHTTPStatusCodes(pass *analysis.Pass) (interface{}, error) {
default:
return
}
if arg >= len(call.Args) {
return
}
lit, ok := call.Args[arg].(*ast.BasicLit)
if !ok {
return
Expand Down