Enable unused-receiver linter (revive) (#7448)

Signed-off-by: Anders Eknert <anders@styra.com>
This commit is contained in:
Anders Eknert
2025-03-14 10:41:25 +00:00
committed by GitHub
parent 7049966700
commit bd5ceb5142
56 changed files with 95 additions and 93 deletions
+4 -2
View File
@@ -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
+1 -1
View File
@@ -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 {
+2 -2
View File
@@ -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"
}
+2 -2
View File
@@ -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
}
+1 -1
View File
@@ -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()
+1 -1
View File
@@ -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())
+1 -1
View File
@@ -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",
}
+1 -1
View File
@@ -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"
+4 -4
View File
@@ -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
}
+1 -1
View File
@@ -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()
}
+3 -3
View File
@@ -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
}
+6 -6
View File
@@ -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
}
+1 -1
View File
@@ -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,
+1 -1
View File
@@ -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()
+2 -2
View File
@@ -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
}
+3 -3
View File
@@ -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{}
}
+1 -1
View File
@@ -34,5 +34,5 @@ func (l *latch) wait() {
l.waitGroup.Wait()
}
func (l *latch) Close() {
func (*latch) Close() {
}
+1 -1
View File
@@ -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,
}
+1 -1
View File
@@ -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
+1 -1
View File
@@ -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()
}
+1 -1
View File
@@ -106,7 +106,7 @@ const (
Unused
)
func (a *Policy) String() string {
func (*Policy) String() string {
return "Policy"
}
+1 -1
View File
@@ -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"
+1 -1
View File
@@ -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
}
+1 -1
View File
@@ -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 {
+1 -1
View File
@@ -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")
+1 -1
View File
@@ -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
}
+2 -2
View File
@@ -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
}
+1 -1
View File
@@ -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
+2 -2
View File
@@ -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
}
+1 -1
View File
@@ -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 == "" {
+1 -1
View File
@@ -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
+2 -2
View File
@@ -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 {
+1 -1
View File
@@ -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) {
+1 -1
View File
@@ -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
+3 -3
View File
@@ -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 {
+1 -1
View File
@@ -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{}
}
+4 -4
View File
@@ -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{}
}
+1 -1
View File
@@ -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")
+2 -2
View File
@@ -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
}
+1 -1
View File
@@ -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)
}
+4 -4
View File
@@ -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, "/")
+1 -1
View File
@@ -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")
}
+3 -3
View File
@@ -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 {
+1 -1
View File
@@ -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)}
+1 -1
View File
@@ -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)
+1 -1
View File
@@ -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() {
+1 -1
View File
@@ -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()
}
@@ -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 {
+1 -1
View File
@@ -3216,7 +3216,7 @@ func (q vcKeyScope) Hash() int {
return hash
}
func (q vcKeyScope) IsGround() bool {
func (vcKeyScope) IsGround() bool {
return false
}
+1 -1
View File
@@ -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
}
+5 -5
View File
@@ -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
}
+1 -1
View File
@@ -311,7 +311,7 @@ type testLegacyTracer struct {
events []*Event
}
func (n *testLegacyTracer) Enabled() bool {
func (*testLegacyTracer) Enabled() bool {
return true
}
+2 -2
View File
@@ -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}
}
+1 -1
View File
@@ -109,7 +109,7 @@ func unwrap(t Type) Type {
}
}
func (t Null) String() string {
func (Null) String() string {
return typeNull
}
+1 -1
View File
@@ -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)
}
+1 -1
View File
@@ -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
}