chore(linter): enable unparam#6160
Conversation
Signed-off-by: ivan katliarchuk <[email protected]>
|
Pull Request Test Coverage Report for Build 22218536551Warning: This coverage report may be inaccurate.This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.
Details
💛 - Coveralls |
Signed-off-by: ivan katliarchuk <[email protected]>
Signed-off-by: ivan katliarchuk <[email protected]>
Signed-off-by: ivan katliarchuk <[email protected]>
Signed-off-by: ivan katliarchuk <[email protected]>
registry/txt/registry_test.go
Outdated
| _, err := NewTXTRegistry(p, "txt.", "", "", time.Hour, "", []string{}, []string{}, false, nil, "") | ||
| require.Error(t, err) | ||
|
|
||
| _, err = NewTXTRegistry(p, "", "txt", "", time.Hour, "", []string{}, []string{}, false, nil, "") | ||
| require.Error(t, err) | ||
|
|
||
| r, err := NewTXTRegistry(p, "txt", "", "owner", time.Hour, "", []string{}, []string{}, false, nil, "") | ||
| r, err := NewTXTRegistry(p, "txt.", "", "owner", time.Hour, "", []string{}, []string{}, false, nil, "") |
source/contour_httpproxy_test.go
Outdated
| if source, err := newTestHTTPProxySource(); err != nil { | ||
| require.NoError(t, err) | ||
| } else if endpoints, err := source.endpointsFromHTTPProxy(ti.httpProxy.HTTPProxy()); err != nil { | ||
| require.NoError(t, err) | ||
| } else { | ||
| endpoints := source.endpointsFromHTTPProxy(ti.httpProxy.HTTPProxy()) | ||
| validateEndpoints(t, endpoints, ti.expected) | ||
| } |
There was a problem hiding this comment.
| if source, err := newTestHTTPProxySource(); err != nil { | |
| require.NoError(t, err) | |
| } else if endpoints, err := source.endpointsFromHTTPProxy(ti.httpProxy.HTTPProxy()); err != nil { | |
| require.NoError(t, err) | |
| } else { | |
| endpoints := source.endpointsFromHTTPProxy(ti.httpProxy.HTTPProxy()) | |
| validateEndpoints(t, endpoints, ti.expected) | |
| } | |
| source, err := newTestHTTPProxySource() | |
| require.NoError(t, err) | |
| endpoints := source.endpointsFromHTTPProxy(ti.httpProxy.HTTPProxy()) | |
| validateEndpoints(t, endpoints, ti.expected) | |
| { | ||
| name: "all types of services with filter enabled for ServiceTypeNodePort and ServiceTypeClusterIP", | ||
| currentServices: createTestServicesByType(namespace, map[v1.ServiceType]int{ | ||
| currentServices: createTestServicesByType("kube-system", map[v1.ServiceType]int{ |
There was a problem hiding this comment.
Is there a reason for not using "default" here like in other test cases?
There was a problem hiding this comment.
Yes. Unapam linter think that the code only works with default and fail the lint.
| withNode(map[string]string{"tenant": "1"}). | ||
| withNode(map[string]string{"tenant": "2"}). | ||
| withNode(map[string]string{"tenant": "3"}). | ||
| withNode(map[string]string{"tenant": "4"}). |
There was a problem hiding this comment.
The way unaparam works - it detects cases with same values like nil in this case, and fail the lint. As there is no variation of the values, kinda either should be empty or have different values.
Co-authored-by: vflaux <[email protected]>
Signed-off-by: ivan katliarchuk <[email protected]>
Signed-off-by: ivan katliarchuk <[email protected]>
Signed-off-by: ivan katliarchuk <[email protected]>
|
/approve |
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: ivankatliarchuk 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 |

What does it do ?
initial failed job https://github.com/kubernetes-sigs/external-dns/actions/runs/21548777453/job/62094259356?pr=6160
Just enough changes to satisfy linter. Fixing this, I found quite few patterns that could have shared function. I'll provide refactoring/shared function in follow-up PR.
Current problems solved
Dead code / unnecessary complexity: Parameters that never vary indicate over-engineered APIs. If pageSize is always 50, why make callers pass it? It adds cognitive load without flexibility.
Incomplete implementations: Functions returning error that's always nil suggest error handling was planned but never implemented. Reviewers should ask: "Should this propagate errors from the operations inside?"
Unused return values: If nobody uses a return value, either the callers are missing something, or the function signature is wrong.
Test helper bloat: Test helpers with unused parameters (like msgAndArgs always nil, or recordType always "A") indicate copy-paste from other helpers without cleanup.
Refactoring leftovers: Parameters that became constant over time often indicate incomplete refactoring. The code evolved but the signature didn't.
Motivation
For reviewers specifically:
The Alibaba errors are a good example: 6 functions return error but always return nil. A reviewer should ask whether errors from the underlying API calls should bubble up.
More