From 04f9e4ef50f0725968335ca3eeab86bdf0037a16 Mon Sep 17 00:00:00 2001 From: "Adolfo Garcia Veytia (puerco)" Date: Sun, 11 Feb 2024 18:31:54 +0000 Subject: [PATCH 1/2] Unname unused function parameters This commit unnames (_) all the unused parameters un functions to satisfy the new version of reviveThis commit unnames (_) all the unused parameters un functions to satisfy the new version of revive.. Signed-off-by: Adolfo Garcia Veytia (puerco) --- .github/workflows/lint.yml | 2 +- cmd/cli/app/artifact/artifact.go | 2 +- cmd/cli/app/auth/auth.go | 2 +- cmd/cli/app/auth/auth_login.go | 4 +-- cmd/cli/app/auth/auth_logout.go | 2 +- cmd/cli/app/docs/docs.go | 4 +-- cmd/cli/app/profile/apply.go | 2 +- cmd/cli/app/profile/create.go | 2 +- cmd/cli/app/profile/profile.go | 2 +- cmd/cli/app/profile/status/status.go | 2 +- cmd/cli/app/project/project.go | 2 +- cmd/cli/app/project/role/role.go | 2 +- cmd/cli/app/provider/provider.go | 2 +- cmd/cli/app/repo/repo.go | 2 +- cmd/cli/app/root.go | 2 +- cmd/cli/app/ruletype/ruletype.go | 2 +- cmd/cli/app/ruletype/ruletype_create.go | 2 +- cmd/server/app/migrate.go | 2 +- cmd/server/app/migrate_down.go | 2 +- cmd/server/app/migrate_up.go | 2 +- cmd/server/app/migrate_version.go | 2 +- cmd/server/app/serve.go | 2 +- internal/controlplane/handlers_authz_test.go | 4 +-- internal/db/profiles_test.go | 8 +++--- .../gh_branch_protect_test.go | 2 +- .../actions/remediate/rest/rest_test.go | 4 +-- internal/engine/eval/rego/lib.go | 16 ++++++------ internal/engine/eval/vulncheck/pkgdb_test.go | 26 +++++++++---------- internal/engine/eval/vulncheck/review_test.go | 6 ++--- internal/engine/eval/vulncheck/vulndb_test.go | 6 ++--- .../engine/ingester/artifact/artifact_test.go | 16 ++++++------ internal/engine/rule_types_test.go | 2 +- internal/events/eventer_test.go | 4 +-- internal/util/cli/cli.go | 2 +- internal/util/statuses.go | 2 +- internal/util/statuses_test.go | 6 ++--- 36 files changed, 76 insertions(+), 76 deletions(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 9cee47aa57..84d4e39914 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -35,4 +35,4 @@ jobs: run: git diff --exit-code - name: Output message if: ${{ failure() }} - run: echo "Please run 'go mod tidy' and commit changes" \ No newline at end of file + run: echo "Please run 'go mod tidy' and commit changes" diff --git a/cmd/cli/app/artifact/artifact.go b/cmd/cli/app/artifact/artifact.go index 17a2244720..b59ad4c9c7 100644 --- a/cmd/cli/app/artifact/artifact.go +++ b/cmd/cli/app/artifact/artifact.go @@ -28,7 +28,7 @@ var ArtifactCmd = &cobra.Command{ Use: "artifact", Short: "Manage artifacts within a minder control plane", Long: `The minder artifact commands allow the management of artifacts within a minder control plane`, - RunE: func(cmd *cobra.Command, args []string) error { + RunE: func(cmd *cobra.Command, _ []string) error { return cmd.Usage() }, } diff --git a/cmd/cli/app/auth/auth.go b/cmd/cli/app/auth/auth.go index a830477ef6..a0dabd842e 100644 --- a/cmd/cli/app/auth/auth.go +++ b/cmd/cli/app/auth/auth.go @@ -29,7 +29,7 @@ var AuthCmd = &cobra.Command{ Long: `The minder auth command project lets you create accounts and grant or revoke authorization to existing accounts within a minder control plane.`, - RunE: func(cmd *cobra.Command, args []string) error { + RunE: func(cmd *cobra.Command, _ []string) error { return cmd.Usage() }, } diff --git a/cmd/cli/app/auth/auth_login.go b/cmd/cli/app/auth/auth_login.go index bef7019e7e..3149a3e116 100644 --- a/cmd/cli/app/auth/auth_login.go +++ b/cmd/cli/app/auth/auth_login.go @@ -116,8 +116,8 @@ func loginCommand(cmd *cobra.Command, _ []string) error { tokenChan := make(chan *oidc.Tokens[*oidc.IDTokenClaims]) - callback := func(w http.ResponseWriter, r *http.Request, tokens *oidc.Tokens[*oidc.IDTokenClaims], state string, - rpValue rp.RelyingParty) { + callback := func(w http.ResponseWriter, _ *http.Request, + tokens *oidc.Tokens[*oidc.IDTokenClaims], _ string, _ rp.RelyingParty) { tokenChan <- tokens // send a success message to the browser diff --git a/cmd/cli/app/auth/auth_logout.go b/cmd/cli/app/auth/auth_logout.go index 42fc5a9389..8b61d75d62 100644 --- a/cmd/cli/app/auth/auth_logout.go +++ b/cmd/cli/app/auth/auth_logout.go @@ -31,7 +31,7 @@ var logoutCmd = &cobra.Command{ Use: "logout", Short: "Logout from minder control plane.", Long: `Logout from minder control plane. Credentials will be removed from $XDG_CONFIG_HOME/minder/credentials.json`, - RunE: func(cmd *cobra.Command, args []string) error { + RunE: func(cmd *cobra.Command, _ []string) error { if err := util.RemoveCredentials(); err != nil { return cli.MessageAndError("Error removing credentials", err) } diff --git a/cmd/cli/app/docs/docs.go b/cmd/cli/app/docs/docs.go index bc88087f75..b4592ca44e 100644 --- a/cmd/cli/app/docs/docs.go +++ b/cmd/cli/app/docs/docs.go @@ -35,13 +35,13 @@ var DocsCmd = &cobra.Command{ Use: "docs", Short: "Generates documentation for the client", Long: `Generates documentation for the client.`, - PreRunE: func(cmd *cobra.Command, args []string) error { + PreRunE: func(cmd *cobra.Command, _ []string) error { if err := viper.BindPFlags(cmd.Flags()); err != nil { return cli.MessageAndError("Error binding flags", err) } return nil }, - RunE: func(cmd *cobra.Command, args []string) error { + RunE: func(_ *cobra.Command, _ []string) error { // We auto-generate the docs daily, so don't include the date at the bottom. app.RootCmd.DisableAutoGenTag = true // We need to add header material, since GenMarkdownTree always diff --git a/cmd/cli/app/profile/apply.go b/cmd/cli/app/profile/apply.go index 8ab768c2b9..86d8b17921 100644 --- a/cmd/cli/app/profile/apply.go +++ b/cmd/cli/app/profile/apply.go @@ -59,7 +59,7 @@ func applyCommand(_ context.Context, cmd *cobra.Command, conn *grpc.ClientConn) table := NewProfileTable() alreadyExists := false - applyFunc := func(ctx context.Context, f string, p *minderv1.Profile) (*minderv1.Profile, error) { + applyFunc := func(ctx context.Context, _ string, p *minderv1.Profile) (*minderv1.Profile, error) { // create a profile resp, err := client.CreateProfile(ctx, &minderv1.CreateProfileRequest{ Profile: p, diff --git a/cmd/cli/app/profile/create.go b/cmd/cli/app/profile/create.go index 4bfa788d7d..fa7cfa6375 100644 --- a/cmd/cli/app/profile/create.go +++ b/cmd/cli/app/profile/create.go @@ -60,7 +60,7 @@ func createCommand(_ context.Context, cmd *cobra.Command, conn *grpc.ClientConn) table := NewProfileTable() - createFunc := func(ctx context.Context, f string, p *minderv1.Profile) (*minderv1.Profile, error) { + createFunc := func(ctx context.Context, _ string, p *minderv1.Profile) (*minderv1.Profile, error) { if enableAlerts { p.Alert = &onOverride } diff --git a/cmd/cli/app/profile/profile.go b/cmd/cli/app/profile/profile.go index 8314a92db2..4d6d0d9b57 100644 --- a/cmd/cli/app/profile/profile.go +++ b/cmd/cli/app/profile/profile.go @@ -28,7 +28,7 @@ var ProfileCmd = &cobra.Command{ Use: "profile", Short: "Manage profiles", Long: `The profile subcommands allows the management of profiles within Minder.`, - RunE: func(cmd *cobra.Command, args []string) error { + RunE: func(cmd *cobra.Command, _ []string) error { return cmd.Usage() }, } diff --git a/cmd/cli/app/profile/status/status.go b/cmd/cli/app/profile/status/status.go index 37961c2f22..fe4dcade78 100644 --- a/cmd/cli/app/profile/status/status.go +++ b/cmd/cli/app/profile/status/status.go @@ -32,7 +32,7 @@ var profileStatusCmd = &cobra.Command{ Use: "status", Short: "Manage profile status", Long: `The profile status subcommand allows management of profile status within Minder.`, - RunE: func(cmd *cobra.Command, args []string) error { + RunE: func(cmd *cobra.Command, _ []string) error { return cmd.Usage() }, } diff --git a/cmd/cli/app/project/project.go b/cmd/cli/app/project/project.go index b422f6026c..310be921e5 100644 --- a/cmd/cli/app/project/project.go +++ b/cmd/cli/app/project/project.go @@ -27,7 +27,7 @@ var ProjectCmd = &cobra.Command{ Use: "project", Short: "Manage project within a minder control plane", Long: `The minder project commands manage projects within a minder control plane.`, - RunE: func(cmd *cobra.Command, args []string) error { + RunE: func(cmd *cobra.Command, _ []string) error { return cmd.Usage() }, } diff --git a/cmd/cli/app/project/role/role.go b/cmd/cli/app/project/role/role.go index 75bfe118d5..d07002820a 100644 --- a/cmd/cli/app/project/role/role.go +++ b/cmd/cli/app/project/role/role.go @@ -27,7 +27,7 @@ var RoleCmd = &cobra.Command{ Use: "role", Short: "Manage roles within a minder control plane", Long: `The minder role commands manage permissions within a minder control plane.`, - RunE: func(cmd *cobra.Command, args []string) error { + RunE: func(cmd *cobra.Command, _ []string) error { return cmd.Usage() }, } diff --git a/cmd/cli/app/provider/provider.go b/cmd/cli/app/provider/provider.go index a5061efb54..27bf4df52c 100644 --- a/cmd/cli/app/provider/provider.go +++ b/cmd/cli/app/provider/provider.go @@ -28,7 +28,7 @@ var ProviderCmd = &cobra.Command{ Use: "provider", Short: "Manage providers within a minder control plane", Long: `The minder provider commands manage providers within a minder control plane.`, - RunE: func(cmd *cobra.Command, args []string) error { + RunE: func(cmd *cobra.Command, _ []string) error { return cmd.Usage() }, } diff --git a/cmd/cli/app/repo/repo.go b/cmd/cli/app/repo/repo.go index d2eefac3e2..6080ca922b 100644 --- a/cmd/cli/app/repo/repo.go +++ b/cmd/cli/app/repo/repo.go @@ -28,7 +28,7 @@ var RepoCmd = &cobra.Command{ Use: "repo", Short: "Manage repositories", Long: `The repo commands allow the management of repositories within Minder.`, - RunE: func(cmd *cobra.Command, args []string) error { + RunE: func(cmd *cobra.Command, _ []string) error { return cmd.Usage() }, } diff --git a/cmd/cli/app/root.go b/cmd/cli/app/root.go index 55cc1c0553..5fb6a31591 100644 --- a/cmd/cli/app/root.go +++ b/cmd/cli/app/root.go @@ -40,7 +40,7 @@ var ( Long: `For more information about minder, please visit: https://docs.stacklok.com/minder`, SilenceErrors: true, // don't print errors twice, we handle them in cli.ExitNicelyOnError - PersistentPreRunE: func(cmd *cobra.Command, args []string) error { + PersistentPreRunE: func(cmd *cobra.Command, _ []string) error { if constants.TargetEnv == "staging" { fmt.Fprintf(cmd.ErrOrStderr(), "WARNING: This build uses a test environment and may not be stable \n") } diff --git a/cmd/cli/app/ruletype/ruletype.go b/cmd/cli/app/ruletype/ruletype.go index c2fad09847..e6e1be3e2b 100644 --- a/cmd/cli/app/ruletype/ruletype.go +++ b/cmd/cli/app/ruletype/ruletype.go @@ -28,7 +28,7 @@ var ruleTypeCmd = &cobra.Command{ Use: "ruletype", Short: "Manage rule types", Long: `The ruletype subcommands allows the management of rule types within Minder.`, - RunE: func(cmd *cobra.Command, args []string) error { + RunE: func(cmd *cobra.Command, _ []string) error { return cmd.Usage() }, } diff --git a/cmd/cli/app/ruletype/ruletype_create.go b/cmd/cli/app/ruletype/ruletype_create.go index e0db419070..1aa8253e39 100644 --- a/cmd/cli/app/ruletype/ruletype_create.go +++ b/cmd/cli/app/ruletype/ruletype_create.go @@ -70,7 +70,7 @@ func createCommand(_ context.Context, cmd *cobra.Command, conn *grpc.ClientConn) table := initializeTableForList() - createFunc := func(ctx context.Context, fileName string, rt *minderv1.RuleType) (*minderv1.RuleType, error) { + createFunc := func(ctx context.Context, _ string, rt *minderv1.RuleType) (*minderv1.RuleType, error) { resprt, err := client.CreateRuleType(ctx, &minderv1.CreateRuleTypeRequest{ RuleType: rt, }) diff --git a/cmd/server/app/migrate.go b/cmd/server/app/migrate.go index 53aebcf686..e464dc295e 100644 --- a/cmd/server/app/migrate.go +++ b/cmd/server/app/migrate.go @@ -27,7 +27,7 @@ var migrateCmd = &cobra.Command{ Use: "migrate", Short: "Database migration tool", Long: `Use tool with a combination of up to down to migrate the database.`, - RunE: func(cmd *cobra.Command, args []string) error { + RunE: func(cmd *cobra.Command, _ []string) error { return cmd.Usage() }, } diff --git a/cmd/server/app/migrate_down.go b/cmd/server/app/migrate_down.go index 3cafac9931..56b0a9c280 100644 --- a/cmd/server/app/migrate_down.go +++ b/cmd/server/app/migrate_down.go @@ -34,7 +34,7 @@ var downCmd = &cobra.Command{ Use: "down", Short: "migrate a down a database version", Long: `Command to downgrade database`, - RunE: func(cmd *cobra.Command, args []string) error { + RunE: func(cmd *cobra.Command, _ []string) error { cfg, err := serverconfig.ReadConfigFromViper(viper.GetViper()) if err != nil { return fmt.Errorf("unable to read config: %w", err) diff --git a/cmd/server/app/migrate_up.go b/cmd/server/app/migrate_up.go index bd0a309961..3d95356ffa 100644 --- a/cmd/server/app/migrate_up.go +++ b/cmd/server/app/migrate_up.go @@ -39,7 +39,7 @@ var upCmd = &cobra.Command{ Use: "up", Short: "migrate the database to the latest version", Long: `Command to upgrade database`, - RunE: func(cmd *cobra.Command, args []string) error { + RunE: func(cmd *cobra.Command, _ []string) error { cfg, err := serverconfig.ReadConfigFromViper(viper.GetViper()) if err != nil { return fmt.Errorf("unable to read config: %w", err) diff --git a/cmd/server/app/migrate_version.go b/cmd/server/app/migrate_version.go index ce248eb4f4..578651326e 100644 --- a/cmd/server/app/migrate_version.go +++ b/cmd/server/app/migrate_version.go @@ -36,7 +36,7 @@ var versionCmd = &cobra.Command{ Use: "version", Short: "get the db version", Long: `Command to get the database version`, - RunE: func(cmd *cobra.Command, args []string) error { + RunE: func(cmd *cobra.Command, _ []string) error { cfg, err := serverconfig.ReadConfigFromViper(viper.GetViper()) if err != nil { return fmt.Errorf("unable to read config: %w", err) diff --git a/cmd/server/app/serve.go b/cmd/server/app/serve.go index 6e26fbf6d4..f5043cb67a 100644 --- a/cmd/server/app/serve.go +++ b/cmd/server/app/serve.go @@ -45,7 +45,7 @@ var serveCmd = &cobra.Command{ Use: "serve", Short: "Start the minder platform", Long: `Starts the minder platform, which includes the gRPC server and the HTTP gateway.`, - RunE: func(cmd *cobra.Command, args []string) error { + RunE: func(cmd *cobra.Command, _ []string) error { ctx, cancel := signal.NotifyContext(cmd.Context(), os.Interrupt) defer cancel() diff --git a/internal/controlplane/handlers_authz_test.go b/internal/controlplane/handlers_authz_test.go index 3f0f9f38da..a37d8abe07 100644 --- a/internal/controlplane/handlers_authz_test.go +++ b/internal/controlplane/handlers_authz_test.go @@ -154,7 +154,7 @@ func TestEntityContextProjectInterceptor(t *testing.T) { TargetResource: tc.resource, } - unaryHandler := func(ctx context.Context, req interface{}) (any, error) { + unaryHandler := func(ctx context.Context, _ interface{}) (any, error) { return replyType{engine.EntityFromContext(ctx)}, nil } @@ -246,7 +246,7 @@ func TestProjectAuthorizationInterceptor(t *testing.T) { TargetResource: tc.resource, } - unaryHandler := func(ctx context.Context, req interface{}) (any, error) { + unaryHandler := func(ctx context.Context, _ interface{}) (any, error) { return replyType{engine.EntityFromContext(ctx)}, nil } server := Server{ diff --git a/internal/db/profiles_test.go b/internal/db/profiles_test.go index 3c3df86425..3f87452f94 100644 --- a/internal/db/profiles_test.go +++ b/internal/db/profiles_test.go @@ -188,18 +188,18 @@ func TestCreateProfileStatusStoredProcedure(t *testing.T) { }{ { name: "Profile with no rule evaluations, should be pending", - ruleStatusSetupFn: func(profile Profile, randomEntities *testRandomEntities) { + ruleStatusSetupFn: func(_ Profile, _ *testRandomEntities) { // noop }, expectedStatusAfterSetup: EvalStatusTypesPending, - ruleStatusModifyFn: func(profile Profile, randomEntities *testRandomEntities) { + ruleStatusModifyFn: func(_ Profile, _ *testRandomEntities) { // noop }, expectedStatusAfterModify: EvalStatusTypesPending, }, { name: "Profile with only success rule evaluation, should be success", - ruleStatusSetupFn: func(profile Profile, randomEntities *testRandomEntities) { + ruleStatusSetupFn: func(_ Profile, _ *testRandomEntities) { // noop }, expectedStatusAfterSetup: EvalStatusTypesPending, @@ -212,7 +212,7 @@ func TestCreateProfileStatusStoredProcedure(t *testing.T) { }, { name: "Profile with all skipped evaluations should be skipped", - ruleStatusSetupFn: func(profile Profile, randomEntities *testRandomEntities) { + ruleStatusSetupFn: func(_ Profile, _ *testRandomEntities) { // noop }, expectedStatusAfterSetup: EvalStatusTypesPending, diff --git a/internal/engine/actions/remediate/gh_branch_protect/gh_branch_protect_test.go b/internal/engine/actions/remediate/gh_branch_protect/gh_branch_protect_test.go index 1ac24f3baf..a204492e48 100644 --- a/internal/engine/actions/remediate/gh_branch_protect/gh_branch_protect_test.go +++ b/internal/engine/actions/remediate/gh_branch_protect/gh_branch_protect_test.go @@ -166,7 +166,7 @@ func TestBranchProtectionRemediate(t *testing.T) { pbuild: testGithubProviderBuilder(ghApiUrl), actionType: "", }, - mockSetup: func(mockGitHub *mock_ghclient.MockGitHub) { + mockSetup: func(_ *mock_ghclient.MockGitHub) { }, remArgs: &remediateArgs{ remAction: interfaces.ActionOptOn, diff --git a/internal/engine/actions/remediate/rest/rest_test.go b/internal/engine/actions/remediate/rest/rest_test.go index fe13e08148..6e53853e27 100644 --- a/internal/engine/actions/remediate/rest/rest_test.go +++ b/internal/engine/actions/remediate/rest/rest_test.go @@ -360,7 +360,7 @@ func TestRestRemediate(t *testing.T) { "allowed_actions": "selected", }, }, - testHandler: func(writer http.ResponseWriter, request *http.Request) { + testHandler: func(_ http.ResponseWriter, _ *http.Request) { assert.Fail(t, "unexpected request") }, wantErr: false, @@ -384,7 +384,7 @@ func TestRestRemediate(t *testing.T) { "allowed_actions": "selected", }, }, - testHandler: func(writer http.ResponseWriter, request *http.Request) { + testHandler: func(writer http.ResponseWriter, _ *http.Request) { writer.WriteHeader(http.StatusForbidden) _, err := writer.Write([]byte("forbidden")) assert.NoError(t, err, "unexpected error writing response") diff --git a/internal/engine/eval/rego/lib.go b/internal/engine/eval/rego/lib.go index 131c632daa..6bdc57475a 100644 --- a/internal/engine/eval/rego/lib.go +++ b/internal/engine/eval/rego/lib.go @@ -64,7 +64,7 @@ func FileExists(res *engif.Result) func(*rego.Rego) { Name: "file.exists", Decl: types.NewFunction(types.Args(types.S), types.B), }, - func(bctx rego.BuiltinContext, op1 *ast.Term) (*ast.Term, error) { + func(_ rego.BuiltinContext, op1 *ast.Term) (*ast.Term, error) { var path string if err := ast.As(op1.Value, &path); err != nil { return nil, err @@ -99,7 +99,7 @@ func FileRead(res *engif.Result) func(*rego.Rego) { Name: "file.read", Decl: types.NewFunction(types.Args(types.S), types.S), }, - func(bctx rego.BuiltinContext, op1 *ast.Term) (*ast.Term, error) { + func(_ rego.BuiltinContext, op1 *ast.Term) (*ast.Term, error) { var path string if err := ast.As(op1.Value, &path); err != nil { return nil, err @@ -144,7 +144,7 @@ func FileLs(res *engif.Result) func(*rego.Rego) { Name: "file.ls", Decl: types.NewFunction(types.Args(types.S), types.A), }, - func(bctx rego.BuiltinContext, op1 *ast.Term) (*ast.Term, error) { + func(_ rego.BuiltinContext, op1 *ast.Term) (*ast.Term, error) { var path string if err := ast.As(op1.Value, &path); err != nil { return nil, err @@ -214,7 +214,7 @@ func FileLsGlob(res *engif.Result) func(*rego.Rego) { Name: "file.ls_glob", Decl: types.NewFunction(types.Args(types.S), types.A), }, - func(bctx rego.BuiltinContext, op1 *ast.Term) (*ast.Term, error) { + func(_ rego.BuiltinContext, op1 *ast.Term) (*ast.Term, error) { var path string if err := ast.As(op1.Value, &path); err != nil { return nil, err @@ -253,7 +253,7 @@ func FileWalk(res *engif.Result) func(*rego.Rego) { Name: "file.walk", Decl: types.NewFunction(types.Args(types.S), types.A), }, - func(bctx rego.BuiltinContext, op1 *ast.Term) (*ast.Term, error) { + func(_ rego.BuiltinContext, op1 *ast.Term) (*ast.Term, error) { var path string if err := ast.As(op1.Value, &path); err != nil { return nil, err @@ -347,7 +347,7 @@ func ListGithubActions(res *engif.Result) func(*rego.Rego) { Name: "github_workflow.ls_actions", Decl: types.NewFunction(types.Args(types.S), types.NewSet(types.S)), }, - func(bctx rego.BuiltinContext, op1 *ast.Term) (*ast.Term, error) { + func(_ rego.BuiltinContext, op1 *ast.Term) (*ast.Term, error) { var base string if err := ast.As(op1.Value, &base); err != nil { return nil, err @@ -358,7 +358,7 @@ func ListGithubActions(res *engif.Result) func(*rego.Rego) { } var terms []*ast.Term - err := frizgh.TraverseGitHubActionWorkflows(res.Fs, base, func(path string, wflow *yaml.Node) error { + err := frizgh.TraverseGitHubActionWorkflows(res.Fs, base, func(_ string, wflow *yaml.Node) error { actions, err := frizgh.ListActionsInYAML(wflow) if err != nil { return err @@ -389,7 +389,7 @@ func FileHTTPType(res *engif.Result) func(*rego.Rego) { Name: "file.http_type", Decl: types.NewFunction(types.Args(types.S), types.S), }, - func(bctx rego.BuiltinContext, op1 *ast.Term) (*ast.Term, error) { + func(_ rego.BuiltinContext, op1 *ast.Term) (*ast.Term, error) { var path string if err := ast.As(op1.Value, &path); err != nil { return nil, err diff --git a/internal/engine/eval/vulncheck/pkgdb_test.go b/internal/engine/eval/vulncheck/pkgdb_test.go index 9bed0af1cd..e001dc797e 100644 --- a/internal/engine/eval/vulncheck/pkgdb_test.go +++ b/internal/engine/eval/vulncheck/pkgdb_test.go @@ -110,7 +110,7 @@ func TestNpmPkgDb(t *testing.T) { }, { name: "Non200Response", - mockHandler: func(w http.ResponseWriter, r *http.Request) { + mockHandler: func(w http.ResponseWriter, _ *http.Request) { w.WriteHeader(http.StatusNotFound) _, err := w.Write([]byte("Not Found")) if err != nil { @@ -122,7 +122,7 @@ func TestNpmPkgDb(t *testing.T) { }, { name: "InvalidJSON", - mockHandler: func(w http.ResponseWriter, r *http.Request) { + mockHandler: func(w http.ResponseWriter, _ *http.Request) { w.WriteHeader(http.StatusOK) _, err := w.Write([]byte("{ invalid json }")) if err != nil { @@ -336,7 +336,7 @@ func TestPyPiPkgDb(t *testing.T) { }, { name: "Non200Response", - mockPyPiHandler: func(w http.ResponseWriter, r *http.Request) { + mockPyPiHandler: func(w http.ResponseWriter, _ *http.Request) { w.WriteHeader(http.StatusNotFound) _, err := w.Write([]byte("Not Found")) if err != nil { @@ -348,7 +348,7 @@ func TestPyPiPkgDb(t *testing.T) { }, { name: "InvalidJSON", - mockPyPiHandler: func(w http.ResponseWriter, r *http.Request) { + mockPyPiHandler: func(w http.ResponseWriter, _ *http.Request) { w.WriteHeader(http.StatusOK) _, err := w.Write([]byte("{ invalid json }")) if err != nil { @@ -422,7 +422,7 @@ func TestGoPkgDb(t *testing.T) { t.Fatal(err) } }, - mockSumHandler: func(w http.ResponseWriter, r *http.Request) { + mockSumHandler: func(w http.ResponseWriter, _ *http.Request) { w.WriteHeader(http.StatusOK) _, err := w.Write([]byte(`19383665 golang.org/x/text v0.13.0 h1:ablQoSUd0tRdKxZewP80B+BaqeKJuVhuRxj/dkrun3k= @@ -457,7 +457,7 @@ go.sum database tree t.Fatal(err) } }, - mockSumHandler: func(w http.ResponseWriter, r *http.Request) { + mockSumHandler: func(w http.ResponseWriter, _ *http.Request) { w.WriteHeader(http.StatusOK) _, err := w.Write([]byte(`19383665 golang.org/x/text v0.13.1 h1:ablQoSUd0tRdKxZewP80B+BaqeKJuVhuRxj/dkrun3k= @@ -481,7 +481,7 @@ go.sum database tree }, { name: "Non200ResponseProxy", - mockProxyHandler: func(w http.ResponseWriter, r *http.Request) { + mockProxyHandler: func(w http.ResponseWriter, _ *http.Request) { w.WriteHeader(http.StatusNotFound) _, err := w.Write([]byte("Not Found")) if err != nil { @@ -493,7 +493,7 @@ go.sum database tree }, { name: "InvalidJSONProxy", - mockProxyHandler: func(w http.ResponseWriter, r *http.Request) { + mockProxyHandler: func(w http.ResponseWriter, _ *http.Request) { w.WriteHeader(http.StatusOK) _, err := w.Write([]byte("{ invalid json }")) if err != nil { @@ -505,7 +505,7 @@ go.sum database tree }, { name: "MissingVersionProxy", - mockProxyHandler: func(w http.ResponseWriter, r *http.Request) { + mockProxyHandler: func(w http.ResponseWriter, _ *http.Request) { data := goModPackage{ Name: "golang.org/x/text", } @@ -521,7 +521,7 @@ go.sum database tree }, { name: "Non200ResponseSum", - mockProxyHandler: func(w http.ResponseWriter, r *http.Request) { + mockProxyHandler: func(w http.ResponseWriter, _ *http.Request) { data := goModPackage{ Version: "v0.13.0", } @@ -531,7 +531,7 @@ go.sum database tree t.Fatal(err) } }, - mockSumHandler: func(w http.ResponseWriter, r *http.Request) { + mockSumHandler: func(w http.ResponseWriter, _ *http.Request) { w.WriteHeader(http.StatusNotFound) }, depName: "golang.org/x/text", @@ -539,7 +539,7 @@ go.sum database tree }, { name: "TooFewLinesSum", - mockProxyHandler: func(w http.ResponseWriter, r *http.Request) { + mockProxyHandler: func(w http.ResponseWriter, _ *http.Request) { data := goModPackage{ Version: "v0.13.0", } @@ -549,7 +549,7 @@ go.sum database tree t.Fatal(err) } }, - mockSumHandler: func(w http.ResponseWriter, r *http.Request) { + mockSumHandler: func(w http.ResponseWriter, _ *http.Request) { w.WriteHeader(http.StatusOK) _, err := w.Write([]byte(`19383665 golang.org/x/text v0.13.0 h1:ablQoSUd0tRdKxZewP80B+BaqeKJuVhuRxj/dkrun3k=`)) diff --git a/internal/engine/eval/vulncheck/review_test.go b/internal/engine/eval/vulncheck/review_test.go index c55d5a20a3..750aeae5d2 100644 --- a/internal/engine/eval/vulncheck/review_test.go +++ b/internal/engine/eval/vulncheck/review_test.go @@ -105,7 +105,7 @@ func TestReviewPrHandlerVulnerabilitiesDifferentIdentities(t *testing.T) { require.NoError(t, err) require.NotNil(t, handler) - server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) { _, err := w.Write([]byte(`+ "mongodb": { + "version": "5.1.0", + }`)) @@ -198,7 +198,7 @@ func TestReviewPrHandlerVulnerabilitiesWithNoPatchVersion(t *testing.T) { require.NoError(t, err) require.NotNil(t, handler) - server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) { _, err := w.Write([]byte(`+ "mongodb": { + "version": "5.1.0", + }`)) @@ -378,7 +378,7 @@ func TestCommitStatusPrHandlerWithVulnerabilities(t *testing.T) { require.NoError(t, err) require.NotNil(t, handler) - server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) { _, err := w.Write([]byte(`+ "mongodb": { + "version": "5.1.0", + }`)) diff --git a/internal/engine/eval/vulncheck/vulndb_test.go b/internal/engine/eval/vulncheck/vulndb_test.go index 26aa0556d8..430d98a257 100644 --- a/internal/engine/eval/vulncheck/vulndb_test.go +++ b/internal/engine/eval/vulncheck/vulndb_test.go @@ -223,7 +223,7 @@ func TestGoVulnDb(t *testing.T) { }{ { name: "SemverMultipleRanges", - mockVulnHandler: func(w http.ResponseWriter, r *http.Request) { + mockVulnHandler: func(w http.ResponseWriter, _ *http.Request) { w.WriteHeader(http.StatusOK) _, err := w.Write([]byte(multipleRanges)) if err != nil { @@ -247,7 +247,7 @@ func TestGoVulnDb(t *testing.T) { }, { name: "NonSemver", - mockVulnHandler: func(w http.ResponseWriter, r *http.Request) { + mockVulnHandler: func(w http.ResponseWriter, _ *http.Request) { w.WriteHeader(http.StatusOK) _, err := w.Write([]byte(nonSemver)) if err != nil { @@ -271,7 +271,7 @@ func TestGoVulnDb(t *testing.T) { }, { name: "NotFixed", - mockVulnHandler: func(w http.ResponseWriter, r *http.Request) { + mockVulnHandler: func(w http.ResponseWriter, _ *http.Request) { w.WriteHeader(http.StatusOK) _, err := w.Write([]byte(notFixed)) if err != nil { diff --git a/internal/engine/ingester/artifact/artifact_test.go b/internal/engine/ingester/artifact/artifact_test.go index 1636af65b9..9d20c3ca75 100644 --- a/internal/engine/ingester/artifact/artifact_test.go +++ b/internal/engine/ingester/artifact/artifact_test.go @@ -169,7 +169,7 @@ func TestArtifactIngestMatching(t *testing.T) { name: "matching-name-but-not-tags", wantErr: true, wantNonNilRes: false, - mockSetup: func(mockGhClient *mock_ghclient.MockGitHub, mockVerifier *mockverify.MockArtifactVerifier) { + mockSetup: func(mockGhClient *mock_ghclient.MockGitHub, _ *mockverify.MockArtifactVerifier) { mockGhClient.EXPECT().GetOwner().Return("stacklok") mockGhClient.EXPECT(). GetPackageVersions(gomock.Any(), true, "stacklok", "container", "matching-name-but-not-tags"). @@ -208,7 +208,7 @@ func TestArtifactIngestMatching(t *testing.T) { name: "multiple-tags-from-different-versions", wantErr: true, wantNonNilRes: false, - mockSetup: func(mockGhClient *mock_ghclient.MockGitHub, mockVerifier *mockverify.MockArtifactVerifier) { + mockSetup: func(mockGhClient *mock_ghclient.MockGitHub, _ *mockverify.MockArtifactVerifier) { mockGhClient.EXPECT().GetOwner().Return("stacklok") mockGhClient.EXPECT(). GetPackageVersions(gomock.Any(), true, "stacklok", "container", "matching-name-but-not-tags"). @@ -247,7 +247,7 @@ func TestArtifactIngestMatching(t *testing.T) { name: "multiple-tags-from-same-version", wantErr: true, wantNonNilRes: false, - mockSetup: func(mockGhClient *mock_ghclient.MockGitHub, mockVerifier *mockverify.MockArtifactVerifier) { + mockSetup: func(mockGhClient *mock_ghclient.MockGitHub, _ *mockverify.MockArtifactVerifier) { mockGhClient.EXPECT().GetOwner().Return("stacklok") mockGhClient.EXPECT(). GetPackageVersions(gomock.Any(), true, "stacklok", "container", "matching-name-but-not-tags"). @@ -336,7 +336,7 @@ func TestArtifactIngestMatching(t *testing.T) { wantErr: true, wantNonNilRes: false, errType: evalerrors.ErrEvaluationSkipSilently, - mockSetup: func(mockGhClient *mock_ghclient.MockGitHub, mockVerifier *mockverify.MockArtifactVerifier) { + mockSetup: func(_ *mock_ghclient.MockGitHub, _ *mockverify.MockArtifactVerifier) { }, artifact: &pb.Artifact{ Type: "container", @@ -470,7 +470,7 @@ func TestArtifactIngestMatching(t *testing.T) { name: "tag-doesnt-match-regex", wantErr: true, wantNonNilRes: false, - mockSetup: func(mockGhClient *mock_ghclient.MockGitHub, mockVerifier *mockverify.MockArtifactVerifier) { + mockSetup: func(mockGhClient *mock_ghclient.MockGitHub, _ *mockverify.MockArtifactVerifier) { mockGhClient.EXPECT().GetOwner().Return("stacklok") mockGhClient.EXPECT(). GetPackageVersions(gomock.Any(), true, "stacklok", "container", "matching-name-but-not-tags"). @@ -500,7 +500,7 @@ func TestArtifactIngestMatching(t *testing.T) { name: "multiple-tags-doesnt-match-regex", wantErr: true, wantNonNilRes: false, - mockSetup: func(mockGhClient *mock_ghclient.MockGitHub, mockVerifier *mockverify.MockArtifactVerifier) { + mockSetup: func(mockGhClient *mock_ghclient.MockGitHub, _ *mockverify.MockArtifactVerifier) { mockGhClient.EXPECT().GetOwner().Return("stacklok") mockGhClient.EXPECT(). GetPackageVersions(gomock.Any(), true, "stacklok", "container", "matching-name-but-not-tags"). @@ -534,7 +534,7 @@ func TestArtifactIngestMatching(t *testing.T) { name: "test-artifact-with-empty-tags", wantErr: true, wantNonNilRes: false, - mockSetup: func(mockGhClient *mock_ghclient.MockGitHub, mockVerifier *mockverify.MockArtifactVerifier) { + mockSetup: func(_ *mock_ghclient.MockGitHub, _ *mockverify.MockArtifactVerifier) { }, artifact: &pb.Artifact{ Type: "container", @@ -550,7 +550,7 @@ func TestArtifactIngestMatching(t *testing.T) { name: "test-artifact-version-with-no-tags", wantErr: true, wantNonNilRes: false, - mockSetup: func(mockGhClient *mock_ghclient.MockGitHub, mockVerifier *mockverify.MockArtifactVerifier) { + mockSetup: func(mockGhClient *mock_ghclient.MockGitHub, _ *mockverify.MockArtifactVerifier) { mockGhClient.EXPECT().GetOwner().Return("stacklok") mockGhClient.EXPECT(). GetPackageVersions(gomock.Any(), true, "stacklok", "container", "matching-name-but-not-tags"). diff --git a/internal/engine/rule_types_test.go b/internal/engine/rule_types_test.go index 96c4ae7871..d93656e894 100644 --- a/internal/engine/rule_types_test.go +++ b/internal/engine/rule_types_test.go @@ -34,7 +34,7 @@ func TestExampleRulesAreValidatedCorrectly(t *testing.T) { require.NoError(t, err, "failed to parse example profile, make sure to do - make init-examples") // open rules in example directory - err = filepath.Walk("../../examples/rules-and-profiles/rule-types/github", func(path string, info os.FileInfo, err error) error { + err = filepath.Walk("../../examples/rules-and-profiles/rule-types/github", func(path string, info os.FileInfo, _ error) error { // skip directories if info.IsDir() { return nil diff --git a/internal/events/eventer_test.go b/internal/events/eventer_test.go index 3e1a89a5c8..12681ccedc 100644 --- a/internal/events/eventer_test.go +++ b/internal/events/eventer_test.go @@ -257,8 +257,8 @@ func setupConsumer(c *fakeConsumer, out chan eventPair, failureCounter *int) { } } -func makeFailingHandler(counter *int) func(_ string, out chan eventPair) events.Handler { - return func(_ string, out chan eventPair) events.Handler { +func makeFailingHandler(counter *int) func(_ string, _ chan eventPair) events.Handler { + return func(_ string, _ chan eventPair) events.Handler { return countFailuresHandler(counter) } } diff --git a/internal/util/cli/cli.go b/internal/util/cli/cli.go index 103d104332..2b772f2ba0 100644 --- a/internal/util/cli/cli.go +++ b/internal/util/cli/cli.go @@ -107,7 +107,7 @@ func GetAppContextWithTimeoutDuration(ctx context.Context, v *viper.Viper, tout func GRPCClientWrapRunE( runEFunc func(ctx context.Context, cmd *cobra.Command, c *grpc.ClientConn) error, ) func(cmd *cobra.Command, args []string) error { - return func(cmd *cobra.Command, args []string) error { + return func(cmd *cobra.Command, _ []string) error { if err := viper.BindPFlags(cmd.Flags()); err != nil { return fmt.Errorf("error binding flags: %s", err) } diff --git a/internal/util/statuses.go b/internal/util/statuses.go index 0613ca037f..ef63bc0b1b 100644 --- a/internal/util/statuses.go +++ b/internal/util/statuses.go @@ -179,7 +179,7 @@ func (s *NiceStatus) Error() string { // SanitizingInterceptor sanitized error statuses which do not conform to NiceStatus, ensuring // that we don't accidentally leak implementation details over gRPC. func SanitizingInterceptor() grpc.UnaryServerInterceptor { - return func(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (interface{}, error) { + return func(ctx context.Context, req interface{}, _ *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (interface{}, error) { ret, err := handler(ctx, req) if err != nil { // If we returned a NiceStatus, pass it through. diff --git a/internal/util/statuses_test.go b/internal/util/statuses_test.go index be5ce0ee50..ef6fac9869 100644 --- a/internal/util/statuses_test.go +++ b/internal/util/statuses_test.go @@ -52,21 +52,21 @@ func TestSanitizingInterceptor(t *testing.T) { }{ { name: "success", - handler: func(ctx context.Context, req interface{}) (interface{}, error) { + handler: func(_ context.Context, _ interface{}) (interface{}, error) { return "success", nil }, wantErr: false, }, { name: "some error", - handler: func(ctx context.Context, req interface{}) (interface{}, error) { + handler: func(_ context.Context, _ interface{}) (interface{}, error) { return nil, status.Error(codes.Internal, "some error") }, wantErr: true, }, { name: "nice error", - handler: func(ctx context.Context, req interface{}) (interface{}, error) { + handler: func(_ context.Context, _ interface{}) (interface{}, error) { return nil, util.UserVisibleError(codes.Internal, "some error") }, wantErr: true, From c90ec7176842d4fc277cb0c5ee42c7cb4a498078 Mon Sep 17 00:00:00 2001 From: "Adolfo Garcia Veytia (puerco)" Date: Sun, 11 Feb 2024 18:39:18 +0000 Subject: [PATCH 2/2] Bump golangci-lint in workflow to v1.56.1 Signed-off-by: Adolfo Garcia Veytia (puerco) --- .github/workflows/lint.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 84d4e39914..a7f083a4fa 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -18,7 +18,7 @@ jobs: - name: golangci-lint uses: golangci/golangci-lint-action@3cfe3a4abbb849e10058ce4af15d205b6da42804 # v3 with: - version: v1.55.2 + version: v1.56.1 mod-tidy: name: Go mod tidy