Skip to content

Commit 2c0af94

Browse files
authored
refactor: use any instead of interface{} (#1709)
This matches what I think is the general preference these days - either way, consistency is good and I don't know of a `use-interface` rule 😄
1 parent 44ceaf0 commit 2c0af94

File tree

5 files changed

+8
-6
lines changed

5 files changed

+8
-6
lines changed

.golangci.yaml

+2
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,8 @@ linters-settings:
108108
disabled: false
109109
- name: unused-parameter
110110
disabled: false
111+
- name: use-any
112+
disabled: false
111113
- name: var-declaration
112114
disabled: false
113115
- name: var-naming

internal/datasource/maven_registry.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ func (m *MavenRegistryAPIClient) getArtifactMetadata(ctx context.Context, regist
210210
return metadata, nil
211211
}
212212

213-
func (m *MavenRegistryAPIClient) get(ctx context.Context, auth *HTTPAuthentication, url string, dst interface{}) error {
213+
func (m *MavenRegistryAPIClient) get(ctx context.Context, auth *HTTPAuthentication, url string, dst any) error {
214214
resp, err := m.responses.Get(url, func() (response, error) {
215215
resp, err := auth.Get(ctx, http.DefaultClient, url)
216216
if err != nil {

internal/datasource/npm_registry_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -156,8 +156,8 @@ func TestNpmRegistryClient(t *testing.T) {
156156
if err != nil {
157157
t.Fatalf("failed getting full json: %v", err)
158158
}
159-
wantMap := want.Value().(map[string]interface{})
160-
gotMap := got.Value().(map[string]interface{})
159+
wantMap := want.Value().(map[string]any)
160+
gotMap := got.Value().(map[string]any)
161161
if diff := cmp.Diff(wantMap, gotMap, cmpopts.SortSlices(compare.Less[string])); diff != "" {
162162
t.Errorf("FullJSON(\"%s\", \"%s\") (-want +got)\n%s", pkg, ver, diff)
163163
}

internal/resolution/client/client.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ type DependencyClient interface {
3030
AddRegistries(registries []Registry) error
3131
}
3232

33-
type Registry interface{}
33+
type Registry any
3434

3535
// PreFetch loads cache, then makes and caches likely queries needed for resolving a package with a list of requirements
3636
func PreFetch(ctx context.Context, c DependencyClient, requirements []resolve.RequirementVersion, manifestPath string) {

internal/sourceanalysis/rust.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -84,11 +84,11 @@ func rustAnalysis(pkgs []models.PackageVulns, source models.SourceInfo) {
8484
// ],
8585
// "arch": []
8686
// }
87-
ecosystemAffects, ok := a.EcosystemSpecific["affects"].(map[string]interface{})
87+
ecosystemAffects, ok := a.EcosystemSpecific["affects"].(map[string]any)
8888
if !ok {
8989
continue
9090
}
91-
affectedFunctions, ok := ecosystemAffects["functions"].([]interface{})
91+
affectedFunctions, ok := ecosystemAffects["functions"].([]any)
9292
if !ok {
9393
continue
9494
}

0 commit comments

Comments
 (0)