Skip to content

Commit

Permalink
chore: enable unused-parameter from revive (#2949)
Browse files Browse the repository at this point in the history
Signed-off-by: Matthieu MOREL <[email protected]>
  • Loading branch information
mmorel-35 authored Jan 30, 2025
1 parent 425d849 commit a43edc8
Show file tree
Hide file tree
Showing 41 changed files with 122 additions and 123 deletions.
1 change: 0 additions & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ linters-settings:
disabled: true
- name: unreachable-code
- name: unused-parameter
disabled: true
- name: use-any
- name: var-declaration
- name: var-naming
Expand Down
4 changes: 2 additions & 2 deletions docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -998,7 +998,7 @@ func (p *DockerProvider) BuildImage(ctx context.Context, img ImageBuildInfo) (st
return resp, nil
},
backoff.WithContext(backoff.NewExponentialBackOff(), ctx),
func(err error, duration time.Duration) {
func(err error, _ time.Duration) {
p.Logger.Printf("Failed to build image: %s, will retry", err)
},
)
Expand Down Expand Up @@ -1414,7 +1414,7 @@ func (p *DockerProvider) attemptToPullImage(ctx context.Context, tag string, pul
return nil
},
backoff.WithContext(backoff.NewExponentialBackOff(), ctx),
func(err error, duration time.Duration) {
func(err error, _ time.Duration) {
p.Logger.Printf("Failed to pull image: %s, will retry", err)
},
)
Expand Down
2 changes: 1 addition & 1 deletion docker_auth_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ func TestDockerImageAuth(t *testing.T) {
t.Cleanup(func() {
defaultRegistryFn = origDefaultRegistryFn
})
defaultRegistryFn = func(ctx context.Context) string {
defaultRegistryFn = func(_ context.Context) string {
return ""
}

Expand Down
8 changes: 4 additions & 4 deletions internal/core/docker_host.go
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ func isHostNotSet(err error) bool {
}

// dockerHostFromEnv returns the docker host from the DOCKER_HOST environment variable, if it's not empty
func dockerHostFromEnv(ctx context.Context) (string, error) {
func dockerHostFromEnv(_ context.Context) (string, error) {
if dockerHostPath := os.Getenv("DOCKER_HOST"); dockerHostPath != "" {
return dockerHostPath, nil
}
Expand All @@ -263,7 +263,7 @@ func dockerHostFromContext(ctx context.Context) (string, error) {
}

// dockerHostFromProperties returns the docker host from the ~/.testcontainers.properties file, if it's not empty
func dockerHostFromProperties(ctx context.Context) (string, error) {
func dockerHostFromProperties(_ context.Context) (string, error) {
cfg := config.Read()
socketPath := cfg.Host
if socketPath != "" {
Expand All @@ -285,7 +285,7 @@ func dockerSocketOverridePath() (string, error) {

// dockerSocketPath returns the docker socket from the default docker socket path, if it's not empty
// and the socket exists
func dockerSocketPath(ctx context.Context) (string, error) {
func dockerSocketPath(_ context.Context) (string, error) {
if fileExists(DockerSocketPath) {
return DockerSocketPathWithSchema, nil
}
Expand All @@ -294,7 +294,7 @@ func dockerSocketPath(ctx context.Context) (string, error) {
}

// testcontainersHostFromProperties returns the testcontainers host from the ~/.testcontainers.properties file, if it's not empty
func testcontainersHostFromProperties(ctx context.Context) (string, error) {
func testcontainersHostFromProperties(_ context.Context) (string, error) {
cfg := config.Read()
testcontainersHost := cfg.TestcontainersHost
if testcontainersHost != "" {
Expand Down
2 changes: 1 addition & 1 deletion internal/core/docker_host_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ type mockCli struct {

// Info returns a mock implementation of types.Info, which is handy for detecting the operating system,
// which is used to determine the default docker socket path.
func (m mockCli) Info(ctx context.Context) (system.Info, error) {
func (m mockCli) Info(_ context.Context) (system.Info, error) {
return system.Info{
OperatingSystem: m.OS,
}, nil
Expand Down
26 changes: 13 additions & 13 deletions lifecycle.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,67 +61,67 @@ var DefaultLoggingHook = func(logger Logging) ContainerLifecycleHooks {

return ContainerLifecycleHooks{
PreBuilds: []ContainerRequestHook{
func(ctx context.Context, req ContainerRequest) error {
func(_ context.Context, req ContainerRequest) error {
logger.Printf("🐳 Building image %s:%s", req.GetRepo(), req.GetTag())
return nil
},
},
PostBuilds: []ContainerRequestHook{
func(ctx context.Context, req ContainerRequest) error {
func(_ context.Context, req ContainerRequest) error {
logger.Printf("✅ Built image %s", req.Image)
return nil
},
},
PreCreates: []ContainerRequestHook{
func(ctx context.Context, req ContainerRequest) error {
func(_ context.Context, req ContainerRequest) error {
logger.Printf("🐳 Creating container for image %s", req.Image)
return nil
},
},
PostCreates: []ContainerHook{
func(ctx context.Context, c Container) error {
func(_ context.Context, c Container) error {
logger.Printf("✅ Container created: %s", shortContainerID(c))
return nil
},
},
PreStarts: []ContainerHook{
func(ctx context.Context, c Container) error {
func(_ context.Context, c Container) error {
logger.Printf("🐳 Starting container: %s", shortContainerID(c))
return nil
},
},
PostStarts: []ContainerHook{
func(ctx context.Context, c Container) error {
func(_ context.Context, c Container) error {
logger.Printf("✅ Container started: %s", shortContainerID(c))
return nil
},
},
PostReadies: []ContainerHook{
func(ctx context.Context, c Container) error {
func(_ context.Context, c Container) error {
logger.Printf("🔔 Container is ready: %s", shortContainerID(c))
return nil
},
},
PreStops: []ContainerHook{
func(ctx context.Context, c Container) error {
func(_ context.Context, c Container) error {
logger.Printf("🐳 Stopping container: %s", shortContainerID(c))
return nil
},
},
PostStops: []ContainerHook{
func(ctx context.Context, c Container) error {
func(_ context.Context, c Container) error {
logger.Printf("✅ Container stopped: %s", shortContainerID(c))
return nil
},
},
PreTerminates: []ContainerHook{
func(ctx context.Context, c Container) error {
func(_ context.Context, c Container) error {
logger.Printf("🐳 Terminating container: %s", shortContainerID(c))
return nil
},
},
PostTerminates: []ContainerHook{
func(ctx context.Context, c Container) error {
func(_ context.Context, c Container) error {
logger.Printf("🚫 Container terminated: %s", shortContainerID(c))
return nil
},
Expand Down Expand Up @@ -199,7 +199,7 @@ var defaultLogConsumersHook = func(cfg *LogConsumerConfig) ContainerLifecycleHoo
PostStops: []ContainerHook{
// Stop the log production.
// See combineContainerHooks for the order of execution.
func(ctx context.Context, c Container) error {
func(_ context.Context, c Container) error {
if cfg == nil || len(cfg.Consumers) == 0 {
return nil
}
Expand Down Expand Up @@ -266,7 +266,7 @@ var defaultReadinessHook = func() ContainerLifecycleHooks {
return checkPortsMapped(jsonRaw.NetworkSettings.Ports, dockerContainer.exposedPorts)
},
b,
func(err error, duration time.Duration) {
func(err error, _ time.Duration) {
dockerContainer.logger.Printf("All requested ports were not exposed: %v", err)
},
)
Expand Down
48 changes: 24 additions & 24 deletions lifecycle_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -541,91 +541,91 @@ func TestLifecycleHooks(t *testing.T) {
LifecycleHooks: []ContainerLifecycleHooks{
{
PreCreates: []ContainerRequestHook{
func(ctx context.Context, req ContainerRequest) error {
func(_ context.Context, _ ContainerRequest) error {
prints = append(prints, "pre-create hook 1")
return nil
},
func(ctx context.Context, req ContainerRequest) error {
func(_ context.Context, _ ContainerRequest) error {
prints = append(prints, "pre-create hook 2")
return nil
},
},
PostCreates: []ContainerHook{
func(ctx context.Context, c Container) error {
func(_ context.Context, _ Container) error {
prints = append(prints, "post-create hook 1")
return nil
},
func(ctx context.Context, c Container) error {
func(_ context.Context, _ Container) error {
prints = append(prints, "post-create hook 2")
return nil
},
},
PreStarts: []ContainerHook{
func(ctx context.Context, c Container) error {
func(_ context.Context, _ Container) error {
prints = append(prints, "pre-start hook 1")
return nil
},
func(ctx context.Context, c Container) error {
func(_ context.Context, _ Container) error {
prints = append(prints, "pre-start hook 2")
return nil
},
},
PostStarts: []ContainerHook{
func(ctx context.Context, c Container) error {
func(_ context.Context, _ Container) error {
prints = append(prints, "post-start hook 1")
return nil
},
func(ctx context.Context, c Container) error {
func(_ context.Context, _ Container) error {
prints = append(prints, "post-start hook 2")
return nil
},
},
PostReadies: []ContainerHook{
func(ctx context.Context, c Container) error {
func(_ context.Context, _ Container) error {
prints = append(prints, "post-ready hook 1")
return nil
},
func(ctx context.Context, c Container) error {
func(_ context.Context, _ Container) error {
prints = append(prints, "post-ready hook 2")
return nil
},
},
PreStops: []ContainerHook{
func(ctx context.Context, c Container) error {
func(_ context.Context, _ Container) error {
prints = append(prints, "pre-stop hook 1")
return nil
},
func(ctx context.Context, c Container) error {
func(_ context.Context, _ Container) error {
prints = append(prints, "pre-stop hook 2")
return nil
},
},
PostStops: []ContainerHook{
func(ctx context.Context, c Container) error {
func(_ context.Context, _ Container) error {
prints = append(prints, "post-stop hook 1")
return nil
},
func(ctx context.Context, c Container) error {
func(_ context.Context, _ Container) error {
prints = append(prints, "post-stop hook 2")
return nil
},
},
PreTerminates: []ContainerHook{
func(ctx context.Context, c Container) error {
func(_ context.Context, _ Container) error {
prints = append(prints, "pre-terminate hook 1")
return nil
},
func(ctx context.Context, c Container) error {
func(_ context.Context, _ Container) error {
prints = append(prints, "pre-terminate hook 2")
return nil
},
},
PostTerminates: []ContainerHook{
func(ctx context.Context, c Container) error {
func(_ context.Context, _ Container) error {
prints = append(prints, "post-terminate hook 1")
return nil
},
func(ctx context.Context, c Container) error {
func(_ context.Context, _ Container) error {
prints = append(prints, "post-terminate hook 2")
return nil
},
Expand Down Expand Up @@ -714,13 +714,13 @@ func TestCombineLifecycleHooks(t *testing.T) {
prints := []string{}

preCreateFunc := func(prefix string, hook string, lifecycleID int, hookID int) func(ctx context.Context, req ContainerRequest) error {
return func(ctx context.Context, _ ContainerRequest) error {
return func(_ context.Context, _ ContainerRequest) error {
prints = append(prints, fmt.Sprintf("[%s] pre-%s hook %d.%d", prefix, hook, lifecycleID, hookID))
return nil
}
}
hookFunc := func(prefix string, hookType string, hook string, lifecycleID int, hookID int) func(ctx context.Context, c Container) error {
return func(ctx context.Context, _ Container) error {
return func(_ context.Context, _ Container) error {
prints = append(prints, fmt.Sprintf("[%s] %s-%s hook %d.%d", prefix, hookType, hook, lifecycleID, hookID))
return nil
}
Expand Down Expand Up @@ -975,19 +975,19 @@ func lifecycleHooksIsHonouredFn(t *testing.T, prints []string) {

func Test_combineContainerHooks(t *testing.T) {
var funcID string
defaultContainerRequestHook := func(ctx context.Context, req ContainerRequest) error {
defaultContainerRequestHook := func(_ context.Context, _ ContainerRequest) error {
funcID = "defaultContainerRequestHook"
return nil
}
userContainerRequestHook := func(ctx context.Context, req ContainerRequest) error {
userContainerRequestHook := func(_ context.Context, _ ContainerRequest) error {
funcID = "userContainerRequestHook"
return nil
}
defaultContainerHook := func(ctx context.Context, container Container) error {
defaultContainerHook := func(_ context.Context, _ Container) error {
funcID = "defaultContainerHook"
return nil
}
userContainerHook := func(ctx context.Context, container Container) error {
userContainerHook := func(_ context.Context, _ Container) error {
funcID = "userContainerHook"
return nil
}
Expand Down
4 changes: 2 additions & 2 deletions logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,13 @@ type Logging interface {
type noopLogger struct{}

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

// Deprecated: this function will be removed in a future release
// LogDockerServerInfo logs the docker server info using the provided logger and Docker client
func LogDockerServerInfo(ctx context.Context, client client.APIClient, logger Logging) {
func LogDockerServerInfo(_ context.Context, _ client.APIClient, _ Logging) {
// NOOP
}

Expand Down
2 changes: 1 addition & 1 deletion modulegen/cmd/modules/example.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ var newExampleCmd = &cobra.Command{
Use: "example",
Short: "Create a new Example",
Long: "Create a new Example",
RunE: func(cmd *cobra.Command, args []string) error {
RunE: func(_ *cobra.Command, _ []string) error {
return internal.Generate(tcModuleVar, false)
},
}
Expand Down
2 changes: 1 addition & 1 deletion modulegen/cmd/modules/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ var newModuleCmd = &cobra.Command{
Use: "module",
Short: "Create a new Module",
Long: "Create a new Module",
RunE: func(cmd *cobra.Command, args []string) error {
RunE: func(_ *cobra.Command, _ []string) error {
return internal.Generate(tcModuleVar, true)
},
}
Expand Down
4 changes: 2 additions & 2 deletions modules/clickhouse/clickhouse_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ func performReplicatedCRUD(t *testing.T, conn driver.Conn) ([]Test, error) {
return res, nil
},
backoff.NewExponentialBackOff(),
func(err error, duration time.Duration) {
func(err error, _ time.Duration) {
t.Log(err)
},
)
Expand All @@ -309,7 +309,7 @@ func performCRUD(t *testing.T, conn driver.Conn) ([]Test, error) {
return getAllRows(conn)
},
backoff.NewExponentialBackOff(),
func(err error, duration time.Duration) {
func(err error, _ time.Duration) {
t.Log(err)
},
)
Expand Down
Loading

0 comments on commit a43edc8

Please sign in to comment.