Skip to content

Commit 5d9441a

Browse files
typechecker uses qualifiedFieldName
1 parent 3ec579c commit 5d9441a

File tree

3 files changed

+3
-6
lines changed

3 files changed

+3
-6
lines changed

pkg/analysis/numericbounds/analyzer.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ func run(pass *analysis.Pass) (any, error) {
7171

7272
inspect.InspectFields(func(field *ast.Field, _ extractjsontags.FieldTagInfo, markersAccess markershelper.Markers, qualifiedFieldName string) {
7373
// Create TypeChecker with closure capturing markersAccess and qualifiedFieldName
74+
// Ignore TypeChecker's prefix since we use qualifiedFieldName from inspector
7475
typeChecker := utils.NewTypeChecker(func(pass *analysis.Pass, ident *ast.Ident, node ast.Node, _ string) {
7576
checkNumericType(pass, ident, node, markersAccess, qualifiedFieldName)
7677
})

pkg/analysis/numericbounds/testdata/src/a/a.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -145,10 +145,6 @@ type SliceFields struct {
145145
InvalidSlice []int32 // want "SliceFields.InvalidSlice is missing minimum bound validation marker" "SliceFields.InvalidSlice is missing maximum bound validation marker"
146146

147147
InvalidSlice64 []int64 // want "SliceFields.InvalidSlice64 is missing minimum bound validation marker" "SliceFields.InvalidSlice64 is missing maximum bound validation marker"
148-
149-
// +kubebuilder:validation:items:Minimum=0
150-
// +kubebuilder:validation:items:Maximum=100
151-
ValidSliceWithBounds []int32
152148
}
153149

154150
// TypeAliasFields with type aliases should be checked

pkg/analysis/utils/type_check.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,14 @@ type TypeChecker interface {
3131
}
3232

3333
// NewTypeChecker returns a new TypeChecker with the provided checkFunc.
34-
func NewTypeChecker(checkFunc func(pass *analysis.Pass, ident *ast.Ident, node ast.Node, prefix string)) TypeChecker {
34+
func NewTypeChecker(checkFunc func(pass *analysis.Pass, ident *ast.Ident, node ast.Node, qualifiedFieldName string)) TypeChecker {
3535
return &typeChecker{
3636
checkFunc: checkFunc,
3737
}
3838
}
3939

4040
type typeChecker struct {
41-
checkFunc func(pass *analysis.Pass, ident *ast.Ident, node ast.Node, prefix string)
41+
checkFunc func(pass *analysis.Pass, ident *ast.Ident, node ast.Node, qualifiedFieldName string)
4242
}
4343

4444
// CheckNode checks the provided node for built-in types.

0 commit comments

Comments
 (0)