diff --git a/.golangci.yaml b/.golangci.yaml index 0a9649e662..0d4197eec2 100644 --- a/.golangci.yaml +++ b/.golangci.yaml @@ -186,8 +186,10 @@ linters-settings: rules: # this mainly complains about us using min/max for variable names, # which seems like an unlikely source of actual issues - - name: redefines-builtin-id - disabled: true + - name: redefines-builtin-id + disabled: true + - name: unused-receiver + disabled: false linters: disable-all: true diff --git a/cmd/bench.go b/cmd/bench.go index f283e7dc5d..68be3904da 100644 --- a/cmd/bench.go +++ b/cmd/bench.go @@ -230,7 +230,7 @@ func benchMain(args []string, params benchmarkCommandParams, w io.Writer, r benc type goBenchRunner struct { } -func (r *goBenchRunner) run(ctx context.Context, ectx *evalContext, params benchmarkCommandParams, f func(context.Context, ...rego.EvalOption) error) (testing.BenchmarkResult, error) { +func (*goBenchRunner) run(ctx context.Context, ectx *evalContext, params benchmarkCommandParams, f func(context.Context, ...rego.EvalOption) error) (testing.BenchmarkResult, error) { var hist, m metrics.Metrics if params.metrics { diff --git a/cmd/eval.go b/cmd/eval.go index 0bf5dfe478..f78401b37a 100644 --- a/cmd/eval.go +++ b/cmd/eval.go @@ -788,7 +788,7 @@ func newrepeatedStringFlag(val []string) repeatedStringFlag { } } -func (f *repeatedStringFlag) Type() string { +func (*repeatedStringFlag) Type() string { return stringType } @@ -818,7 +818,7 @@ func newIntFlag(val int) intFlag { } } -func (f *intFlag) Type() string { +func (*intFlag) Type() string { return "int" } diff --git a/cmd/flags.go b/cmd/flags.go index e0f99677c1..3998d706aa 100644 --- a/cmd/flags.go +++ b/cmd/flags.go @@ -207,7 +207,7 @@ func newcapabilitiesFlag() *capabilitiesFlag { } } -func (f *capabilitiesFlag) Type() string { +func (*capabilitiesFlag) Type() string { return stringType } @@ -236,7 +236,7 @@ type stringptrFlag struct { isSet bool } -func (f *stringptrFlag) Type() string { +func (*stringptrFlag) Type() string { return stringType } diff --git a/cmd/internal/env/env.go b/cmd/internal/env/env.go index 3d0adbe97a..9a4e385e67 100644 --- a/cmd/internal/env/env.go +++ b/cmd/internal/env/env.go @@ -22,7 +22,7 @@ var ( const globalPrefix = "opa" -func (cf cmdFlagsImpl) CheckEnvironmentVariables(command *cobra.Command) error { +func (cmdFlagsImpl) CheckEnvironmentVariables(command *cobra.Command) error { var errs []string v := viper.New() v.AutomaticEnv() diff --git a/internal/logging/logging.go b/internal/logging/logging.go index dc28b1b356..acd44f8cad 100644 --- a/internal/logging/logging.go +++ b/internal/logging/logging.go @@ -50,7 +50,7 @@ func spaces(num int) string { return strings.Repeat(" ", num) } -func (p *prettyFormatter) Format(e *logrus.Entry) ([]byte, error) { +func (*prettyFormatter) Format(e *logrus.Entry) ([]byte, error) { b := new(bytes.Buffer) level := strings.ToUpper(e.Level.String()) diff --git a/internal/prometheus/prometheus.go b/internal/prometheus/prometheus.go index bda185a395..feab3617fe 100644 --- a/internal/prometheus/prometheus.go +++ b/internal/prometheus/prometheus.go @@ -94,7 +94,7 @@ func (p *Provider) InstrumentHandler(handler http.Handler, label string) http.Ha } // Info returns attributes that describe the metric provider. -func (p *Provider) Info() metrics.Info { +func (*Provider) Info() metrics.Info { return metrics.Info{ Name: "prometheus", } diff --git a/internal/providers/aws/signing_v4a.go b/internal/providers/aws/signing_v4a.go index 59e49c1f30..8f6d760e82 100644 --- a/internal/providers/aws/signing_v4a.go +++ b/internal/providers/aws/signing_v4a.go @@ -280,7 +280,7 @@ func buildAuthorizationHeader(credentialStr, signedHeadersStr, signingSignature return parts.String() } -func (s *httpSigner) buildCanonicalHeaders(host string, rule v4Internal.Rule, header http.Header, length int64) (signed http.Header, signedHeaders, canonicalHeadersStr string) { +func (*httpSigner) buildCanonicalHeaders(host string, rule v4Internal.Rule, header http.Header, length int64) (signed http.Header, signedHeaders, canonicalHeadersStr string) { signed = make(http.Header) const hostHeader = "host" diff --git a/internal/wasm/module/module.go b/internal/wasm/module/module.go index 913863c10c..033d429c89 100644 --- a/internal/wasm/module/module.go +++ b/internal/wasm/module/module.go @@ -288,7 +288,7 @@ func (x ExportDescriptorType) String() string { } // Kind returns the function import type kind. -func (i FunctionImport) Kind() ImportDescriptorType { +func (FunctionImport) Kind() ImportDescriptorType { return FunctionImportType } @@ -297,7 +297,7 @@ func (i FunctionImport) String() string { } // Kind returns the memory import type kind. -func (i MemoryImport) Kind() ImportDescriptorType { +func (MemoryImport) Kind() ImportDescriptorType { return MemoryImportType } @@ -306,7 +306,7 @@ func (i MemoryImport) String() string { } // Kind returns the table import type kind. -func (i TableImport) Kind() ImportDescriptorType { +func (TableImport) Kind() ImportDescriptorType { return TableImportType } @@ -315,7 +315,7 @@ func (i TableImport) String() string { } // Kind returns the global import type kind. -func (i GlobalImport) Kind() ImportDescriptorType { +func (GlobalImport) Kind() ImportDescriptorType { return GlobalImportType } diff --git a/internal/wasm/sdk/opa/loader/http/loader.go b/internal/wasm/sdk/opa/loader/http/loader.go index 1930881724..e7577c1132 100644 --- a/internal/wasm/sdk/opa/loader/http/loader.go +++ b/internal/wasm/sdk/opa/loader/http/loader.go @@ -258,7 +258,7 @@ func (l *Loader) get(ctx context.Context, tag string) (*bundle.Bundle, error) { // close closes the HTTP response gracefully, first draining it, to // avoid resource leaks. -func (l *Loader) close(resp *http.Response) { +func (*Loader) close(resp *http.Response) { _, _ = io.Copy(io.Discard, resp.Body) // Ignore errors. _ = resp.Body.Close() } diff --git a/v1/ast/compile.go b/v1/ast/compile.go index 2092708af6..13855692cd 100644 --- a/v1/ast/compile.go +++ b/v1/ast/compile.go @@ -3030,7 +3030,7 @@ func (qc *queryCompiler) resolveRefs(qctx *QueryContext, body Body) (Body, error return resolveRefsInBody(globals, ignore, body), nil } -func (qc *queryCompiler) rewriteComprehensionTerms(_ *QueryContext, body Body) (Body, error) { +func (*queryCompiler) rewriteComprehensionTerms(_ *QueryContext, body Body) (Body, error) { gen := newLocalVarGenerator("q", body) f := newEqualityFactory(gen) node, err := rewriteComprehensionTerms(f, body) @@ -3040,13 +3040,13 @@ func (qc *queryCompiler) rewriteComprehensionTerms(_ *QueryContext, body Body) ( return node.(Body), nil } -func (qc *queryCompiler) rewriteDynamicTerms(_ *QueryContext, body Body) (Body, error) { +func (*queryCompiler) rewriteDynamicTerms(_ *QueryContext, body Body) (Body, error) { gen := newLocalVarGenerator("q", body) f := newEqualityFactory(gen) return rewriteDynamics(f, body), nil } -func (qc *queryCompiler) rewriteExprTerms(_ *QueryContext, body Body) (Body, error) { +func (*queryCompiler) rewriteExprTerms(_ *QueryContext, body Body) (Body, error) { gen := newLocalVarGenerator("q", body) return rewriteExprTermsInBody(gen, body), nil } diff --git a/v1/ast/term.go b/v1/ast/term.go index 866fc4ddb6..e0fda51e89 100644 --- a/v1/ast/term.go +++ b/v1/ast/term.go @@ -541,7 +541,7 @@ func NullTerm() *Term { } // Equal returns true if the other term Value is also Null. -func (null Null) Equal(other Value) bool { +func (Null) Equal(other Value) bool { switch other.(type) { case Null: return true @@ -552,7 +552,7 @@ func (null Null) Equal(other Value) bool { // Compare compares null to other, return <0, 0, or >0 if it is less than, equal to, // or greater than other. -func (null Null) Compare(other Value) int { +func (Null) Compare(other Value) int { if _, ok := other.(Null); ok { return 0 } @@ -560,7 +560,7 @@ func (null Null) Compare(other Value) int { } // Find returns the current value or a not found error. -func (null Null) Find(path Ref) (Value, error) { +func (Null) Find(path Ref) (Value, error) { if len(path) == 0 { return NullValue, nil } @@ -568,7 +568,7 @@ func (null Null) Find(path Ref) (Value, error) { } // Hash returns the hash code for the Value. -func (null Null) Hash() int { +func (Null) Hash() int { return 0 } @@ -577,7 +577,7 @@ func (Null) IsGround() bool { return true } -func (null Null) String() string { +func (Null) String() string { return "null" } @@ -3036,7 +3036,7 @@ func (c Call) Compare(other Value) int { } // Find returns the current value or a not found error. -func (c Call) Find(Ref) (Value, error) { +func (Call) Find(Ref) (Value, error) { return nil, errFindNotFound } diff --git a/v1/ast/unify.go b/v1/ast/unify.go index 182aae090b..3af52815f7 100644 --- a/v1/ast/unify.go +++ b/v1/ast/unify.go @@ -226,7 +226,7 @@ func (u *unifier) unifyAll(a Var, b Value) { } } -func (u *unifier) varVisitor() *VarVisitor { +func (*unifier) varVisitor() *VarVisitor { return NewVarVisitor().WithParams(VarVisitorParams{ SkipRefHead: true, SkipObjectKeys: true, diff --git a/v1/compile/compile.go b/v1/compile/compile.go index 9a8ab1a8a6..dac4e59491 100644 --- a/v1/compile/compile.go +++ b/v1/compile/compile.go @@ -1166,7 +1166,7 @@ func (o *optimizer) getSupportForEntrypoint(queries []ast.Body, entrypoint *ast. // by rules in modules in 'b' then the module from 'a' is discarded. // NOTE(sr): This function assumes that `b` is the result of partial eval, and thus does NOT // contain any rules that genuinely need their ref heads. -func (o *optimizer) merge(a, b []bundle.ModuleFile) []bundle.ModuleFile { +func (*optimizer) merge(a, b []bundle.ModuleFile) []bundle.ModuleFile { prefixes := ast.NewSet() diff --git a/v1/cover/cover.go b/v1/cover/cover.go index c99d8f5051..fc642661a2 100644 --- a/v1/cover/cover.go +++ b/v1/cover/cover.go @@ -28,12 +28,12 @@ func New() *Cover { } // Enabled returns true if coverage is enabled. -func (c *Cover) Enabled() bool { +func (*Cover) Enabled() bool { return true } // Config returns the standard Tracer configuration for the Cover tracer -func (c *Cover) Config() topdown.TraceConfig { +func (*Cover) Config() topdown.TraceConfig { return topdown.TraceConfig{ PlugLocalVars: false, // Event variable metadata is not required for the Coverage report } diff --git a/v1/debug/debugger_test.go b/v1/debug/debugger_test.go index 1498570a4c..6c483d6dcb 100644 --- a/v1/debug/debugger_test.go +++ b/v1/debug/debugger_test.go @@ -2196,14 +2196,14 @@ func newTestStack(events ...*topdown.Event) *testStack { } } -func (ts *testStack) Enabled() bool { +func (*testStack) Enabled() bool { return true } -func (ts *testStack) TraceEvent(_ topdown.Event) { +func (*testStack) TraceEvent(_ topdown.Event) { } -func (ts *testStack) Config() topdown.TraceConfig { +func (*testStack) Config() topdown.TraceConfig { return topdown.TraceConfig{} } diff --git a/v1/debug/latch.go b/v1/debug/latch.go index cc73bde254..c58c26fe94 100644 --- a/v1/debug/latch.go +++ b/v1/debug/latch.go @@ -34,5 +34,5 @@ func (l *latch) wait() { l.waitGroup.Wait() } -func (l *latch) Close() { +func (*latch) Close() { } diff --git a/v1/debug/trace.go b/v1/debug/trace.go index d96b4f065f..f37c245fc3 100644 --- a/v1/debug/trace.go +++ b/v1/debug/trace.go @@ -54,7 +54,7 @@ func (dt *debugTracer) TraceEvent(e topdown.Event) { <-dt.waitChan } -func (dt *debugTracer) Config() topdown.TraceConfig { +func (*debugTracer) Config() topdown.TraceConfig { return topdown.TraceConfig{ PlugLocalVars: true, } diff --git a/v1/download/oci_download.go b/v1/download/oci_download.go index 0d5420f56b..5a680ed4ed 100644 --- a/v1/download/oci_download.go +++ b/v1/download/oci_download.go @@ -90,7 +90,7 @@ func (d *OCIDownloader) WithBundleParserOpts(opts ast.ParserOptions) *OCIDownloa } // ClearCache is deprecated. Use SetCache instead. -func (d *OCIDownloader) ClearCache() { +func (*OCIDownloader) ClearCache() { } // SetCache sets the etag value to the SHA of the loaded bundle diff --git a/v1/format/format.go b/v1/format/format.go index 10589d26d3..30d73f2d09 100644 --- a/v1/format/format.go +++ b/v1/format/format.go @@ -929,7 +929,7 @@ func (w *writer) writeRefStringPath(s ast.String) { } } -func (w *writer) formatVar(v ast.Var) string { +func (*writer) formatVar(v ast.Var) string { if v.IsWildcard() { return ast.Wildcard.String() } diff --git a/v1/ir/ir.go b/v1/ir/ir.go index 4f6961605d..3657a9b673 100644 --- a/v1/ir/ir.go +++ b/v1/ir/ir.go @@ -106,7 +106,7 @@ const ( Unused ) -func (a *Policy) String() string { +func (*Policy) String() string { return "Policy" } diff --git a/v1/metrics/metrics.go b/v1/metrics/metrics.go index eaf0d99593..f1038e8bcb 100644 --- a/v1/metrics/metrics.go +++ b/v1/metrics/metrics.go @@ -178,7 +178,7 @@ func (m *metrics) Clear() { m.counters = map[string]Counter{} } -func (m *metrics) formatKey(name string, metrics interface{}) string { +func (*metrics) formatKey(name string, metrics interface{}) string { switch metrics.(type) { case Timer: return "timer_" + name + "_ns" diff --git a/v1/plugins/bundle/config.go b/v1/plugins/bundle/config.go index ee32ed9781..8a75caa888 100644 --- a/v1/plugins/bundle/config.go +++ b/v1/plugins/bundle/config.go @@ -233,7 +233,7 @@ func (c *Config) validateAndInjectDefaultsLegacy(services []string) error { return nil } -func (c *Config) getServiceFromList(service string, services []string) (string, error) { +func (*Config) getServiceFromList(service string, services []string) (string, error) { if service == "" && len(services) != 0 { return services[0], nil } diff --git a/v1/plugins/bundle/plugin.go b/v1/plugins/bundle/plugin.go index 8d5577f2d7..422dbe9626 100644 --- a/v1/plugins/bundle/plugin.go +++ b/v1/plugins/bundle/plugin.go @@ -678,7 +678,7 @@ func (p *Plugin) activate(ctx context.Context, name string, b *bundle.Bundle, is return err } -func (p *Plugin) persistBundle(name string, bundles map[string]*Source) bool { +func (*Plugin) persistBundle(name string, bundles map[string]*Source) bool { bundleSrc := bundles[name] if bundleSrc == nil { diff --git a/v1/plugins/discovery/config.go b/v1/plugins/discovery/config.go index dac9060da7..117b28c56a 100644 --- a/v1/plugins/discovery/config.go +++ b/v1/plugins/discovery/config.go @@ -134,7 +134,7 @@ func (c *Config) validateAndInjectDefaults(services []string, confKeys map[strin return c.Config.ValidateAndInjectDefaults() } -func (c *Config) getServiceFromList(service string, services []string) (string, error) { +func (*Config) getServiceFromList(service string, services []string) (string, error) { if service == "" { if len(services) != 1 { return "", errors.New("more than one service is defined") diff --git a/v1/plugins/discovery/discovery_test.go b/v1/plugins/discovery/discovery_test.go index fcf8bda7e9..132ba34dbb 100644 --- a/v1/plugins/discovery/discovery_test.go +++ b/v1/plugins/discovery/discovery_test.go @@ -485,7 +485,7 @@ type testFactory struct { p *reconfigureTestPlugin } -func (f testFactory) Validate(*plugins.Manager, []byte) (interface{}, error) { +func (testFactory) Validate(*plugins.Manager, []byte) (interface{}, error) { return nil, nil } diff --git a/v1/plugins/logs/mask.go b/v1/plugins/logs/mask.go index 9c84a764cc..8a03e1f1f7 100644 --- a/v1/plugins/logs/mask.go +++ b/v1/plugins/logs/mask.go @@ -201,7 +201,7 @@ func (r maskRule) Mask(event *EventV1) error { return nil } -func (r maskRule) removeValue(p []string, node interface{}) error { +func (maskRule) removeValue(p []string, node interface{}) error { if len(p) == 0 { return nil } @@ -281,7 +281,7 @@ func (r maskRule) removeValue(p []string, node interface{}) error { return nil } -func (r maskRule) mkdirp(node interface{}, path []string, value interface{}) error { +func (maskRule) mkdirp(node interface{}, path []string, value interface{}) error { if len(path) == 0 { return nil } diff --git a/v1/plugins/plugins_test.go b/v1/plugins/plugins_test.go index e2aa4f8f38..9112192fd1 100644 --- a/v1/plugins/plugins_test.go +++ b/v1/plugins/plugins_test.go @@ -625,7 +625,7 @@ func TestPluginManagerServerInitialized(t *testing.T) { type myAuthPluginMock struct{} -func (m *myAuthPluginMock) NewClient(c rest.Config) (*http.Client, error) { +func (*myAuthPluginMock) NewClient(c rest.Config) (*http.Client, error) { tlsConfig, err := rest.DefaultTLSConfig(c) if err != nil { return nil, err diff --git a/v1/plugins/rest/auth.go b/v1/plugins/rest/auth.go index abd391f015..7ef9bf7dfd 100644 --- a/v1/plugins/rest/auth.go +++ b/v1/plugins/rest/auth.go @@ -376,7 +376,7 @@ func (ap *oauth2ClientCredentialsAuthPlugin) createAuthJWT(ctx context.Context, return &jwt, nil } -func (ap *oauth2ClientCredentialsAuthPlugin) mapKMSAlgToSign(alg string) (string, error) { +func (*oauth2ClientCredentialsAuthPlugin) mapKMSAlgToSign(alg string) (string, error) { switch alg { case "ECDSA_SHA_256": return "ES256", nil @@ -758,7 +758,7 @@ func (ap *clientTLSAuthPlugin) NewClient(c Config) (*http.Client, error) { return client, nil } -func (ap *clientTLSAuthPlugin) Prepare(_ *http.Request) error { +func (*clientTLSAuthPlugin) Prepare(_ *http.Request) error { return nil } diff --git a/v1/plugins/rest/aws.go b/v1/plugins/rest/aws.go index defae62be0..a610a8014b 100644 --- a/v1/plugins/rest/aws.go +++ b/v1/plugins/rest/aws.go @@ -69,7 +69,7 @@ type awsEnvironmentCredentialService struct { logger logging.Logger } -func (cs *awsEnvironmentCredentialService) credentials(context.Context) (aws.Credentials, error) { +func (*awsEnvironmentCredentialService) credentials(context.Context) (aws.Credentials, error) { var creds aws.Credentials creds.AccessKey = os.Getenv(accessKeyEnvVar) if creds.AccessKey == "" { diff --git a/v1/plugins/rest/rest_test.go b/v1/plugins/rest/rest_test.go index 98ac5be881..48ab617ebd 100644 --- a/v1/plugins/rest/rest_test.go +++ b/v1/plugins/rest/rest_test.go @@ -2554,7 +2554,7 @@ func mockAuthPluginLookup(name string) HTTPAuthPlugin { type myPluginMock struct{} -func (m *myPluginMock) NewClient(c Config) (*http.Client, error) { +func (*myPluginMock) NewClient(c Config) (*http.Client, error) { tlsConfig, err := DefaultTLSConfig(c) if err != nil { return nil, err diff --git a/v1/plugins/status/plugin_test.go b/v1/plugins/status/plugin_test.go index 71b7ace024..a99024bc9d 100644 --- a/v1/plugins/status/plugin_test.go +++ b/v1/plugins/status/plugin_test.go @@ -1162,10 +1162,10 @@ func (*testPlugin) Start(context.Context) error { return nil } -func (p *testPlugin) Stop(context.Context) { +func (*testPlugin) Stop(context.Context) { } -func (p *testPlugin) Reconfigure(context.Context, interface{}) { +func (*testPlugin) Reconfigure(context.Context, interface{}) { } func (p *testPlugin) Log(_ context.Context, req *UpdateRequestV1) error { diff --git a/v1/refactor/refactor.go b/v1/refactor/refactor.go index a951d01f82..92633332a5 100644 --- a/v1/refactor/refactor.go +++ b/v1/refactor/refactor.go @@ -69,7 +69,7 @@ func (mqr *MoveQueryResult) validate() error { // Move rewrites Rego code by updating package paths and other references in q's modules as per // the mapping specified in q. -func (r *Refactor) Move(q MoveQuery) (*MoveQueryResult, error) { +func (*Refactor) Move(q MoveQuery) (*MoveQueryResult, error) { for _, module := range q.Modules { t := ast.NewGenericTransformer(func(x interface{}) (interface{}, error) { diff --git a/v1/rego/plugins.go b/v1/rego/plugins.go index 88f23480b4..55b5ed7803 100644 --- a/v1/rego/plugins.go +++ b/v1/rego/plugins.go @@ -24,7 +24,7 @@ type TargetPluginEval interface { Eval(context.Context, *EvalContext, ast.Value) (ast.Value, error) } -func (r *Rego) targetPlugin(tgt string) TargetPlugin { +func (*Rego) targetPlugin(tgt string) TargetPlugin { for _, p := range targetPlugins { if p.IsTarget(tgt) { return p diff --git a/v1/rego/rego.go b/v1/rego/rego.go index 64b3ef5963..fae39273af 100644 --- a/v1/rego/rego.go +++ b/v1/rego/rego.go @@ -1985,7 +1985,7 @@ func (r *Rego) parseInput() (ast.Value, error) { return r.parseRawInput(r.rawInput, r.metrics) } -func (r *Rego) parseRawInput(rawInput *interface{}, m metrics.Metrics) (ast.Value, error) { +func (*Rego) parseRawInput(rawInput *interface{}, m metrics.Metrics) (ast.Value, error) { var input ast.Value if rawInput == nil { @@ -2615,7 +2615,7 @@ func (r *Rego) rewriteQueryToCaptureValue(_ ast.QueryCompiler, query ast.Body) ( return query, nil } -func (r *Rego) rewriteQueryForPartialEval(_ ast.QueryCompiler, query ast.Body) (ast.Body, error) { +func (*Rego) rewriteQueryForPartialEval(_ ast.QueryCompiler, query ast.Body) (ast.Body, error) { if len(query) != 1 { return nil, errors.New("partial evaluation requires single ref (not multiple expressions)") } @@ -2641,7 +2641,7 @@ func (r *Rego) rewriteQueryForPartialEval(_ ast.QueryCompiler, query ast.Body) ( // this wouldn't be done, except for handling queries with the `Partial` API // where rewriting them can substantially simplify the result, and it is unlikely // that the caller would need expression values. -func (r *Rego) rewriteEqualsForPartialQueryCompile(_ ast.QueryCompiler, query ast.Body) (ast.Body, error) { +func (*Rego) rewriteEqualsForPartialQueryCompile(_ ast.QueryCompiler, query ast.Body) (ast.Body, error) { doubleEq := ast.Equal.Ref() unifyOp := ast.Equality.Ref() ast.WalkExprs(query, func(x *ast.Expr) bool { diff --git a/v1/repl/repl.go b/v1/repl/repl.go index 3fb9d928d8..e4a98c48fa 100644 --- a/v1/repl/repl.go +++ b/v1/repl/repl.go @@ -451,7 +451,7 @@ func (r *REPL) cmdDumpPath(ctx context.Context, filename string) error { return dumpStorage(ctx, r.store, r.txn, f) } -func (r *REPL) cmdExit() error { +func (*REPL) cmdExit() error { return stop{} } diff --git a/v1/runtime/plugins_test.go b/v1/runtime/plugins_test.go index 30e12f4022..31cb7ff81d 100644 --- a/v1/runtime/plugins_test.go +++ b/v1/runtime/plugins_test.go @@ -25,9 +25,9 @@ func (t *Tester) Start(_ context.Context) error { return t.startErr } -func (t *Tester) Stop(_ context.Context) {} +func (*Tester) Stop(_ context.Context) {} -func (t *Tester) Reconfigure(_ context.Context, _ interface{}) {} +func (*Tester) Reconfigure(_ context.Context, _ interface{}) {} type Config struct { ConfigErr bool `json:"configerr"` @@ -35,7 +35,7 @@ type Config struct { type Factory struct{} -func (f Factory) Validate(_ *plugins.Manager, config []byte) (interface{}, error) { +func (Factory) Validate(_ *plugins.Manager, config []byte) (interface{}, error) { cfg := Config{} @@ -50,7 +50,7 @@ func (f Factory) Validate(_ *plugins.Manager, config []byte) (interface{}, error return cfg, nil } -func (f Factory) New(_ *plugins.Manager, _ interface{}) plugins.Plugin { +func (Factory) New(_ *plugins.Manager, _ interface{}) plugins.Plugin { return &Tester{} } diff --git a/v1/runtime/runtime.go b/v1/runtime/runtime.go index c2707d1244..d3a27aeeaa 100644 --- a/v1/runtime/runtime.go +++ b/v1/runtime/runtime.go @@ -901,7 +901,7 @@ func (rt *Runtime) processWatcherUpdate(ctx context.Context, paths []string, rem }) } -func (rt *Runtime) getBanner() string { +func (*Runtime) getBanner() string { var buf bytes.Buffer fmt.Fprintf(&buf, "OPA %v (commit %v, built at %v)\n", version.Version, version.Vcs, version.Timestamp) fmt.Fprintf(&buf, "\n") diff --git a/v1/sdk/RawMapper.go b/v1/sdk/RawMapper.go index b0f6f1b0db..e17f6f7ebc 100644 --- a/v1/sdk/RawMapper.go +++ b/v1/sdk/RawMapper.go @@ -7,11 +7,11 @@ import ( type RawMapper struct { } -func (e *RawMapper) MapResults(pq *rego.PartialQueries) (interface{}, error) { +func (*RawMapper) MapResults(pq *rego.PartialQueries) (interface{}, error) { return pq, nil } -func (e *RawMapper) ResultToJSON(results interface{}) (interface{}, error) { +func (*RawMapper) ResultToJSON(results interface{}) (interface{}, error) { return results, nil } diff --git a/v1/server/authorizer/authorizer_test.go b/v1/server/authorizer/authorizer_test.go index fa58443f52..d7c6229d73 100644 --- a/v1/server/authorizer/authorizer_test.go +++ b/v1/server/authorizer/authorizer_test.go @@ -36,7 +36,7 @@ func (a appendingPrintHook) Print(_ print.Context, s string) error { return nil } -func (h *mockHandler) ServeHTTP(w http.ResponseWriter, _ *http.Request) { +func (*mockHandler) ServeHTTP(w http.ResponseWriter, _ *http.Request) { w.WriteHeader(200) } diff --git a/v1/server/server.go b/v1/server/server.go index 94e7c80937..2b4f5fc193 100644 --- a/v1/server/server.go +++ b/v1/server/server.go @@ -980,7 +980,7 @@ func (s *Server) execQuery(ctx context.Context, br bundleRevisions, txn storage. return &results, nil } -func (s *Server) indexGet(w http.ResponseWriter, _ *http.Request) { +func (*Server) indexGet(w http.ResponseWriter, _ *http.Request) { _ = indexHTML.Execute(w, struct { Version string BuildCommit string @@ -1213,7 +1213,7 @@ func (s *Server) canEval(ctx context.Context) bool { return false } -func (s *Server) bundlesReady(pluginStatuses map[string]*plugins.Status) bool { +func (*Server) bundlesReady(pluginStatuses map[string]*plugins.Status) bool { // Look for a discovery plugin first, if it exists and isn't ready // then don't bother with the others. @@ -2470,7 +2470,7 @@ func (s *Server) getDecisionLogger(br bundleRevisions) (logger decisionLogger) { return logger } -func (s *Server) getExplainResponse(explainMode types.ExplainModeV1, trace []*topdown.Event, pretty bool) (explanation types.TraceV1) { +func (*Server) getExplainResponse(explainMode types.ExplainModeV1, trace []*topdown.Event, pretty bool) (explanation types.TraceV1) { switch explainMode { case types.ExplainNotesV1: var err error @@ -2569,7 +2569,7 @@ func (s *Server) makeRego(_ context.Context, return rego.New(opts...), nil } -func (s *Server) prepareV1PatchSlice(root string, ops []types.PatchV1) (result []patchImpl, err error) { +func (*Server) prepareV1PatchSlice(root string, ops []types.PatchV1) (result []patchImpl, err error) { root = "/" + strings.Trim(root, "/") diff --git a/v1/server/server_test.go b/v1/server/server_test.go index c0e18faeb4..d45ead8ea8 100644 --- a/v1/server/server_test.go +++ b/v1/server/server_test.go @@ -5145,7 +5145,7 @@ type queryBindingErrStore struct { storage.PolicyNotSupported } -func (s *queryBindingErrStore) Read(_ context.Context, _ storage.Transaction, _ storage.Path) (interface{}, error) { +func (*queryBindingErrStore) Read(_ context.Context, _ storage.Transaction, _ storage.Path) (interface{}, error) { return nil, errors.New("expected error") } diff --git a/v1/storage/disk/disk.go b/v1/storage/disk/disk.go index 059d0f4e14..6db611d5a1 100644 --- a/v1/storage/disk/disk.go +++ b/v1/storage/disk/disk.go @@ -461,7 +461,7 @@ func (db *Store) backupAndLoadDB() (*badger.DB, error) { return newDB, wrapError(os.RemoveAll(backupDir)) } -func (db *Store) cleanup(oldDB *badger.DB) error { +func (*Store) cleanup(oldDB *badger.DB) error { err := oldDB.Close() if err != nil { return wrapError(err) @@ -669,7 +669,7 @@ func (h *handle) Unregister(_ context.Context, txn storage.Transaction) { delete(h.db.triggers, h) } -func (db *Store) loadMetadata(txn *badger.Txn, m *metadata) (bool, error) { +func (*Store) loadMetadata(txn *badger.Txn, m *metadata) (bool, error) { item, err := txn.Get([]byte(metadataKey)) if err != nil { @@ -692,7 +692,7 @@ func (db *Store) loadMetadata(txn *badger.Txn, m *metadata) (bool, error) { return true, nil } -func (db *Store) setMetadata(txn *badger.Txn, m metadata) error { +func (*Store) setMetadata(txn *badger.Txn, m metadata) error { bs, err := json.Marshal(m) if err != nil { diff --git a/v1/storage/disk/paths.go b/v1/storage/disk/paths.go index 1364540a50..909bdf17cc 100644 --- a/v1/storage/disk/paths.go +++ b/v1/storage/disk/paths.go @@ -40,7 +40,7 @@ func (pm *pathMapper) PolicyID2Key(id string) []byte { return []byte(pm.policiesPrefix + id) } -func (pm *pathMapper) DataKey2Path(key []byte) (storage.Path, error) { +func (*pathMapper) DataKey2Path(key []byte) (storage.Path, error) { p, ok := storage.ParsePathEscaped(string(key)) if !ok { return nil, &storage.Error{Code: storage.InternalErr, Message: fmt.Sprintf("corrupt key: %s", key)} diff --git a/v1/test/e2e/testing.go b/v1/test/e2e/testing.go index 9dca6e93b3..b99f3c6eb8 100644 --- a/v1/test/e2e/testing.go +++ b/v1/test/e2e/testing.go @@ -460,7 +460,7 @@ func (t *TestRuntime) compileRequest(req types.CompileRequestV1, instrument bool return &typedResp, nil } -func (t *TestRuntime) request(method, url string, input io.Reader) (io.ReadCloser, error) { +func (*TestRuntime) request(method, url string, input io.Reader) (io.ReadCloser, error) { req, err := http.NewRequest(method, url, input) if err != nil { return nil, fmt.Errorf("unexpected error: %w", err) diff --git a/v1/tester/runner.go b/v1/tester/runner.go index 6bf24a53a7..634ea5508c 100644 --- a/v1/tester/runner.go +++ b/v1/tester/runner.go @@ -518,7 +518,7 @@ func (r *Runner) runTests(ctx context.Context, txn storage.Transaction, enablePr return ch, nil } -func (r *Runner) shouldRun(rule *ast.Rule, testRegex *regexp.Regexp) bool { +func (*Runner) shouldRun(rule *ast.Rule, testRegex *regexp.Regexp) bool { var ref ast.Ref for _, term := range rule.Head.Ref().GroundPrefix() { diff --git a/v1/topdown/cache/cache.go b/v1/topdown/cache/cache.go index 064e9c4adc..60f38aaba2 100644 --- a/v1/topdown/cache/cache.go +++ b/v1/topdown/cache/cache.go @@ -325,7 +325,7 @@ func (c *cache) unsafeDelete(k ast.Value) { c.l.Remove(cacheItem.keyElement) } -func (c *cache) unsafeClone(value InterQueryCacheValue) (InterQueryCacheValue, error) { +func (*cache) unsafeClone(value InterQueryCacheValue) (InterQueryCacheValue, error) { return value.Clone() } diff --git a/v1/topdown/copypropagation/copypropagation.go b/v1/topdown/copypropagation/copypropagation.go index 233bbcad1b..9f4beca54a 100644 --- a/v1/topdown/copypropagation/copypropagation.go +++ b/v1/topdown/copypropagation/copypropagation.go @@ -209,7 +209,7 @@ func (p *CopyPropagator) Apply(query ast.Body) ast.Body { // plugBindings applies the binding list and union-find to x. This process // removes as many variables as possible. -func (p *CopyPropagator) plugBindings(pctx *plugContext, expr *ast.Expr) *ast.Expr { +func (*CopyPropagator) plugBindings(pctx *plugContext, expr *ast.Expr) *ast.Expr { xform := bindingPlugTransform{ pctx: pctx, @@ -244,7 +244,7 @@ func (t bindingPlugTransform) Transform(x interface{}) (interface{}, error) { } } -func (t bindingPlugTransform) plugBindingsVar(pctx *plugContext, v ast.Var) ast.Value { +func (bindingPlugTransform) plugBindingsVar(pctx *plugContext, v ast.Var) ast.Value { var result ast.Value = v @@ -274,7 +274,7 @@ func (t bindingPlugTransform) plugBindingsVar(pctx *plugContext, v ast.Var) ast. return b } -func (t bindingPlugTransform) plugBindingsRef(pctx *plugContext, v ast.Ref) ast.Ref { +func (bindingPlugTransform) plugBindingsRef(pctx *plugContext, v ast.Ref) ast.Ref { // Apply union-find to remove redundant variables from input. if root, ok := pctx.uf.Find(v[0].Value); ok { diff --git a/v1/topdown/eval.go b/v1/topdown/eval.go index 635ea38451..af59d42632 100644 --- a/v1/topdown/eval.go +++ b/v1/topdown/eval.go @@ -3216,7 +3216,7 @@ func (q vcKeyScope) Hash() int { return hash } -func (q vcKeyScope) IsGround() bool { +func (vcKeyScope) IsGround() bool { return false } diff --git a/v1/topdown/http.go b/v1/topdown/http.go index 2d29c12f4d..463f01de22 100644 --- a/v1/topdown/http.go +++ b/v1/topdown/http.go @@ -1197,7 +1197,7 @@ func (c *interQueryCacheData) toCacheValue() (*interQueryCacheValue, error) { return &interQueryCacheValue{Data: b}, nil } -func (c *interQueryCacheData) SizeInBytes() int64 { +func (*interQueryCacheData) SizeInBytes() int64 { return 0 } diff --git a/v1/topdown/http_test.go b/v1/topdown/http_test.go index 575b055b12..de1b8dbc94 100644 --- a/v1/topdown/http_test.go +++ b/v1/topdown/http_test.go @@ -3180,19 +3180,19 @@ func (c *onlyOnceInterQueryCache) Get(_ ast.Value) (value iCache.InterQueryCache return nil, false } -func (c *onlyOnceInterQueryCache) Insert(_ ast.Value, _ iCache.InterQueryCacheValue) int { +func (*onlyOnceInterQueryCache) Insert(_ ast.Value, _ iCache.InterQueryCacheValue) int { return 0 } -func (c *onlyOnceInterQueryCache) InsertWithExpiry(_ ast.Value, _ iCache.InterQueryCacheValue, _ time.Time) int { +func (*onlyOnceInterQueryCache) InsertWithExpiry(_ ast.Value, _ iCache.InterQueryCacheValue, _ time.Time) int { return 0 } -func (c *onlyOnceInterQueryCache) Delete(_ ast.Value) {} +func (*onlyOnceInterQueryCache) Delete(_ ast.Value) {} -func (c *onlyOnceInterQueryCache) UpdateConfig(_ *iCache.Config) {} +func (*onlyOnceInterQueryCache) UpdateConfig(_ *iCache.Config) {} -func (c *onlyOnceInterQueryCache) Clone(val iCache.InterQueryCacheValue) (iCache.InterQueryCacheValue, error) { +func (*onlyOnceInterQueryCache) Clone(val iCache.InterQueryCacheValue) (iCache.InterQueryCacheValue, error) { return val, nil } diff --git a/v1/topdown/query_test.go b/v1/topdown/query_test.go index 15608cd570..69716b0181 100644 --- a/v1/topdown/query_test.go +++ b/v1/topdown/query_test.go @@ -311,7 +311,7 @@ type testLegacyTracer struct { events []*Event } -func (n *testLegacyTracer) Enabled() bool { +func (*testLegacyTracer) Enabled() bool { return true } diff --git a/v1/topdown/trace.go b/v1/topdown/trace.go index 85143bf711..070e254d28 100644 --- a/v1/topdown/trace.go +++ b/v1/topdown/trace.go @@ -199,7 +199,7 @@ func (l *legacyTracer) Enabled() bool { return l.t.Enabled() } -func (l *legacyTracer) Config() TraceConfig { +func (*legacyTracer) Config() TraceConfig { return TraceConfig{ PlugLocalVars: true, // For backwards compatibility old tracers will plug local variables } @@ -241,7 +241,7 @@ func (b *BufferTracer) TraceEvent(evt Event) { } // Config returns the Tracers standard configuration -func (b *BufferTracer) Config() TraceConfig { +func (*BufferTracer) Config() TraceConfig { return TraceConfig{PlugLocalVars: true} } diff --git a/v1/types/types.go b/v1/types/types.go index 1bf4d6aed0..c661e96666 100644 --- a/v1/types/types.go +++ b/v1/types/types.go @@ -109,7 +109,7 @@ func unwrap(t Type) Type { } } -func (t Null) String() string { +func (Null) String() string { return typeNull } diff --git a/v1/util/graph_test.go b/v1/util/graph_test.go index 8504e86cef..9c05b3e31d 100644 --- a/v1/util/graph_test.go +++ b/v1/util/graph_test.go @@ -34,7 +34,7 @@ func (t *testTraversal) Edges(x T) []T { return r } -func (t *testTraversal) Equals(a, b T) bool { +func (*testTraversal) Equals(a, b T) bool { return a.(int) == b.(int) } diff --git a/v1/util/test/zeroreader.go b/v1/util/test/zeroreader.go index ee2a4e4540..df3664ca60 100644 --- a/v1/util/test/zeroreader.go +++ b/v1/util/test/zeroreader.go @@ -7,7 +7,7 @@ package test // ZeroReader is an io.Reader implementation that returns an infinite stream of zeros type ZeroReader struct{} -func (z ZeroReader) Read(p []byte) (n int, err error) { +func (ZeroReader) Read(p []byte) (n int, err error) { for i := range p { p[i] = 0 }