mirror of
https://github.com/mgechev/revive.git
synced 2025-03-17 20:57:58 +02:00
parent
7cb4540a46
commit
16871ed55f
@ -27,10 +27,10 @@ type packages struct {
|
||||
|
||||
func (ps *packages) methodNames(lp *lint.Package) pkgMethods {
|
||||
ps.mu.Lock()
|
||||
defer ps.mu.Unlock()
|
||||
|
||||
for _, pkg := range ps.pkgs {
|
||||
if pkg.pkg == lp {
|
||||
ps.mu.Unlock()
|
||||
return pkg
|
||||
}
|
||||
}
|
||||
@ -38,7 +38,6 @@ func (ps *packages) methodNames(lp *lint.Package) pkgMethods {
|
||||
pkgm := pkgMethods{pkg: lp, methods: make(map[string]map[string]*referenceMethod), mu: &sync.Mutex{}}
|
||||
ps.pkgs = append(ps.pkgs, pkgm)
|
||||
|
||||
ps.mu.Unlock()
|
||||
return pkgm
|
||||
}
|
||||
|
||||
@ -72,6 +71,7 @@ func (*ConfusingNamingRule) Name() string {
|
||||
|
||||
// checkMethodName checks if a given method/function name is similar (just case differences) to other method/function of the same struct/file.
|
||||
func checkMethodName(holder string, id *ast.Ident, w *lintConfusingNames) {
|
||||
|
||||
if id.Name == "init" && holder == defaultStructName {
|
||||
// ignore init functions
|
||||
return
|
||||
@ -137,8 +137,11 @@ func getStructName(r *ast.FieldList) string {
|
||||
|
||||
t := r.List[0].Type
|
||||
|
||||
if p, _ := t.(*ast.StarExpr); p != nil { // if a pointer receiver => dereference pointer receiver types
|
||||
t = p.X
|
||||
switch v := t.(type) {
|
||||
case *ast.StarExpr:
|
||||
t = v.X
|
||||
case *ast.IndexExpr:
|
||||
t = v.X
|
||||
}
|
||||
|
||||
if p, _ := t.(*ast.Ident); p != nil {
|
||||
|
12
testdata/confusing-naming1.go
vendored
12
testdata/confusing-naming1.go
vendored
@ -1,5 +1,4 @@
|
||||
// Test of confusing-naming rule.
|
||||
|
||||
// Package pkg ...
|
||||
package pkg
|
||||
|
||||
@ -60,3 +59,14 @@ type tBar struct {
|
||||
qwe bool
|
||||
zxc float32
|
||||
}
|
||||
|
||||
// issue #864
|
||||
type x[T any] struct{}
|
||||
|
||||
func (x[T]) method() {
|
||||
}
|
||||
|
||||
type y[T any] struct{}
|
||||
|
||||
func (y[T]) method() {
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user