From 817bb432c2948b020a87e40ae6404c6fadd332db Mon Sep 17 00:00:00 2001 From: Evan Goode Date: Sat, 29 Mar 2025 19:19:31 -0400 Subject: [PATCH] Lint --- authlib_injector.go | 3 +++ config.go | 5 ++++- db_test.go | 2 +- front.go | 12 ++++++------ front_test.go | 2 +- util.go | 2 -- 6 files changed, 15 insertions(+), 11 deletions(-) diff --git a/authlib_injector.go b/authlib_injector.go index 73a4cda..d6ef30f 100644 --- a/authlib_injector.go +++ b/authlib_injector.go @@ -189,6 +189,9 @@ func (app *App) AuthlibInjectorDeleteTexture(textureType string) func(c echo.Con nil, // capeURL textureType == TextureTypeCape, // deleteCape ) + if err != nil { + return err + } return c.NoContent(http.StatusNoContent) }) diff --git a/config.go b/config.go index 6138ea2..8951f3c 100644 --- a/config.go +++ b/config.go @@ -397,6 +397,9 @@ func CleanConfig(config *Config) error { oidcConfig.Issuer, false, ) + if err != nil { + return err + } } return nil } @@ -418,7 +421,7 @@ RequireInvite = true ` func HandleDeprecations(config Config, metadata *toml.MetaData) [][]string { - deprecatedPaths := make([][]string, 0, 0) + deprecatedPaths := make([][]string, 0) warningTemplate := "Warning: config option %s is deprecated and will be removed in a future version. Use %s instead." diff --git a/db_test.go b/db_test.go index 9e37631..9cbcecb 100644 --- a/db_test.go +++ b/db_test.go @@ -169,7 +169,7 @@ func (ts *TestSuite) testMigrateBackwards(t *testing.T) { query, err := os.ReadFile("sql/1.sql") assert.Nil(t, err) assert.Nil(t, db.Exec(string(query)).Error) - setUserVersion(db, CURRENT_USER_VERSION+1) + assert.Nil(t, setUserVersion(db, CURRENT_USER_VERSION+1)) err = Migrate(ts.Config, mo.None[string](), db, true, CURRENT_USER_VERSION) var backwardsMigrationError BackwardsMigrationError diff --git a/front.go b/front.go index 791941c..17346bf 100644 --- a/front.go +++ b/front.go @@ -101,9 +101,9 @@ func (app *App) setSuccessMessage(c *echo.Context, template string, args ...inte app.setMessageCookie(c, SUCCESS_MESSAGE_COOKIE_NAME, template, args...) } -func (app *App) setWarningMessage(c *echo.Context, template string, args ...interface{}) { - app.setMessageCookie(c, WARNING_MESSAGE_COOKIE_NAME, template, args...) -} +// func (app *App) setWarningMessage(c *echo.Context, template string, args ...interface{}) { +// app.setMessageCookie(c, WARNING_MESSAGE_COOKIE_NAME, template, args...) +// } func (app *App) setErrorMessage(c *echo.Context, template string, args ...interface{}) { app.setMessageCookie(c, ERROR_MESSAGE_COOKIE_NAME, template, args...) @@ -153,11 +153,11 @@ func (app *App) HandleWebError(err error, c *echo.Context) error { var webError *WebError var userError *UserError if errors.As(err, &webError) { - app.setErrorMessage(c, webError.Error()) + app.setErrorMessage(c, "%s", webError.Error()) return (*c).Redirect(http.StatusSeeOther, webError.ReturnURL) } else if errors.As(err, &userError) { returnURL := getReturnURL(app, c) - app.setErrorMessage(c, userError.Error()) + app.setErrorMessage(c, "%s", userError.Error()) return (*c).Redirect(http.StatusSeeOther, returnURL) } @@ -192,7 +192,7 @@ func (app *App) HandleWebError(err error, c *echo.Context) error { }) } else { returnURL := getReturnURL(app, c) - app.setErrorMessage(c, message) + app.setErrorMessage(c, "%s", message) return (*c).Redirect(http.StatusSeeOther, returnURL) } } diff --git a/front_test.go b/front_test.go index 80401c3..2812bd4 100644 --- a/front_test.go +++ b/front_test.go @@ -117,7 +117,7 @@ func (ts *TestSuite) createPlayerShouldSucceed(t *testing.T, rec *httptest.Respo returnURLExp := regexp.MustCompile("^" + regexp.QuoteMeta(ts.App.FrontEndURL+"/web/player/") + "(.+)$") uuidMatch := returnURLExp.FindStringSubmatch(rec.Header().Get("Location")) - assert.True(t, uuidMatch != nil && len(uuidMatch) == 2) + assert.True(t, len(uuidMatch) == 2) uuid_ := uuidMatch[1] _, err := uuid.Parse(uuid_) assert.Nil(t, err) diff --git a/util.go b/util.go index c87a392..a9d5f6c 100644 --- a/util.go +++ b/util.go @@ -1,7 +1,6 @@ package main import ( - "cmp" "crypto" "crypto/rand" "crypto/rsa" @@ -12,7 +11,6 @@ import ( "io" "log" "os" - "slices" "strings" "sync" )