Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unname unused params and bump golangci-lint #2335

Merged
merged 2 commits into from
Feb 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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"
run: echo "Please run 'go mod tidy' and commit changes"
2 changes: 1 addition & 1 deletion cmd/cli/app/artifact/artifact.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
},
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/cli/app/auth/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
},
}
Expand Down
4 changes: 2 additions & 2 deletions cmd/cli/app/auth/auth_login.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion cmd/cli/app/auth/auth_logout.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
4 changes: 2 additions & 2 deletions cmd/cli/app/docs/docs.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion cmd/cli/app/profile/apply.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion cmd/cli/app/profile/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/cli/app/profile/profile.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
},
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/cli/app/profile/status/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
},
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/cli/app/project/project.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
},
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/cli/app/project/role/role.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
},
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/cli/app/provider/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
},
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/cli/app/repo/repo.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
},
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/cli/app/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/cli/app/ruletype/ruletype.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
},
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/cli/app/ruletype/ruletype_create.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
})
Expand Down
2 changes: 1 addition & 1 deletion cmd/server/app/migrate.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
},
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/server/app/migrate_down.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion cmd/server/app/migrate_up.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion cmd/server/app/migrate_version.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion cmd/server/app/serve.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
4 changes: 2 additions & 2 deletions internal/controlplane/handlers_authz_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down Expand Up @@ -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{
Expand Down
8 changes: 4 additions & 4 deletions internal/db/profiles_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions internal/engine/actions/remediate/rest/rest_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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")
Expand Down
16 changes: 8 additions & 8 deletions internal/engine/eval/rego/lib.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down
Loading
Loading