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

Fix deepsource RVV-B0013 Unused method receiver #1832

Merged
merged 5 commits into from
Nov 18, 2022
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
2 changes: 1 addition & 1 deletion hack/benchmark/internal/starter/gateway/vald/vald.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ func New(opts ...Option) starter.Starter {
return srv
}

func (s *server) Run(ctx context.Context, tb testing.TB) func() {
func (*server) Run(ctx context.Context, tb testing.TB) func() {
tb.Helper()

// TODO (@hlts2): Make when divided gateway.
Expand Down
6 changes: 3 additions & 3 deletions internal/client/v1/client/vald/vald.go
Original file line number Diff line number Diff line change
Expand Up @@ -621,15 +621,15 @@ func (c *client) StreamGetObject(ctx context.Context, opts ...grpc.CallOption) (
return res, nil
}

func (c *singleClient) Start(ctx context.Context) (<-chan error, error) {
func (*singleClient) Start(ctx context.Context) (<-chan error, error) {
return nil, nil
}

func (c *singleClient) Stop(ctx context.Context) error {
func (*singleClient) Stop(ctx context.Context) error {
return nil
}

func (c *singleClient) GRPCClient() grpc.Client {
func (*singleClient) GRPCClient() grpc.Client {
return nil
}

Expand Down
8 changes: 4 additions & 4 deletions internal/db/kvs/redis/redis_mock.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,19 +58,19 @@ type dummyHook struct {
name string
}

func (d *dummyHook) BeforeProcess(ctx context.Context, cmd Cmder) (context.Context, error) {
func (*dummyHook) BeforeProcess(ctx context.Context, cmd Cmder) (context.Context, error) {
return ctx, nil
}

func (d *dummyHook) AfterProcess(ctx context.Context, cmd Cmder) error {
func (*dummyHook) AfterProcess(ctx context.Context, cmd Cmder) error {
return nil
}

func (d *dummyHook) BeforeProcessPipeline(ctx context.Context, cmds []Cmder) (context.Context, error) {
func (*dummyHook) BeforeProcessPipeline(ctx context.Context, cmds []Cmder) (context.Context, error) {
return ctx, nil
}

func (d *dummyHook) AfterProcessPipeline(ctx context.Context, cmds []Cmder) error {
func (*dummyHook) AfterProcessPipeline(ctx context.Context, cmds []Cmder) error {
return nil
}

Expand Down
2 changes: 1 addition & 1 deletion internal/db/nosql/cassandra/cassandra_mock.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,4 @@ func (dm *DialerMock) DialContext(ctx context.Context, network, addr string) (ne
func (dm *DialerMock) GetDialer() func(ctx context.Context, network, addr string) (net.Conn, error) {
return dm.DialContextFunc
}
func (dm *DialerMock) StartDialerCache(ctx context.Context) {}
func (*DialerMock) StartDialerCache(ctx context.Context) {}
4 changes: 2 additions & 2 deletions internal/db/nosql/cassandra/conviction.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@ func NewConvictionPolicy() gocql.ConvictionPolicy {
}

// AddFailure implements gocql.ConvictionPolicy interface to handle failure and convicts all hosts.
func (c *convictionPolicy) AddFailure(err error, host *gocql.HostInfo) bool {
func (*convictionPolicy) AddFailure(err error, host *gocql.HostInfo) bool {
log.Warn(errors.ErrCassandraHostDownDetected(err, host.String()))
return true
}

// Reset clears the conviction state.
func (c *convictionPolicy) Reset(host *gocql.HostInfo) {
func (*convictionPolicy) Reset(host *gocql.HostInfo) {
log.Infof("cassandra host %s reset detected\t%s", host.HostnameAndPort(), host.String())
}
2 changes: 1 addition & 1 deletion internal/io/copy_bench_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ type writer struct {
io.Writer
}

func (w *writer) Write(p []byte) (n int, err error) {
func (*writer) Write(p []byte) (n int, err error) {
return len(p), nil
}

Expand Down
6 changes: 3 additions & 3 deletions internal/k8s/metrics/node/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,18 +128,18 @@ func (r *reconciler) NewReconciler(ctx context.Context, mgr manager.Manager) rec
return r
}

func (r *reconciler) For() (client.Object, []builder.ForOption) {
func (*reconciler) For() (client.Object, []builder.ForOption) {
// WARN: metrics should be renew
// https://github.com/kubernetes/community/blob/main/contributors/design-proposals/instrumentation/resource-metrics-api.md#further-improvements
return new(metrics.NodeMetrics), nil
}

func (r *reconciler) Owns() (client.Object, []builder.OwnsOption) {
func (*reconciler) Owns() (client.Object, []builder.OwnsOption) {
// return new(metrics.PodMetrics)
return nil, nil
}

func (r *reconciler) Watches() (*source.Kind, handler.EventHandler, []builder.WatchesOption) {
func (*reconciler) Watches() (*source.Kind, handler.EventHandler, []builder.WatchesOption) {
// return &source.Kind{Type: new(metrics.NodeMetrics)}, &handler.EnqueueRequestForObject{}
return nil, nil, nil
}
6 changes: 3 additions & 3 deletions internal/k8s/metrics/pod/pod.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,18 +154,18 @@ func (r *reconciler) NewReconciler(ctx context.Context, mgr manager.Manager) rec
return r
}

func (r *reconciler) For() (client.Object, []builder.ForOption) {
func (*reconciler) For() (client.Object, []builder.ForOption) {
// WARN: metrics should be renew
// https://github.com/kubernetes/community/blob/main/contributors/design-proposals/instrumentation/resource-metrics-api.md#further-improvements
return new(metrics.PodMetrics), nil
}

func (r *reconciler) Owns() (client.Object, []builder.OwnsOption) {
func (*reconciler) Owns() (client.Object, []builder.OwnsOption) {
// return new(metrics.PodMetrics)
return nil, nil
}

func (r *reconciler) Watches() (*source.Kind, handler.EventHandler, []builder.WatchesOption) {
func (*reconciler) Watches() (*source.Kind, handler.EventHandler, []builder.WatchesOption) {
// return &source.Kind{Type: new(metrics.PodMetrics)}, &handler.EnqueueRequestForObject{}
return nil, nil, nil
}
6 changes: 3 additions & 3 deletions internal/k8s/node/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,15 +167,15 @@ func (r *reconciler) NewReconciler(ctx context.Context, mgr manager.Manager) rec
return r
}

func (r *reconciler) For() (client.Object, []builder.ForOption) {
func (*reconciler) For() (client.Object, []builder.ForOption) {
return new(corev1.Node), nil
}

func (r *reconciler) Owns() (client.Object, []builder.OwnsOption) {
func (*reconciler) Owns() (client.Object, []builder.OwnsOption) {
return nil, nil
}

func (r *reconciler) Watches() (*source.Kind, handler.EventHandler, []builder.WatchesOption) {
func (*reconciler) Watches() (*source.Kind, handler.EventHandler, []builder.WatchesOption) {
// return &source.Kind{Type: new(corev1.Node)}, &handler.EnqueueRequestForObject{}
return nil, nil, nil
}
6 changes: 3 additions & 3 deletions internal/k8s/pod/pod.go
Original file line number Diff line number Diff line change
Expand Up @@ -181,15 +181,15 @@ func (r *reconciler) NewReconciler(ctx context.Context, mgr manager.Manager) rec
return r
}

func (r *reconciler) For() (client.Object, []builder.ForOption) {
func (*reconciler) For() (client.Object, []builder.ForOption) {
return new(corev1.Pod), nil
}

func (r *reconciler) Owns() (client.Object, []builder.OwnsOption) {
func (*reconciler) Owns() (client.Object, []builder.OwnsOption) {
return nil, nil
}

func (r *reconciler) Watches() (*source.Kind, handler.EventHandler, []builder.WatchesOption) {
func (*reconciler) Watches() (*source.Kind, handler.EventHandler, []builder.WatchesOption) {
// return &source.Kind{Type: new(corev1.Pod)}, &handler.EnqueueRequestForObject{}
return nil, nil, nil
}
2 changes: 1 addition & 1 deletion internal/log/glg/glg.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ func (l *logger) setLogFormat(fmt format.Format) *logger {
return l
}

func (l *logger) Close() error {
func (*logger) Close() error {
return nil
}

Expand Down
2 changes: 1 addition & 1 deletion internal/log/mock/logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,6 @@ func (l *Logger) Fatald(msg string, details ...interface{}) {
l.FatalfFunc(msg, details...)
}

func (l *Logger) Close() error {
func (*Logger) Close() error {
return nil
}
24 changes: 12 additions & 12 deletions internal/net/grpc/logger/logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,64 +44,64 @@ func Init() {
}

// Info prints the debug log to the logger.
func (l *logger) Info(args ...interface{}) {
func (*logger) Info(args ...interface{}) {
log.Debug(append([]interface{}{tag}, args...)...)
}

// Infoln prints the debug log to the logger.
func (l *logger) Infoln(args ...interface{}) {
func (*logger) Infoln(args ...interface{}) {
log.Debug(append([]interface{}{tag}, args...)...)
}

// Infof prints the debug log to the logger.
func (l *logger) Infof(format string, args ...interface{}) {
func (*logger) Infof(format string, args ...interface{}) {
log.Debugf(tag+"\t"+format, args...)
}

// Warning prints the warning log to the logger.
func (l *logger) Warning(args ...interface{}) {
func (*logger) Warning(args ...interface{}) {
log.Warn(append([]interface{}{tag}, args...)...)
}

// Warningln prints the warning log to the logger.
func (l *logger) Warningln(args ...interface{}) {
func (*logger) Warningln(args ...interface{}) {
log.Warn(append([]interface{}{tag}, args...)...)
}

// Warningf prints the warning log to the logger.
func (l *logger) Warningf(format string, args ...interface{}) {
func (*logger) Warningf(format string, args ...interface{}) {
log.Warnf(tag+"\t"+format, args...)
}

// Error prints the error log to the logger.
func (l *logger) Error(args ...interface{}) {
func (*logger) Error(args ...interface{}) {
log.Error(append([]interface{}{tag}, args...)...)
}

// Errorln prints the error log to the logger.
func (l *logger) Errorln(args ...interface{}) {
func (*logger) Errorln(args ...interface{}) {
log.Error(append([]interface{}{tag}, args...)...)
}

// Errorf prints the error log to the logger.
func (l *logger) Errorf(format string, args ...interface{}) {
func (*logger) Errorf(format string, args ...interface{}) {
log.Errorf(tag+"\t"+format, args...)
}

// Fatal prints the fatal log to the logger and exit the program.
func (l *logger) Fatal(args ...interface{}) {
func (*logger) Fatal(args ...interface{}) {
// skipcq: RVV-A0003
log.Fatal(append([]interface{}{tag}, args...)...)
}

// Fatalln prints the fatal log to the logger and exit the program.
func (l *logger) Fatalln(args ...interface{}) {
func (*logger) Fatalln(args ...interface{}) {
// skipcq: RVV-A0003
log.Fatal(append([]interface{}{tag}, args...)...)
}

// Fatalf prints the fatal log to the logger and exit the program.
func (l *logger) Fatalf(format string, args ...interface{}) {
func (*logger) Fatalf(format string, args ...interface{}) {
// skipcq: RVV-A0003
log.Fatalf(tag+"\t"+format, args...)
}
Expand Down
4 changes: 2 additions & 2 deletions internal/net/grpc/pool/pool_bench_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func init() {
log.Init(log.WithLevel(level.ERROR.String()))
}

func (s *server) Pods(context.Context, *payload.Discoverer_Request) (*payload.Info_Pods, error) {
func (*server) Pods(context.Context, *payload.Discoverer_Request) (*payload.Info_Pods, error) {
return &payload.Info_Pods{
Pods: []*payload.Info_Pod{
{
Expand All @@ -54,7 +54,7 @@ func (s *server) Pods(context.Context, *payload.Discoverer_Request) (*payload.In
}, nil
}

func (s *server) Nodes(context.Context, *payload.Discoverer_Request) (*payload.Info_Nodes, error) {
func (*server) Nodes(context.Context, *payload.Discoverer_Request) (*payload.Info_Nodes, error) {
return new(payload.Info_Nodes), nil
}

Expand Down
2 changes: 1 addition & 1 deletion internal/net/http/routing/router.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ func New(opts ...Option) http.Handler {
// routing wraps the handler.Func and returns a new http.Handler.
// routing helps to handle unsupported HTTP method, timeout,
// and the error returned from the handler.Func.
func (rt *router) routing(
func (*router) routing(
name, path string, m []string, h rest.Func,
) http.Handler {
return http.HandlerFunc(
Expand Down
4 changes: 2 additions & 2 deletions internal/observability/metrics/agent/sidecar/sidecar.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ func New() MetricsHook {
}
}

func (sm *sidecarMetrics) View() ([]*metrics.View, error) {
func (*sidecarMetrics) View() ([]*metrics.View, error) {
uploadTotal, err := view.New(
view.MatchInstrumentName(uploadTotalMetricsName),
view.WithSetDescription(uploadTotalMetricsDescription),
Expand Down Expand Up @@ -152,7 +152,7 @@ func (sm *sidecarMetrics) Register(m metrics.Meter) error {
)
}

func (sm *sidecarMetrics) BeforeProcess(ctx context.Context, info *observer.BackupInfo) (context.Context, error) {
func (*sidecarMetrics) BeforeProcess(ctx context.Context, info *observer.BackupInfo) (context.Context, error) {
return ctx, nil
}

Expand Down
2 changes: 1 addition & 1 deletion internal/observability/metrics/backoff/backoff.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ func New() metrics.Metric {
}
}

func (bm *backoffMetrics) View() ([]*metrics.View, error) {
func (*backoffMetrics) View() ([]*metrics.View, error) {
retryCount, err := view.New(
view.MatchInstrumentName(metricsName),
view.WithSetDescription(metricsDescription),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ func New() metrics.Metric {
}
}

func (bm *breakerMetrics) View() ([]*metrics.View, error) {
func (*breakerMetrics) View() ([]*metrics.View, error) {
breakerState, err := view.New(
view.MatchInstrumentName(metricsName),
view.WithSetDescription(metricsDescription),
Expand Down
4 changes: 2 additions & 2 deletions internal/observability/metrics/grpc/grpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func New() metrics.Metric {
return &grpcServerMetrics{}
}

func (gm *grpcServerMetrics) View() ([]*metrics.View, error) {
func (*grpcServerMetrics) View() ([]*metrics.View, error) {
latencyHistgram, err := view.New(
view.MatchInstrumentName(latencyMetricsName),
view.WithSetDescription(latencyMetricsDesctiption),
Expand All @@ -59,7 +59,7 @@ func (gm *grpcServerMetrics) View() ([]*metrics.View, error) {
}, nil
}

func (gm *grpcServerMetrics) Register(m metrics.Meter) error {
func (*grpcServerMetrics) Register(m metrics.Meter) error {
// The metrics are dynamically registered at the grpc server interceptor package,
// so do nothing in this part
return nil
Expand Down
2 changes: 1 addition & 1 deletion internal/observability/metrics/manager/index/index.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func New(i service.Indexer) metrics.Metric {
}
}

func (im *indexerMetrics) View() ([]*metrics.View, error) {
func (*indexerMetrics) View() ([]*metrics.View, error) {
uuidCount, err := view.New(
view.MatchInstrumentName(uuidCountMetricsName),
view.WithSetDescription(uuidCountMetricsDescription),
Expand Down
4 changes: 2 additions & 2 deletions internal/observability/metrics/mem/index/index.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ func New() metrics.Metric {
return &memoryMetrics{}
}

func (mm *memoryMetrics) View() ([]*metrics.View, error) {
func (*memoryMetrics) View() ([]*metrics.View, error) {
alloc, err := view.New(
view.MatchInstrumentName(allocMetricsDescription),
view.WithSetDescription(allocMetricsDescription),
Expand Down Expand Up @@ -218,7 +218,7 @@ func (mm *memoryMetrics) View() ([]*metrics.View, error) {
}, nil
}

func (mm *memoryMetrics) Register(m metrics.Meter) error {
func (*memoryMetrics) Register(m metrics.Meter) error {
alloc, err := m.AsyncInt64().Gauge(
allocMetricsName,
metrics.WithDescription(allocMetricsDescription),
Expand Down
4 changes: 2 additions & 2 deletions internal/observability/metrics/runtime/cgo/cgo.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func New() metrics.Metric {
return &cgo{}
}

func (c *cgo) View() ([]*metrics.View, error) {
func (*cgo) View() ([]*metrics.View, error) {
count, err := view.New(
view.MatchInstrumentName(metricsName),
view.WithSetDescription(metricsDescription),
Expand All @@ -47,7 +47,7 @@ func (c *cgo) View() ([]*metrics.View, error) {
}, nil
}

func (c *cgo) Register(m metrics.Meter) error {
func (*cgo) Register(m metrics.Meter) error {
count, err := m.AsyncInt64().Gauge(
metricsName,
metrics.WithDescription(metricsDescription),
Expand Down
Loading