fix type detection#33
Conversation
|
This issue is currently awaiting triage. If logtools contributors determine this is a relevant issue, they will accept it by applying the The DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
573b649 to
05f9cf9
Compare
Recent Go changed how type aliases are handled. We need to test with it...
Using the original type or the alias may make a difference...
With recent dependencies (= `go get -u ./...`), type aliases are reported as
`types.Alias` instead of `types.Named`. Found initially in Kubernetes,
confirmed with unit tests:
--- FAIL: TestAnalyzer (3.05s)
--- FAIL: TestAnalyzer/Function_call_parameters (0.20s)
analysistest.go:713: parameters/parameters.go:54: no diagnostic was reported matching `Additional arguments to Info should always be Key Value pairs. Please check if there is any key or value missing.`
analysistest.go:713: parameters/parameters.go:55: no diagnostic was reported matching `Additional arguments to Error should always be Key Value pairs. Please check if there is any key or value missing.`
analysistest.go:713: parameters/parameters.go:65: no diagnostic was reported matching `Key positional arguments are expected to be inlined constant strings. Please replace 1 provided with string value`
analysistest.go:713: parameters/parameters.go:67: no diagnostic was reported matching `Key positional arguments are expected to be inlined constant strings. Please replace 1 provided with string value`
analysistest.go:713: parameters/parameters.go:80: no diagnostic was reported matching `Additional arguments to Info should always be Key Value pairs. Please check if there is any key or value missing.`
--- FAIL: TestAnalyzer/helpers (0.16s)
analysistest.go:713: helpers/doNotAllowDirectCalls.go:34: no diagnostic was reported matching `function "WithName" should be called through klogr.LoggerWithName`
analysistest.go:713: helpers/doNotAllowDirectCalls.go:35: no diagnostic was reported matching `function "WithValues" should be called through klogr.LoggerWithValues`
--- FAIL: TestAnalyzer/Detect_incomplete_fmt.Stringer (0.21s)
analysistest.go:713: stringer/stringer.go:27: no diagnostic was reported matching `The type \*stringer.config inherits \(\*k8s.io/apimachinery/pkg/apis/meta/v1.TypeMeta\).String as implementation of fmt.Stringer, which covers only a subset of the value. Implement String\(\) for the type or wrap it with TODO.`
FAIL
FAIL sigs.k8s.io/logtools/logcheck 3.059s
We need to resolve type aliases. We can't just call Underlying, that
resolves to an unnamed type. We need to use Rhs instead, which depends
on Go 1.23.
05f9cf9 to
7c2a63c
Compare
|
Errors that went undetected in Kubernetes because of this: We can probably relax the |
|
/assign @dims |
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: dims, pohly The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
|
@serathius: can I still count on you for a formal LGTM? |
|
/assign @serathius |
|
/lgtm |
Recent Go packages report klog's
Logger = logr.Loggertype alias as atypes.Aliasinstead of thetypes.Namedthat the code supported. As a result, checking of calls through that alias wasn't working anymore in Kubernetes because it builds the plugin with Go 1.25 and more recent dependencies.