Skip to content

Commit bd5ceb5

Browse files
authored
Enable unused-receiver linter (revive) (#7448)
Signed-off-by: Anders Eknert <[email protected]>
1 parent 7049966 commit bd5ceb5

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+95
-93
lines changed

.golangci.yaml

+4-2
Original file line numberDiff line numberDiff line change
@@ -186,8 +186,10 @@ linters-settings:
186186
rules:
187187
# this mainly complains about us using min/max for variable names,
188188
# which seems like an unlikely source of actual issues
189-
- name: redefines-builtin-id
190-
disabled: true
189+
- name: redefines-builtin-id
190+
disabled: true
191+
- name: unused-receiver
192+
disabled: false
191193

192194
linters:
193195
disable-all: true

cmd/bench.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ func benchMain(args []string, params benchmarkCommandParams, w io.Writer, r benc
230230
type goBenchRunner struct {
231231
}
232232

233-
func (r *goBenchRunner) run(ctx context.Context, ectx *evalContext, params benchmarkCommandParams, f func(context.Context, ...rego.EvalOption) error) (testing.BenchmarkResult, error) {
233+
func (*goBenchRunner) run(ctx context.Context, ectx *evalContext, params benchmarkCommandParams, f func(context.Context, ...rego.EvalOption) error) (testing.BenchmarkResult, error) {
234234

235235
var hist, m metrics.Metrics
236236
if params.metrics {

cmd/eval.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -788,7 +788,7 @@ func newrepeatedStringFlag(val []string) repeatedStringFlag {
788788
}
789789
}
790790

791-
func (f *repeatedStringFlag) Type() string {
791+
func (*repeatedStringFlag) Type() string {
792792
return stringType
793793
}
794794

@@ -818,7 +818,7 @@ func newIntFlag(val int) intFlag {
818818
}
819819
}
820820

821-
func (f *intFlag) Type() string {
821+
func (*intFlag) Type() string {
822822
return "int"
823823
}
824824

cmd/flags.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ func newcapabilitiesFlag() *capabilitiesFlag {
207207
}
208208
}
209209

210-
func (f *capabilitiesFlag) Type() string {
210+
func (*capabilitiesFlag) Type() string {
211211
return stringType
212212
}
213213

@@ -236,7 +236,7 @@ type stringptrFlag struct {
236236
isSet bool
237237
}
238238

239-
func (f *stringptrFlag) Type() string {
239+
func (*stringptrFlag) Type() string {
240240
return stringType
241241
}
242242

cmd/internal/env/env.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ var (
2222

2323
const globalPrefix = "opa"
2424

25-
func (cf cmdFlagsImpl) CheckEnvironmentVariables(command *cobra.Command) error {
25+
func (cmdFlagsImpl) CheckEnvironmentVariables(command *cobra.Command) error {
2626
var errs []string
2727
v := viper.New()
2828
v.AutomaticEnv()

internal/logging/logging.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ func spaces(num int) string {
5050
return strings.Repeat(" ", num)
5151
}
5252

53-
func (p *prettyFormatter) Format(e *logrus.Entry) ([]byte, error) {
53+
func (*prettyFormatter) Format(e *logrus.Entry) ([]byte, error) {
5454
b := new(bytes.Buffer)
5555

5656
level := strings.ToUpper(e.Level.String())

internal/prometheus/prometheus.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ func (p *Provider) InstrumentHandler(handler http.Handler, label string) http.Ha
9494
}
9595

9696
// Info returns attributes that describe the metric provider.
97-
func (p *Provider) Info() metrics.Info {
97+
func (*Provider) Info() metrics.Info {
9898
return metrics.Info{
9999
Name: "prometheus",
100100
}

internal/providers/aws/signing_v4a.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ func buildAuthorizationHeader(credentialStr, signedHeadersStr, signingSignature
280280
return parts.String()
281281
}
282282

283-
func (s *httpSigner) buildCanonicalHeaders(host string, rule v4Internal.Rule, header http.Header, length int64) (signed http.Header, signedHeaders, canonicalHeadersStr string) {
283+
func (*httpSigner) buildCanonicalHeaders(host string, rule v4Internal.Rule, header http.Header, length int64) (signed http.Header, signedHeaders, canonicalHeadersStr string) {
284284
signed = make(http.Header)
285285

286286
const hostHeader = "host"

internal/wasm/module/module.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,7 @@ func (x ExportDescriptorType) String() string {
288288
}
289289

290290
// Kind returns the function import type kind.
291-
func (i FunctionImport) Kind() ImportDescriptorType {
291+
func (FunctionImport) Kind() ImportDescriptorType {
292292
return FunctionImportType
293293
}
294294

@@ -297,7 +297,7 @@ func (i FunctionImport) String() string {
297297
}
298298

299299
// Kind returns the memory import type kind.
300-
func (i MemoryImport) Kind() ImportDescriptorType {
300+
func (MemoryImport) Kind() ImportDescriptorType {
301301
return MemoryImportType
302302
}
303303

@@ -306,7 +306,7 @@ func (i MemoryImport) String() string {
306306
}
307307

308308
// Kind returns the table import type kind.
309-
func (i TableImport) Kind() ImportDescriptorType {
309+
func (TableImport) Kind() ImportDescriptorType {
310310
return TableImportType
311311
}
312312

@@ -315,7 +315,7 @@ func (i TableImport) String() string {
315315
}
316316

317317
// Kind returns the global import type kind.
318-
func (i GlobalImport) Kind() ImportDescriptorType {
318+
func (GlobalImport) Kind() ImportDescriptorType {
319319
return GlobalImportType
320320
}
321321

internal/wasm/sdk/opa/loader/http/loader.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ func (l *Loader) get(ctx context.Context, tag string) (*bundle.Bundle, error) {
258258

259259
// close closes the HTTP response gracefully, first draining it, to
260260
// avoid resource leaks.
261-
func (l *Loader) close(resp *http.Response) {
261+
func (*Loader) close(resp *http.Response) {
262262
_, _ = io.Copy(io.Discard, resp.Body) // Ignore errors.
263263
_ = resp.Body.Close()
264264
}

v1/ast/compile.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -3030,7 +3030,7 @@ func (qc *queryCompiler) resolveRefs(qctx *QueryContext, body Body) (Body, error
30303030
return resolveRefsInBody(globals, ignore, body), nil
30313031
}
30323032

3033-
func (qc *queryCompiler) rewriteComprehensionTerms(_ *QueryContext, body Body) (Body, error) {
3033+
func (*queryCompiler) rewriteComprehensionTerms(_ *QueryContext, body Body) (Body, error) {
30343034
gen := newLocalVarGenerator("q", body)
30353035
f := newEqualityFactory(gen)
30363036
node, err := rewriteComprehensionTerms(f, body)
@@ -3040,13 +3040,13 @@ func (qc *queryCompiler) rewriteComprehensionTerms(_ *QueryContext, body Body) (
30403040
return node.(Body), nil
30413041
}
30423042

3043-
func (qc *queryCompiler) rewriteDynamicTerms(_ *QueryContext, body Body) (Body, error) {
3043+
func (*queryCompiler) rewriteDynamicTerms(_ *QueryContext, body Body) (Body, error) {
30443044
gen := newLocalVarGenerator("q", body)
30453045
f := newEqualityFactory(gen)
30463046
return rewriteDynamics(f, body), nil
30473047
}
30483048

3049-
func (qc *queryCompiler) rewriteExprTerms(_ *QueryContext, body Body) (Body, error) {
3049+
func (*queryCompiler) rewriteExprTerms(_ *QueryContext, body Body) (Body, error) {
30503050
gen := newLocalVarGenerator("q", body)
30513051
return rewriteExprTermsInBody(gen, body), nil
30523052
}

v1/ast/term.go

+6-6
Original file line numberDiff line numberDiff line change
@@ -541,7 +541,7 @@ func NullTerm() *Term {
541541
}
542542

543543
// Equal returns true if the other term Value is also Null.
544-
func (null Null) Equal(other Value) bool {
544+
func (Null) Equal(other Value) bool {
545545
switch other.(type) {
546546
case Null:
547547
return true
@@ -552,23 +552,23 @@ func (null Null) Equal(other Value) bool {
552552

553553
// Compare compares null to other, return <0, 0, or >0 if it is less than, equal to,
554554
// or greater than other.
555-
func (null Null) Compare(other Value) int {
555+
func (Null) Compare(other Value) int {
556556
if _, ok := other.(Null); ok {
557557
return 0
558558
}
559559
return -1
560560
}
561561

562562
// Find returns the current value or a not found error.
563-
func (null Null) Find(path Ref) (Value, error) {
563+
func (Null) Find(path Ref) (Value, error) {
564564
if len(path) == 0 {
565565
return NullValue, nil
566566
}
567567
return nil, errFindNotFound
568568
}
569569

570570
// Hash returns the hash code for the Value.
571-
func (null Null) Hash() int {
571+
func (Null) Hash() int {
572572
return 0
573573
}
574574

@@ -577,7 +577,7 @@ func (Null) IsGround() bool {
577577
return true
578578
}
579579

580-
func (null Null) String() string {
580+
func (Null) String() string {
581581
return "null"
582582
}
583583

@@ -3036,7 +3036,7 @@ func (c Call) Compare(other Value) int {
30363036
}
30373037

30383038
// Find returns the current value or a not found error.
3039-
func (c Call) Find(Ref) (Value, error) {
3039+
func (Call) Find(Ref) (Value, error) {
30403040
return nil, errFindNotFound
30413041
}
30423042

v1/ast/unify.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ func (u *unifier) unifyAll(a Var, b Value) {
226226
}
227227
}
228228

229-
func (u *unifier) varVisitor() *VarVisitor {
229+
func (*unifier) varVisitor() *VarVisitor {
230230
return NewVarVisitor().WithParams(VarVisitorParams{
231231
SkipRefHead: true,
232232
SkipObjectKeys: true,

v1/compile/compile.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -1166,7 +1166,7 @@ func (o *optimizer) getSupportForEntrypoint(queries []ast.Body, entrypoint *ast.
11661166
// by rules in modules in 'b' then the module from 'a' is discarded.
11671167
// NOTE(sr): This function assumes that `b` is the result of partial eval, and thus does NOT
11681168
// contain any rules that genuinely need their ref heads.
1169-
func (o *optimizer) merge(a, b []bundle.ModuleFile) []bundle.ModuleFile {
1169+
func (*optimizer) merge(a, b []bundle.ModuleFile) []bundle.ModuleFile {
11701170

11711171
prefixes := ast.NewSet()
11721172

v1/cover/cover.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,12 @@ func New() *Cover {
2828
}
2929

3030
// Enabled returns true if coverage is enabled.
31-
func (c *Cover) Enabled() bool {
31+
func (*Cover) Enabled() bool {
3232
return true
3333
}
3434

3535
// Config returns the standard Tracer configuration for the Cover tracer
36-
func (c *Cover) Config() topdown.TraceConfig {
36+
func (*Cover) Config() topdown.TraceConfig {
3737
return topdown.TraceConfig{
3838
PlugLocalVars: false, // Event variable metadata is not required for the Coverage report
3939
}

v1/debug/debugger_test.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -2196,14 +2196,14 @@ func newTestStack(events ...*topdown.Event) *testStack {
21962196
}
21972197
}
21982198

2199-
func (ts *testStack) Enabled() bool {
2199+
func (*testStack) Enabled() bool {
22002200
return true
22012201
}
22022202

2203-
func (ts *testStack) TraceEvent(_ topdown.Event) {
2203+
func (*testStack) TraceEvent(_ topdown.Event) {
22042204
}
22052205

2206-
func (ts *testStack) Config() topdown.TraceConfig {
2206+
func (*testStack) Config() topdown.TraceConfig {
22072207
return topdown.TraceConfig{}
22082208
}
22092209

v1/debug/latch.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,5 +34,5 @@ func (l *latch) wait() {
3434
l.waitGroup.Wait()
3535
}
3636

37-
func (l *latch) Close() {
37+
func (*latch) Close() {
3838
}

v1/debug/trace.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ func (dt *debugTracer) TraceEvent(e topdown.Event) {
5454
<-dt.waitChan
5555
}
5656

57-
func (dt *debugTracer) Config() topdown.TraceConfig {
57+
func (*debugTracer) Config() topdown.TraceConfig {
5858
return topdown.TraceConfig{
5959
PlugLocalVars: true,
6060
}

v1/download/oci_download.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ func (d *OCIDownloader) WithBundleParserOpts(opts ast.ParserOptions) *OCIDownloa
9090
}
9191

9292
// ClearCache is deprecated. Use SetCache instead.
93-
func (d *OCIDownloader) ClearCache() {
93+
func (*OCIDownloader) ClearCache() {
9494
}
9595

9696
// SetCache sets the etag value to the SHA of the loaded bundle

v1/format/format.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -929,7 +929,7 @@ func (w *writer) writeRefStringPath(s ast.String) {
929929
}
930930
}
931931

932-
func (w *writer) formatVar(v ast.Var) string {
932+
func (*writer) formatVar(v ast.Var) string {
933933
if v.IsWildcard() {
934934
return ast.Wildcard.String()
935935
}

v1/ir/ir.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ const (
106106
Unused
107107
)
108108

109-
func (a *Policy) String() string {
109+
func (*Policy) String() string {
110110
return "Policy"
111111
}
112112

v1/metrics/metrics.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ func (m *metrics) Clear() {
178178
m.counters = map[string]Counter{}
179179
}
180180

181-
func (m *metrics) formatKey(name string, metrics interface{}) string {
181+
func (*metrics) formatKey(name string, metrics interface{}) string {
182182
switch metrics.(type) {
183183
case Timer:
184184
return "timer_" + name + "_ns"

v1/plugins/bundle/config.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ func (c *Config) validateAndInjectDefaultsLegacy(services []string) error {
233233
return nil
234234
}
235235

236-
func (c *Config) getServiceFromList(service string, services []string) (string, error) {
236+
func (*Config) getServiceFromList(service string, services []string) (string, error) {
237237
if service == "" && len(services) != 0 {
238238
return services[0], nil
239239
}

v1/plugins/bundle/plugin.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -678,7 +678,7 @@ func (p *Plugin) activate(ctx context.Context, name string, b *bundle.Bundle, is
678678
return err
679679
}
680680

681-
func (p *Plugin) persistBundle(name string, bundles map[string]*Source) bool {
681+
func (*Plugin) persistBundle(name string, bundles map[string]*Source) bool {
682682
bundleSrc := bundles[name]
683683

684684
if bundleSrc == nil {

v1/plugins/discovery/config.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ func (c *Config) validateAndInjectDefaults(services []string, confKeys map[strin
134134
return c.Config.ValidateAndInjectDefaults()
135135
}
136136

137-
func (c *Config) getServiceFromList(service string, services []string) (string, error) {
137+
func (*Config) getServiceFromList(service string, services []string) (string, error) {
138138
if service == "" {
139139
if len(services) != 1 {
140140
return "", errors.New("more than one service is defined")

v1/plugins/discovery/discovery_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -485,7 +485,7 @@ type testFactory struct {
485485
p *reconfigureTestPlugin
486486
}
487487

488-
func (f testFactory) Validate(*plugins.Manager, []byte) (interface{}, error) {
488+
func (testFactory) Validate(*plugins.Manager, []byte) (interface{}, error) {
489489
return nil, nil
490490
}
491491

v1/plugins/logs/mask.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ func (r maskRule) Mask(event *EventV1) error {
201201
return nil
202202
}
203203

204-
func (r maskRule) removeValue(p []string, node interface{}) error {
204+
func (maskRule) removeValue(p []string, node interface{}) error {
205205
if len(p) == 0 {
206206
return nil
207207
}
@@ -281,7 +281,7 @@ func (r maskRule) removeValue(p []string, node interface{}) error {
281281
return nil
282282
}
283283

284-
func (r maskRule) mkdirp(node interface{}, path []string, value interface{}) error {
284+
func (maskRule) mkdirp(node interface{}, path []string, value interface{}) error {
285285
if len(path) == 0 {
286286
return nil
287287
}

v1/plugins/plugins_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -625,7 +625,7 @@ func TestPluginManagerServerInitialized(t *testing.T) {
625625

626626
type myAuthPluginMock struct{}
627627

628-
func (m *myAuthPluginMock) NewClient(c rest.Config) (*http.Client, error) {
628+
func (*myAuthPluginMock) NewClient(c rest.Config) (*http.Client, error) {
629629
tlsConfig, err := rest.DefaultTLSConfig(c)
630630
if err != nil {
631631
return nil, err

0 commit comments

Comments
 (0)