Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: enable use-any from revive #2948

Merged
merged 1 commit into from
Jan 29, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ linters-settings:
- name: unused-parameter
disabled: true
- name: use-any
disabled: true
- name: var-declaration
- name: var-naming
disabled: true
Expand Down
4 changes: 2 additions & 2 deletions lifecycle_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -668,7 +668,7 @@ type inMemoryLogger struct {
data []string
}

func (l *inMemoryLogger) Printf(format string, args ...interface{}) {
func (l *inMemoryLogger) Printf(format string, args ...any) {
l.data = append(l.data, fmt.Sprintf(format, args...))
}

Expand Down Expand Up @@ -882,7 +882,7 @@ type linesTestLogger struct {
data []string
}

func (l *linesTestLogger) Printf(format string, args ...interface{}) {
func (l *linesTestLogger) Printf(format string, args ...any) {
l.data = append(l.data, fmt.Sprintf(format, args...))
}

Expand Down
6 changes: 3 additions & 3 deletions logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,13 @@ var (

// Logging defines the Logger interface
type Logging interface {
Printf(format string, v ...interface{})
Printf(format string, v ...any)
}

type noopLogger struct{}

// Printf implements Logging.
func (n noopLogger) Printf(format string, v ...interface{}) {
func (n noopLogger) Printf(format string, v ...any) {
// NOOP
}

Expand Down Expand Up @@ -98,7 +98,7 @@ type testLogger struct {
}

// Printf implements Logging.
func (t testLogger) Printf(format string, v ...interface{}) {
func (t testLogger) Printf(format string, v ...any) {
t.Helper()
t.Logf(format, v...)
}
24 changes: 12 additions & 12 deletions modulegen/internal/mkdocs/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,19 @@ type Config struct {
Logo string `yaml:"logo"`
Favicon string `yaml:"favicon"`
} `yaml:"theme"`
ExtraCSS []string `yaml:"extra_css"`
RepoName string `yaml:"repo_name"`
RepoURL string `yaml:"repo_url"`
MarkdownExtensions []interface{} `yaml:"markdown_extensions"`
ExtraCSS []string `yaml:"extra_css"`
RepoName string `yaml:"repo_name"`
RepoURL string `yaml:"repo_url"`
MarkdownExtensions []any `yaml:"markdown_extensions"`
Nav []struct {
Home string `yaml:"Home,omitempty"`
Quickstart string `yaml:"Quickstart,omitempty"`
Features []interface{} `yaml:"Features,omitempty"`
Examples []string `yaml:"Examples,omitempty"`
Modules []string `yaml:"Modules,omitempty"`
SystemRequirements []interface{} `yaml:"System Requirements,omitempty"`
Contributing string `yaml:"Contributing,omitempty"`
GettingHelp string `yaml:"Getting help,omitempty"`
Home string `yaml:"Home,omitempty"`
Quickstart string `yaml:"Quickstart,omitempty"`
Features []any `yaml:"Features,omitempty"`
Examples []string `yaml:"Examples,omitempty"`
Modules []string `yaml:"Modules,omitempty"`
SystemRequirements []any `yaml:"System Requirements,omitempty"`
Contributing string `yaml:"Contributing,omitempty"`
GettingHelp string `yaml:"Getting help,omitempty"`
} `yaml:"nav"`
EditURI string `yaml:"edit_uri"`
Extra struct {
Expand Down
2 changes: 1 addition & 1 deletion modules/chroma/examples_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ func ExampleChromaContainer_collections() {
col1, err := col.Add(
context.Background(),
nil, // embeddings
[]map[string]interface{}{}, // metadata
[]map[string]any{}, // metadata
[]string{"test-doc-1", "test-doc-2"}, // documents
[]string{"test-label-1", "test-label-2"}, // ids
)
Expand Down
2 changes: 1 addition & 1 deletion modules/compose/compose_builder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ func writeTemplateWithSrvType(t *testing.T, templateFile string, srvType string,
tmpl, err := template.ParseFiles(filepath.Join(testdataPackage, templateFile))
require.NoErrorf(t, err, "parsing template file")

values := map[string]interface{}{}
values := map[string]any{}
for i, p := range port {
values[fmt.Sprintf("Port_%d", i)] = p
}
Expand Down
4 changes: 2 additions & 2 deletions modules/compose/compose_local.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ type LocalDockerCompose struct {
Identifier string
Cmd []string
Env map[string]string
Services map[string]interface{}
Services map[string]any
waitStrategySupplied bool
WaitStrategyMap map[waitService]wait.Strategy
}
Expand Down Expand Up @@ -254,7 +254,7 @@ func (dc *LocalDockerCompose) determineVersion() error {
// references to all services in them
func (dc *LocalDockerCompose) validate() error {
type compose struct {
Services map[string]interface{}
Services map[string]any
}

for _, abs := range dc.absComposeFilePaths {
Expand Down
2 changes: 1 addition & 1 deletion modules/gcloud/spanner_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ func ExampleRunSpannerContainer() {
_, err = client.Apply(ctx, []*spanner.Mutation{
spanner.Insert("Languages",
[]string{"language", "mascot"},
[]interface{}{"Go", "Gopher"}),
[]any{"Go", "Gopher"}),
})
if err != nil {
log.Printf("failed to apply mutation: %v", err)
Expand Down
2 changes: 1 addition & 1 deletion modules/grafana-lgtm/grafana_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func TestGrafanaLGTM(t *testing.T) {

require.Equal(t, http.StatusOK, httpResp.StatusCode)

body := make(map[string]interface{})
body := make(map[string]any)
err = json.NewDecoder(httpResp.Body).Decode(&body)
require.NoError(t, err)
require.Equal(t, "11.0.0", body["version"])
Expand Down
2 changes: 1 addition & 1 deletion modules/mockserver/examples_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ func ExampleRun_connect() {
Method: http.MethodPost,
Path: "/api/categories",
}
requestMatcher = requestMatcher.WithJSONFields(map[string]interface{}{"name": "Tools"})
requestMatcher = requestMatcher.WithJSONFields(map[string]any{"name": "Tools"})
err = ms.RegisterExpectation(client.NewExpectation(requestMatcher).WithResponse(client.NewResponseOK().WithJSONBody(map[string]any{"test": "value"})))
if err != nil {
log.Printf("failed to register expectation: %s", err)
Expand Down
2 changes: 1 addition & 1 deletion modules/neo4j/neo4j_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ type inMemoryLogger struct {
buffer strings.Builder
}

func (iml *inMemoryLogger) Printf(msg string, args ...interface{}) {
func (iml *inMemoryLogger) Printf(msg string, args ...any) {
iml.buffer.Write([]byte(fmt.Sprintf(msg, args...)))
iml.buffer.Write([]byte(logSeparator))
}
Expand Down
4 changes: 2 additions & 2 deletions modules/pulsar/pulsar_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -181,14 +181,14 @@ func TestPulsar(t *testing.T) {
body, err := io.ReadAll(resp.Body)
require.NoError(t, err)

var stats map[string]interface{}
var stats map[string]any
err = json.Unmarshal(body, &stats)
require.NoError(t, err)

subscriptions := stats["subscriptions"]
require.NotNil(t, subscriptions)

subscriptionsMap := subscriptions.(map[string]interface{})
subscriptionsMap := subscriptions.(map[string]any)

// check that the subscription exists
_, ok := subscriptionsMap[subscriptionName]
Expand Down
18 changes: 9 additions & 9 deletions modules/rabbitmq/rabbitmq_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ func TestRunContainer_withAllSettings(t *testing.T) {
AutoDelete: false,
Internal: false,
Durable: true,
Args: map[string]interface{}{},
Args: map[string]any{},
}),
testcontainers.WithAfterReadyCommand(Exchange{
VHost: "vhost2",
Expand All @@ -124,7 +124,7 @@ func TestRunContainer_withAllSettings(t *testing.T) {
AutoDelete: false,
Internal: false,
Durable: true,
Args: map[string]interface{}{},
Args: map[string]any{},
}),
// }
// addQueues {
Expand All @@ -133,14 +133,14 @@ func TestRunContainer_withAllSettings(t *testing.T) {
Name: "queue2",
AutoDelete: true,
Durable: false,
Args: map[string]interface{}{"x-message-ttl": 1000},
Args: map[string]any{"x-message-ttl": 1000},
}),
testcontainers.WithAfterReadyCommand(Queue{
VHost: "vhost1",
Name: "queue3",
AutoDelete: true,
Durable: false,
Args: map[string]interface{}{"x-message-ttl": 1000},
Args: map[string]any{"x-message-ttl": 1000},
}),
testcontainers.WithAfterReadyCommand(Queue{VHost: "vhost2", Name: "queue4"}),
// }
Expand All @@ -153,7 +153,7 @@ func TestRunContainer_withAllSettings(t *testing.T) {
Destination: "queue4",
RoutingKey: "ss7",
DestinationType: "queue",
Args: map[string]interface{}{},
Args: map[string]any{},
}),
// }
// addUsers {
Expand All @@ -174,28 +174,28 @@ func TestRunContainer_withAllSettings(t *testing.T) {
testcontainers.WithAfterReadyCommand(Policy{
Name: "max length policy",
Pattern: "^dog",
Definition: map[string]interface{}{"max-length": 1},
Definition: map[string]any{"max-length": 1},
Priority: 1,
ApplyTo: "queues",
}),
testcontainers.WithAfterReadyCommand(Policy{
Name: "alternate exchange policy",
Pattern: "^direct-exchange",
Definition: map[string]interface{}{"alternate-exchange": "amq.direct"},
Definition: map[string]any{"alternate-exchange": "amq.direct"},
}),
testcontainers.WithAfterReadyCommand(Policy{
VHost: "vhost2",
Name: "ha-all",
Pattern: ".*",
Definition: map[string]interface{}{
Definition: map[string]any{
"ha-mode": "all",
"ha-sync-mode": "automatic",
},
}),
testcontainers.WithAfterReadyCommand(OperatorPolicy{
Name: "operator policy 1",
Pattern: "^queue1",
Definition: map[string]interface{}{"message-ttl": 1000},
Definition: map[string]any{"message-ttl": 1000},
Priority: 1,
ApplyTo: "queues",
}),
Expand Down
10 changes: 5 additions & 5 deletions modules/rabbitmq/types_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ type Binding struct {
DestinationType string
RoutingKey string
// additional arguments, that will be serialized to JSON when passed to the container
Args map[string]interface{}
Args map[string]any
}

func NewBinding(source string, destination string) Binding {
Expand Down Expand Up @@ -82,7 +82,7 @@ type Exchange struct {
AutoDelete bool
Internal bool
Durable bool
Args map[string]interface{}
Args map[string]any
}

func (e Exchange) AsCommand() []string {
Expand Down Expand Up @@ -124,7 +124,7 @@ type OperatorPolicy struct {
testcontainers.ExecOptions
Name string
Pattern string
Definition map[string]interface{}
Definition map[string]any
Priority int
ApplyTo string
}
Expand Down Expand Up @@ -230,7 +230,7 @@ type Policy struct {
VHost string
Name string
Pattern string
Definition map[string]interface{}
Definition map[string]any
Priority int
ApplyTo string
}
Expand Down Expand Up @@ -273,7 +273,7 @@ type Queue struct {
VHost string
AutoDelete bool
Durable bool
Args map[string]interface{}
Args map[string]any
}

func (q Queue) AsCommand() []string {
Expand Down
12 changes: 6 additions & 6 deletions modules/surrealdb/surrealdb_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@ func TestSurrealDBSelect(t *testing.T) {
result, err := db.Select("person.tobie")
require.NoError(t, err)

resultData := result.([]any)[0].(map[string]interface{})
resultData := result.([]any)[0].(map[string]any)
require.Equal(t, "Founder & CEO", resultData["title"])
require.Equal(t, "Tobie", resultData["name"].(map[string]interface{})["first"])
require.Equal(t, "Morgan Hitchcock", resultData["name"].(map[string]interface{})["last"])
require.Equal(t, "Tobie", resultData["name"].(map[string]any)["first"])
require.Equal(t, "Morgan Hitchcock", resultData["name"].(map[string]any)["last"])
require.Equal(t, true, resultData["marketing"])
}

Expand Down Expand Up @@ -82,9 +82,9 @@ func TestSurrealDBWithAuth(t *testing.T) {
result, err := db.Select("person.tobie")
require.NoError(t, err)

resultData := result.([]any)[0].(map[string]interface{})
resultData := result.([]any)[0].(map[string]any)
require.Equal(t, "Founder & CEO", resultData["title"])
require.Equal(t, "Tobie", resultData["name"].(map[string]interface{})["first"])
require.Equal(t, "Morgan Hitchcock", resultData["name"].(map[string]interface{})["last"])
require.Equal(t, "Tobie", resultData["name"].(map[string]any)["first"])
require.Equal(t, "Morgan Hitchcock", resultData["name"].(map[string]any)["last"])
require.Equal(t, true, resultData["marketing"])
}
Loading