mirror of
https://github.com/mgechev/revive.git
synced 2025-10-08 22:41:54 +02:00
fix: rule confusing-naming
false positive on multiple blank identifiers (#1536)
This commit is contained in:
@@ -167,6 +167,11 @@ func checkStructFields(fields *ast.FieldList, structName string, w *lintConfusin
|
||||
bl := make(map[string]bool, len(fields.List))
|
||||
for _, f := range fields.List {
|
||||
for _, id := range f.Names {
|
||||
// Skip blank identifiers
|
||||
if id.Name == "_" {
|
||||
continue
|
||||
}
|
||||
|
||||
normName := strings.ToUpper(id.Name)
|
||||
if bl[normName] {
|
||||
w.onFailure(lint.Failure{
|
||||
|
14
testdata/confusing_naming1.go
vendored
14
testdata/confusing_naming1.go
vendored
@@ -81,3 +81,17 @@ type b[T any] struct{}
|
||||
|
||||
func (x *b[T]) method() {
|
||||
}
|
||||
|
||||
// Multiple blank identifiers should be allowed (for padding/alignment)
|
||||
type siginfoChild struct {
|
||||
signo int32
|
||||
errno int32
|
||||
exitCode int32
|
||||
_ int32
|
||||
|
||||
pid int32
|
||||
uid uint32
|
||||
status int32
|
||||
|
||||
_ [25]uint32
|
||||
}
|
||||
|
Reference in New Issue
Block a user