diff --git a/.drone.yml b/.drone.yml index 5f118f364..232958767 100644 --- a/.drone.yml +++ b/.drone.yml @@ -139,7 +139,7 @@ steps: event: [ push, tag, pull_request ] - name: api-lint - image: golangci/golangci-lint:v1.55.2 + image: golangci/golangci-lint:v1.56.2 pull: always environment: GOPROXY: 'https://goproxy.kolaente.de' @@ -1401,6 +1401,6 @@ steps: - failure --- kind: signature -hmac: bd616ecf66fe95bd25c5f4bd73fc9ccfc20601a87a4f8dd4574d66393eacd077 +hmac: a5d31a6cb5eb6482e72bea619ee391ff2b8118b9865e3896a607b8a7e874a797 ... diff --git a/.golangci.yml b/.golangci.yml index 69e978211..95f13f7ea 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -99,3 +99,7 @@ issues: - path: pkg/modules/migration/ticktick/ticktick_test.go linters: - testifylint + - path: pkg/migration/* + text: "parameter 'tx' seems to be unused, consider removing or renaming it as" + linters: + - revive diff --git a/magefile.go b/magefile.go index 569257455..35c21cbda 100644 --- a/magefile.go +++ b/magefile.go @@ -415,7 +415,7 @@ func checkGolangCiLintInstalled() { mg.Deps(initVars) if err := exec.Command("golangci-lint").Run(); err != nil && strings.Contains(err.Error(), "executable file not found") { fmt.Println("Please manually install golangci-lint by running") - fmt.Println("curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.55.2") + fmt.Println("curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.56.2") os.Exit(1) } } diff --git a/pkg/cmd/dump.go b/pkg/cmd/dump.go index 6572c17d3..60e9eda2b 100644 --- a/pkg/cmd/dump.go +++ b/pkg/cmd/dump.go @@ -32,10 +32,10 @@ func init() { var dumpCmd = &cobra.Command{ Use: "dump", Short: "Dump all vikunja data into a zip file. Includes config, files and db.", - PreRun: func(cmd *cobra.Command, args []string) { + PreRun: func(_ *cobra.Command, _ []string) { initialize.FullInitWithoutAsync() }, - Run: func(cmd *cobra.Command, args []string) { + Run: func(_ *cobra.Command, _ []string) { filename := "vikunja-dump_" + time.Now().Format("2006-01-02_15-03-05") + ".zip" if err := dump.Dump(filename); err != nil { log.Critical(err.Error()) diff --git a/pkg/cmd/index.go b/pkg/cmd/index.go index 1007acefb..13fc8462a 100644 --- a/pkg/cmd/index.go +++ b/pkg/cmd/index.go @@ -32,10 +32,10 @@ func init() { var indexCmd = &cobra.Command{ Use: "index", Short: "Reindex all of Vikunja's data into Typesense. This will remove any existing index.", - PreRun: func(cmd *cobra.Command, args []string) { + PreRun: func(_ *cobra.Command, _ []string) { initialize.FullInitWithoutAsync() }, - Run: func(cmd *cobra.Command, args []string) { + Run: func(_ *cobra.Command, _ []string) { if config.TypesenseURL.GetString() == "" { log.Error("Typesense not configured") return @@ -61,10 +61,10 @@ var indexCmd = &cobra.Command{ var partialReindexCmd = &cobra.Command{ Use: "partial-index", Short: "Reindex any tasks which were not indexed yet into Typesense. This will not remove any existing index.", - PreRun: func(cmd *cobra.Command, args []string) { + PreRun: func(_ *cobra.Command, _ []string) { initialize.FullInitWithoutAsync() }, - Run: func(cmd *cobra.Command, args []string) { + Run: func(_ *cobra.Command, _ []string) { if config.TypesenseURL.GetString() == "" { log.Error("Typesense not configured") return diff --git a/pkg/cmd/migrate.go b/pkg/cmd/migrate.go index 8c5bfb29d..a2bb4ed6c 100644 --- a/pkg/cmd/migrate.go +++ b/pkg/cmd/migrate.go @@ -36,10 +36,10 @@ func init() { var migrateCmd = &cobra.Command{ Use: "migrate", Short: "Run all database migrations which didn't already run.", - PersistentPreRun: func(cmd *cobra.Command, args []string) { + PersistentPreRun: func(_ *cobra.Command, _ []string) { initialize.LightInit() }, - Run: func(cmd *cobra.Command, args []string) { + Run: func(_ *cobra.Command, _ []string) { migration.Migrate(nil) }, } @@ -47,7 +47,7 @@ var migrateCmd = &cobra.Command{ var migrateListCmd = &cobra.Command{ Use: "list", Short: "Show a list with all database migrations.", - Run: func(cmd *cobra.Command, args []string) { + Run: func(_ *cobra.Command, _ []string) { migration.ListMigrations() }, } @@ -57,7 +57,7 @@ var rollbackUntilFlag string var migrationRollbackCmd = &cobra.Command{ Use: "rollback", Short: "Roll migrations back until a certain point.", - Run: func(cmd *cobra.Command, args []string) { + Run: func(_ *cobra.Command, _ []string) { migration.Rollback(rollbackUntilFlag) }, } diff --git a/pkg/cmd/restore.go b/pkg/cmd/restore.go index 2b8d3ee93..9daed9c8e 100644 --- a/pkg/cmd/restore.go +++ b/pkg/cmd/restore.go @@ -31,10 +31,10 @@ var restoreCmd = &cobra.Command{ Use: "restore [filename]", Short: "Restores all vikunja data from a vikunja dump.", Args: cobra.ExactArgs(1), - PreRun: func(cmd *cobra.Command, args []string) { + PreRun: func(_ *cobra.Command, _ []string) { initialize.FullInitWithoutAsync() }, - Run: func(cmd *cobra.Command, args []string) { + Run: func(_ *cobra.Command, args []string) { if err := dump.Restore(args[0]); err != nil { log.Critical(err.Error()) } diff --git a/pkg/cmd/testmail.go b/pkg/cmd/testmail.go index 1b4bc4e30..e8202a741 100644 --- a/pkg/cmd/testmail.go +++ b/pkg/cmd/testmail.go @@ -33,13 +33,13 @@ var testmailCmd = &cobra.Command{ Use: "testmail [email]", Short: "Send a test mail using the configured smtp connection", Args: cobra.ExactArgs(1), - PreRun: func(cmd *cobra.Command, args []string) { + PreRun: func(_ *cobra.Command, _ []string) { initialize.LightInit() // Start the mail daemon mail.StartMailDaemon() }, - Run: func(cmd *cobra.Command, args []string) { + Run: func(_ *cobra.Command, args []string) { log.Info("Sending testmail...") message := notifications.NewMail(). From("Vikunja <"+config.MailerFromEmail.GetString()+">"). diff --git a/pkg/cmd/user.go b/pkg/cmd/user.go index 4d08404a7..aaaa78027 100644 --- a/pkg/cmd/user.go +++ b/pkg/cmd/user.go @@ -128,10 +128,10 @@ var userCmd = &cobra.Command{ var userListCmd = &cobra.Command{ Use: "list", Short: "Shows a list of all users.", - PreRun: func(cmd *cobra.Command, args []string) { + PreRun: func(_ *cobra.Command, _ []string) { initialize.FullInit() }, - Run: func(cmd *cobra.Command, args []string) { + Run: func(_ *cobra.Command, _ []string) { s := db.NewSession() defer s.Close() @@ -173,10 +173,10 @@ var userListCmd = &cobra.Command{ var userCreateCmd = &cobra.Command{ Use: "create", Short: "Create a new user.", - PreRun: func(cmd *cobra.Command, args []string) { + PreRun: func(_ *cobra.Command, _ []string) { initialize.FullInit() }, - Run: func(cmd *cobra.Command, args []string) { + Run: func(_ *cobra.Command, _ []string) { s := db.NewSession() defer s.Close() @@ -214,10 +214,10 @@ var userUpdateCmd = &cobra.Command{ Use: "update [user id]", Short: "Update an existing user.", Args: cobra.ExactArgs(1), - PreRun: func(cmd *cobra.Command, args []string) { + PreRun: func(_ *cobra.Command, _ []string) { initialize.FullInit() }, - Run: func(cmd *cobra.Command, args []string) { + Run: func(_ *cobra.Command, args []string) { s := db.NewSession() defer s.Close() @@ -250,11 +250,11 @@ var userUpdateCmd = &cobra.Command{ var userResetPasswordCmd = &cobra.Command{ Use: "reset-password [user id]", Short: "Reset a users password, either through mailing them a reset link or directly.", - PreRun: func(cmd *cobra.Command, args []string) { + PreRun: func(_ *cobra.Command, _ []string) { initialize.FullInit() }, Args: cobra.ExactArgs(1), - Run: func(cmd *cobra.Command, args []string) { + Run: func(_ *cobra.Command, args []string) { s := db.NewSession() defer s.Close() @@ -286,11 +286,11 @@ var userResetPasswordCmd = &cobra.Command{ var userChangeStatusCmd = &cobra.Command{ Use: "change-status [user id]", Short: "Enable or disable a user. Will toggle the current status if no flag (--enable or --disable) is provided.", - PreRun: func(cmd *cobra.Command, args []string) { + PreRun: func(_ *cobra.Command, _ []string) { initialize.FullInit() }, Args: cobra.ExactArgs(1), - Run: func(cmd *cobra.Command, args []string) { + Run: func(_ *cobra.Command, args []string) { s := db.NewSession() defer s.Close() @@ -327,10 +327,10 @@ var userDeleteCmd = &cobra.Command{ Short: "Delete an existing user.", Long: "Kick off the user deletion process. If call without the --now flag, this command will only trigger an email to the user in order for them to confirm and start the deletion process. With the flag the user is deleted immediately. USE WITH CAUTION.", Args: cobra.ExactArgs(1), - PreRun: func(cmd *cobra.Command, args []string) { + PreRun: func(_ *cobra.Command, _ []string) { initialize.FullInit() }, - Run: func(cmd *cobra.Command, args []string) { + Run: func(_ *cobra.Command, args []string) { if userFlagDeleteNow && !userFlagDeleteConfirm { fmt.Println("You requested to delete the user immediately. Are you sure?") fmt.Println(`To confirm, please type "yes, I confirm" in all uppercase:`) diff --git a/pkg/cmd/version.go b/pkg/cmd/version.go index 0dfc39f34..32d062759 100644 --- a/pkg/cmd/version.go +++ b/pkg/cmd/version.go @@ -31,7 +31,7 @@ func init() { var versionCmd = &cobra.Command{ Use: "version", Short: "Print the version number of Vikunja", - Run: func(cmd *cobra.Command, args []string) { + Run: func(_ *cobra.Command, _ []string) { fmt.Printf("Vikunja api version %s\n", version.Version) fmt.Printf("Built with %s\n", runtime.Version()) }, diff --git a/pkg/cmd/web.go b/pkg/cmd/web.go index ae614e613..ba3e27708 100644 --- a/pkg/cmd/web.go +++ b/pkg/cmd/web.go @@ -67,10 +67,10 @@ func setupUnixSocket(e *echo.Echo) error { var webCmd = &cobra.Command{ Use: "web", Short: "Starts the rest api web server", - PreRun: func(cmd *cobra.Command, args []string) { + PreRun: func(_ *cobra.Command, _ []string) { initialize.FullInit() }, - Run: func(cmd *cobra.Command, args []string) { + Run: func(_ *cobra.Command, _ []string) { // Version notification log.Infof("Vikunja version %s", version.Version) diff --git a/pkg/integrations/integrations.go b/pkg/integrations/integrations.go index 9f760b45c..bd319925d 100644 --- a/pkg/integrations/integrations.go +++ b/pkg/integrations/integrations.go @@ -120,7 +120,7 @@ func addUserTokenToContext(t *testing.T, user *user.User, c echo.Context) { token, err := auth.NewUserJWTAuthtoken(user, false) require.NoError(t, err) // We send the string token through the parsing function to get a valid jwt.Token - tken, err := jwt.Parse(token, func(t *jwt.Token) (interface{}, error) { + tken, err := jwt.Parse(token, func(_ *jwt.Token) (interface{}, error) { return []byte(config.ServiceJWTSecret.GetString()), nil }) require.NoError(t, err) @@ -132,7 +132,7 @@ func addLinkShareTokenToContext(t *testing.T, share *models.LinkSharing, c echo. token, err := auth.NewLinkShareJWTAuthtoken(share) require.NoError(t, err) // We send the string token through the parsing function to get a valid jwt.Token - tken, err := jwt.Parse(token, func(t *jwt.Token) (interface{}, error) { + tken, err := jwt.Parse(token, func(_ *jwt.Token) (interface{}, error) { return []byte(config.ServiceJWTSecret.GetString()), nil }) require.NoError(t, err) diff --git a/pkg/mail/mail.go b/pkg/mail/mail.go index 1da915cf6..c19c3032e 100644 --- a/pkg/mail/mail.go +++ b/pkg/mail/mail.go @@ -50,8 +50,8 @@ func getClient() (*mail.Client, error) { opts := []mail.Option{ mail.WithPort(config.MailerPort.GetInt()), mail.WithTLSPolicy(tlsPolicy), - //#nosec G402 mail.WithTLSConfig(&tls.Config{ + //#nosec G402 InsecureSkipVerify: config.MailerSkipTLSVerify.GetBool(), ServerName: config.MailerHost.GetString(), }), diff --git a/pkg/models/project_test.go b/pkg/models/project_test.go index 9575fe675..8d79badd8 100644 --- a/pkg/models/project_test.go +++ b/pkg/models/project_test.go @@ -354,9 +354,6 @@ func TestProject_ReadAll(t *testing.T) { assert.Len(t, projects, 25) _ = s.Close() }) - t.Run("only child projects for one project", func(t *testing.T) { - // TODO - }) t.Run("all projects for user", func(t *testing.T) { db.LoadAndAssertFixtures(t) s := db.NewSession() diff --git a/pkg/modules/auth/openid/openid.go b/pkg/modules/auth/openid/openid.go index c66aaef8b..1da50c06b 100644 --- a/pkg/modules/auth/openid/openid.go +++ b/pkg/modules/auth/openid/openid.go @@ -220,7 +220,7 @@ func HandleCallback(c echo.Context) error { log.Errorf("Could not proceed with group routine %v", err) } teamIDsToLeave := utils.NotIn(oldOidcTeams, oidcTeams) - err = RemoveUserFromTeamsByIds(s, u, teamIDsToLeave) + err = RemoveUserFromTeamsByIDs(s, u, teamIDsToLeave) if err != nil { log.Errorf("Found error while leaving teams %v", err) } @@ -280,7 +280,7 @@ func RemoveEmptySSOTeams(s *xorm.Session, teamIDs []int64) (errs []error) { return errs } -func RemoveUserFromTeamsByIds(s *xorm.Session, u *user.User, teamIDs []int64) (err error) { +func RemoveUserFromTeamsByIDs(s *xorm.Session, u *user.User, teamIDs []int64) (err error) { if len(teamIDs) < 1 { return nil diff --git a/pkg/modules/auth/openid/openid_test.go b/pkg/modules/auth/openid/openid_test.go index 6cafbd222..eb234600d 100644 --- a/pkg/modules/auth/openid/openid_test.go +++ b/pkg/modules/auth/openid/openid_test.go @@ -185,7 +185,7 @@ func TestGetOrCreateUser(t *testing.T) { require.NoError(t, err) teamIDsToLeave := utils.NotIn(oldOidcTeams, oidcTeams) require.NoError(t, err) - err = RemoveUserFromTeamsByIds(s, u, teamIDsToLeave) + err = RemoveUserFromTeamsByIDs(s, u, teamIDsToLeave) require.NoError(t, err) errs = RemoveEmptySSOTeams(s, teamIDsToLeave) for _, err = range errs { @@ -226,7 +226,7 @@ func TestGetOrCreateUser(t *testing.T) { require.NoError(t, err) teamIDsToLeave := utils.NotIn(oldOidcTeams, oidcTeams) require.NoError(t, err) - err = RemoveUserFromTeamsByIds(s, u, teamIDsToLeave) + err = RemoveUserFromTeamsByIDs(s, u, teamIDsToLeave) require.NoError(t, err) errs = RemoveEmptySSOTeams(s, teamIDsToLeave) for _, err := range errs { diff --git a/pkg/routes/api_tokens.go b/pkg/routes/api_tokens.go index 662832763..55596f334 100644 --- a/pkg/routes/api_tokens.go +++ b/pkg/routes/api_tokens.go @@ -48,7 +48,7 @@ func SetupTokenMiddleware() echo.MiddlewareFunc { return false }, - ErrorHandler: func(c echo.Context, err error) error { + ErrorHandler: func(_ echo.Context, err error) error { if err != nil { return echo.NewHTTPError(http.StatusUnauthorized, "missing, malformed, expired or otherwise invalid token provided").SetInternal(err) } diff --git a/pkg/routes/metrics.go b/pkg/routes/metrics.go index 0f383d34d..b7a75bfc1 100644 --- a/pkg/routes/metrics.go +++ b/pkg/routes/metrics.go @@ -83,7 +83,7 @@ func setupMetrics(a *echo.Group) { r := a.Group("/metrics") if config.MetricsUsername.GetString() != "" && config.MetricsPassword.GetString() != "" { - r.Use(middleware.BasicAuth(func(username, password string, c echo.Context) (bool, error) { + r.Use(middleware.BasicAuth(func(username, password string, _ echo.Context) (bool, error) { if subtle.ConstantTimeCompare([]byte(username), []byte(config.MetricsUsername.GetString())) == 1 && subtle.ConstantTimeCompare([]byte(password), []byte(config.MetricsPassword.GetString())) == 1 { return true, nil diff --git a/pkg/routes/routes.go b/pkg/routes/routes.go index ce7c0fa26..42934d2bf 100644 --- a/pkg/routes/routes.go +++ b/pkg/routes/routes.go @@ -203,7 +203,7 @@ func RegisterRoutes(e *echo.Echo) { // API Routes a := e.Group("/api/v1") - e.OnAddRouteHandler = func(host string, route echo.Route, handler echo.HandlerFunc, middleware []echo.MiddlewareFunc) { + e.OnAddRouteHandler = func(_ string, route echo.Route, _ echo.HandlerFunc, _ []echo.MiddlewareFunc) { models.CollectRoutesForAPITokenUsage(route) } registerAPIRoutes(a)