staticcheck (#313)
* CI: use staticcheck for linting This commit switches the linter for Go code from golint to staticcheck. Golint has been deprecated since last year and staticcheck is a recommended replacement. Signed-off-by: Lucas Servén Marín <lserven@gmail.com> * revendor Signed-off-by: Lucas Servén Marín <lserven@gmail.com> * cmd,pkg: fix lint warnings Signed-off-by: Lucas Servén Marín <lserven@gmail.com>
This commit is contained in:
committed by
GitHub
parent
93f46e03ea
commit
50fbc2eec2
59
vendor/honnef.co/go/tools/unused/edge.go
vendored
Normal file
59
vendor/honnef.co/go/tools/unused/edge.go
vendored
Normal file
@@ -0,0 +1,59 @@
|
||||
package unused
|
||||
|
||||
//go:generate go run golang.org/x/tools/cmd/stringer@master -type edgeKind
|
||||
type edgeKind uint64
|
||||
|
||||
func (e edgeKind) is(o edgeKind) bool {
|
||||
return e&o != 0
|
||||
}
|
||||
|
||||
const (
|
||||
edgeAlias edgeKind = 1 << iota
|
||||
edgeBlankField
|
||||
edgeAnonymousStruct
|
||||
edgeCgoExported
|
||||
edgeConstGroup
|
||||
edgeElementType
|
||||
edgeEmbeddedInterface
|
||||
edgeExportedConstant
|
||||
edgeExportedField
|
||||
edgeExportedFunction
|
||||
edgeExportedMethod
|
||||
edgeExportedType
|
||||
edgeExportedVariable
|
||||
edgeExtendsExportedFields
|
||||
edgeExtendsExportedMethodSet
|
||||
edgeFieldAccess
|
||||
edgeFunctionArgument
|
||||
edgeFunctionResult
|
||||
edgeFunctionSignature
|
||||
edgeImplements
|
||||
edgeInstructionOperand
|
||||
edgeInterfaceCall
|
||||
edgeInterfaceMethod
|
||||
edgeKeyType
|
||||
edgeLinkname
|
||||
edgeMainFunction
|
||||
edgeNamedType
|
||||
edgeNetRPCRegister
|
||||
edgeNoCopySentinel
|
||||
edgeProvidesMethod
|
||||
edgeReceiver
|
||||
edgeRuntimeFunction
|
||||
edgeSignature
|
||||
edgeStructConversion
|
||||
edgeTestSink
|
||||
edgeTupleElement
|
||||
edgeType
|
||||
edgeTypeName
|
||||
edgeUnderlyingType
|
||||
edgePointerType
|
||||
edgeUnsafeConversion
|
||||
edgeUsedConstant
|
||||
edgeVarDecl
|
||||
edgeIgnored
|
||||
edgeSamePointer
|
||||
edgeTypeParam
|
||||
edgeTypeArg
|
||||
edgeUnionTerm
|
||||
)
|
119
vendor/honnef.co/go/tools/unused/edgekind_string.go
vendored
Normal file
119
vendor/honnef.co/go/tools/unused/edgekind_string.go
vendored
Normal file
@@ -0,0 +1,119 @@
|
||||
// Code generated by "stringer -type edgeKind"; DO NOT EDIT.
|
||||
|
||||
package unused
|
||||
|
||||
import "strconv"
|
||||
|
||||
func _() {
|
||||
// An "invalid array index" compiler error signifies that the constant values have changed.
|
||||
// Re-run the stringer command to generate them again.
|
||||
var x [1]struct{}
|
||||
_ = x[edgeAlias-1]
|
||||
_ = x[edgeBlankField-2]
|
||||
_ = x[edgeAnonymousStruct-4]
|
||||
_ = x[edgeCgoExported-8]
|
||||
_ = x[edgeConstGroup-16]
|
||||
_ = x[edgeElementType-32]
|
||||
_ = x[edgeEmbeddedInterface-64]
|
||||
_ = x[edgeExportedConstant-128]
|
||||
_ = x[edgeExportedField-256]
|
||||
_ = x[edgeExportedFunction-512]
|
||||
_ = x[edgeExportedMethod-1024]
|
||||
_ = x[edgeExportedType-2048]
|
||||
_ = x[edgeExportedVariable-4096]
|
||||
_ = x[edgeExtendsExportedFields-8192]
|
||||
_ = x[edgeExtendsExportedMethodSet-16384]
|
||||
_ = x[edgeFieldAccess-32768]
|
||||
_ = x[edgeFunctionArgument-65536]
|
||||
_ = x[edgeFunctionResult-131072]
|
||||
_ = x[edgeFunctionSignature-262144]
|
||||
_ = x[edgeImplements-524288]
|
||||
_ = x[edgeInstructionOperand-1048576]
|
||||
_ = x[edgeInterfaceCall-2097152]
|
||||
_ = x[edgeInterfaceMethod-4194304]
|
||||
_ = x[edgeKeyType-8388608]
|
||||
_ = x[edgeLinkname-16777216]
|
||||
_ = x[edgeMainFunction-33554432]
|
||||
_ = x[edgeNamedType-67108864]
|
||||
_ = x[edgeNetRPCRegister-134217728]
|
||||
_ = x[edgeNoCopySentinel-268435456]
|
||||
_ = x[edgeProvidesMethod-536870912]
|
||||
_ = x[edgeReceiver-1073741824]
|
||||
_ = x[edgeRuntimeFunction-2147483648]
|
||||
_ = x[edgeSignature-4294967296]
|
||||
_ = x[edgeStructConversion-8589934592]
|
||||
_ = x[edgeTestSink-17179869184]
|
||||
_ = x[edgeTupleElement-34359738368]
|
||||
_ = x[edgeType-68719476736]
|
||||
_ = x[edgeTypeName-137438953472]
|
||||
_ = x[edgeUnderlyingType-274877906944]
|
||||
_ = x[edgePointerType-549755813888]
|
||||
_ = x[edgeUnsafeConversion-1099511627776]
|
||||
_ = x[edgeUsedConstant-2199023255552]
|
||||
_ = x[edgeVarDecl-4398046511104]
|
||||
_ = x[edgeIgnored-8796093022208]
|
||||
_ = x[edgeSamePointer-17592186044416]
|
||||
_ = x[edgeTypeParam-35184372088832]
|
||||
_ = x[edgeTypeArg-70368744177664]
|
||||
_ = x[edgeUnionTerm-140737488355328]
|
||||
}
|
||||
|
||||
const _edgeKind_name = "edgeAliasedgeBlankFieldedgeAnonymousStructedgeCgoExportededgeConstGroupedgeElementTypeedgeEmbeddedInterfaceedgeExportedConstantedgeExportedFieldedgeExportedFunctionedgeExportedMethodedgeExportedTypeedgeExportedVariableedgeExtendsExportedFieldsedgeExtendsExportedMethodSetedgeFieldAccessedgeFunctionArgumentedgeFunctionResultedgeFunctionSignatureedgeImplementsedgeInstructionOperandedgeInterfaceCalledgeInterfaceMethodedgeKeyTypeedgeLinknameedgeMainFunctionedgeNamedTypeedgeNetRPCRegisteredgeNoCopySentineledgeProvidesMethodedgeReceiveredgeRuntimeFunctionedgeSignatureedgeStructConversionedgeTestSinkedgeTupleElementedgeTypeedgeTypeNameedgeUnderlyingTypeedgePointerTypeedgeUnsafeConversionedgeUsedConstantedgeVarDecledgeIgnorededgeSamePointeredgeTypeParamedgeTypeArgedgeUnionTerm"
|
||||
|
||||
var _edgeKind_map = map[edgeKind]string{
|
||||
1: _edgeKind_name[0:9],
|
||||
2: _edgeKind_name[9:23],
|
||||
4: _edgeKind_name[23:42],
|
||||
8: _edgeKind_name[42:57],
|
||||
16: _edgeKind_name[57:71],
|
||||
32: _edgeKind_name[71:86],
|
||||
64: _edgeKind_name[86:107],
|
||||
128: _edgeKind_name[107:127],
|
||||
256: _edgeKind_name[127:144],
|
||||
512: _edgeKind_name[144:164],
|
||||
1024: _edgeKind_name[164:182],
|
||||
2048: _edgeKind_name[182:198],
|
||||
4096: _edgeKind_name[198:218],
|
||||
8192: _edgeKind_name[218:243],
|
||||
16384: _edgeKind_name[243:271],
|
||||
32768: _edgeKind_name[271:286],
|
||||
65536: _edgeKind_name[286:306],
|
||||
131072: _edgeKind_name[306:324],
|
||||
262144: _edgeKind_name[324:345],
|
||||
524288: _edgeKind_name[345:359],
|
||||
1048576: _edgeKind_name[359:381],
|
||||
2097152: _edgeKind_name[381:398],
|
||||
4194304: _edgeKind_name[398:417],
|
||||
8388608: _edgeKind_name[417:428],
|
||||
16777216: _edgeKind_name[428:440],
|
||||
33554432: _edgeKind_name[440:456],
|
||||
67108864: _edgeKind_name[456:469],
|
||||
134217728: _edgeKind_name[469:487],
|
||||
268435456: _edgeKind_name[487:505],
|
||||
536870912: _edgeKind_name[505:523],
|
||||
1073741824: _edgeKind_name[523:535],
|
||||
2147483648: _edgeKind_name[535:554],
|
||||
4294967296: _edgeKind_name[554:567],
|
||||
8589934592: _edgeKind_name[567:587],
|
||||
17179869184: _edgeKind_name[587:599],
|
||||
34359738368: _edgeKind_name[599:615],
|
||||
68719476736: _edgeKind_name[615:623],
|
||||
137438953472: _edgeKind_name[623:635],
|
||||
274877906944: _edgeKind_name[635:653],
|
||||
549755813888: _edgeKind_name[653:668],
|
||||
1099511627776: _edgeKind_name[668:688],
|
||||
2199023255552: _edgeKind_name[688:704],
|
||||
4398046511104: _edgeKind_name[704:715],
|
||||
8796093022208: _edgeKind_name[715:726],
|
||||
17592186044416: _edgeKind_name[726:741],
|
||||
35184372088832: _edgeKind_name[741:754],
|
||||
70368744177664: _edgeKind_name[754:765],
|
||||
140737488355328: _edgeKind_name[765:778],
|
||||
}
|
||||
|
||||
func (i edgeKind) String() string {
|
||||
if str, ok := _edgeKind_map[i]; ok {
|
||||
return str
|
||||
}
|
||||
return "edgeKind(" + strconv.FormatInt(int64(i), 10) + ")"
|
||||
}
|
82
vendor/honnef.co/go/tools/unused/implements.go
vendored
Normal file
82
vendor/honnef.co/go/tools/unused/implements.go
vendored
Normal file
@@ -0,0 +1,82 @@
|
||||
package unused
|
||||
|
||||
import "go/types"
|
||||
|
||||
// lookupMethod returns the index of and method with matching package and name, or (-1, nil).
|
||||
func lookupMethod(T *types.Interface, pkg *types.Package, name string) (int, *types.Func) {
|
||||
if name != "_" {
|
||||
for i := 0; i < T.NumMethods(); i++ {
|
||||
m := T.Method(i)
|
||||
if sameId(m, pkg, name) {
|
||||
return i, m
|
||||
}
|
||||
}
|
||||
}
|
||||
return -1, nil
|
||||
}
|
||||
|
||||
func sameId(obj types.Object, pkg *types.Package, name string) bool {
|
||||
// spec:
|
||||
// "Two identifiers are different if they are spelled differently,
|
||||
// or if they appear in different packages and are not exported.
|
||||
// Otherwise, they are the same."
|
||||
if name != obj.Name() {
|
||||
return false
|
||||
}
|
||||
// obj.Name == name
|
||||
if obj.Exported() {
|
||||
return true
|
||||
}
|
||||
// not exported, so packages must be the same (pkg == nil for
|
||||
// fields in Universe scope; this can only happen for types
|
||||
// introduced via Eval)
|
||||
if pkg == nil || obj.Pkg() == nil {
|
||||
return pkg == obj.Pkg()
|
||||
}
|
||||
// pkg != nil && obj.pkg != nil
|
||||
return pkg.Path() == obj.Pkg().Path()
|
||||
}
|
||||
|
||||
func (g *graph) implements(V types.Type, T *types.Interface, msV *types.MethodSet) ([]*types.Selection, bool) {
|
||||
// fast path for common case
|
||||
if T.Empty() {
|
||||
return nil, true
|
||||
}
|
||||
|
||||
if ityp, _ := V.Underlying().(*types.Interface); ityp != nil {
|
||||
// TODO(dh): is this code reachable?
|
||||
for i := 0; i < T.NumMethods(); i++ {
|
||||
m := T.Method(i)
|
||||
_, obj := lookupMethod(ityp, m.Pkg(), m.Name())
|
||||
switch {
|
||||
case obj == nil:
|
||||
return nil, false
|
||||
case !types.Identical(obj.Type(), m.Type()):
|
||||
return nil, false
|
||||
}
|
||||
}
|
||||
return nil, true
|
||||
}
|
||||
|
||||
// A concrete type implements T if it implements all methods of T.
|
||||
var sels []*types.Selection
|
||||
for i := 0; i < T.NumMethods(); i++ {
|
||||
m := T.Method(i)
|
||||
sel := msV.Lookup(m.Pkg(), m.Name())
|
||||
if sel == nil {
|
||||
return nil, false
|
||||
}
|
||||
|
||||
f, _ := sel.Obj().(*types.Func)
|
||||
if f == nil {
|
||||
return nil, false
|
||||
}
|
||||
|
||||
if !types.Identical(f.Type(), m.Type()) {
|
||||
return nil, false
|
||||
}
|
||||
|
||||
sels = append(sels, sel)
|
||||
}
|
||||
return sels, true
|
||||
}
|
1854
vendor/honnef.co/go/tools/unused/unused.go
vendored
Normal file
1854
vendor/honnef.co/go/tools/unused/unused.go
vendored
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user