From 59b2ed17a6b97d16600d7ad5b72d75a04be00589 Mon Sep 17 00:00:00 2001 From: Jannis Mattheis Date: Sun, 29 May 2022 19:44:09 +0200 Subject: [PATCH] Update linter --- .github/workflows/build.yml | 2 +- .golangci.yml | 3 --- app.go | 4 ++-- auth/authentication_test.go | 1 + auth/password/password_test.go | 1 + database/database.go | 14 ++++---------- plugin/compat/wrap_test.go | 1 + plugin/compat/wrap_test_norace.go | 1 + plugin/manager_test.go | 1 + plugin/manager_test_norace.go | 1 + test/filepath_test.go | 4 ++-- 11 files changed, 15 insertions(+), 18 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 0bdb3ee..a000604 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -26,7 +26,7 @@ jobs: - uses: actions/checkout@v2 - uses: golangci/golangci-lint-action@v2 with: - version: v1.31 + version: v1.45 args: --timeout=5m - run: go mod download - run: make download-tools diff --git a/.golangci.yml b/.golangci.yml index a3b6043..0247db4 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -9,18 +9,15 @@ linters: - deadcode - depguard - exportloopref - - gci - godot - gofmt - gofumpt - goimports - - golint - gomodguard - goprintffuncname - gosimple - govet - ineffassign - - interfacer - misspell - nakedret - nolintlint diff --git a/app.go b/app.go index c591f41..2a99338 100644 --- a/app.go +++ b/app.go @@ -34,11 +34,11 @@ func main() { conf := config.Get() if conf.PluginsDir != "" { - if err := os.MkdirAll(conf.PluginsDir, 0755); err != nil { + if err := os.MkdirAll(conf.PluginsDir, 0o755); err != nil { panic(err) } } - if err := os.MkdirAll(conf.UploadedImagesDir, 0755); err != nil { + if err := os.MkdirAll(conf.UploadedImagesDir, 0o755); err != nil { panic(err) } diff --git a/auth/authentication_test.go b/auth/authentication_test.go index b83900f..84a260b 100644 --- a/auth/authentication_test.go +++ b/auth/authentication_test.go @@ -1,3 +1,4 @@ +//go:build !race // +build !race package auth diff --git a/auth/password/password_test.go b/auth/password/password_test.go index 28b40ca..a9e343a 100644 --- a/auth/password/password_test.go +++ b/auth/password/password_test.go @@ -1,3 +1,4 @@ +//go:build !race // +build !race package password diff --git a/database/database.go b/database/database.go index 9cbc4b6..7920c8c 100644 --- a/database/database.go +++ b/database/database.go @@ -8,15 +8,9 @@ import ( "github.com/gotify/server/v2/auth/password" "github.com/gotify/server/v2/model" "github.com/jinzhu/gorm" - - // enable the mysql dialect. - _ "github.com/jinzhu/gorm/dialects/mysql" - - // enable the postgres dialect. - _ "github.com/jinzhu/gorm/dialects/postgres" - - // enable the sqlite3 dialect. - _ "github.com/jinzhu/gorm/dialects/sqlite" + _ "github.com/jinzhu/gorm/dialects/mysql" // enable the mysql dialect. + _ "github.com/jinzhu/gorm/dialects/postgres" // enable the postgres dialect. + _ "github.com/jinzhu/gorm/dialects/sqlite" // enable the sqlite3 dialect. ) var mkdirAll = os.MkdirAll @@ -95,7 +89,7 @@ func prepareBlobColumn(dialect string, db *gorm.DB) error { func createDirectoryIfSqlite(dialect, connection string) { if dialect == "sqlite3" { if _, err := os.Stat(filepath.Dir(connection)); os.IsNotExist(err) { - if err := mkdirAll(filepath.Dir(connection), 0777); err != nil { + if err := mkdirAll(filepath.Dir(connection), 0o777); err != nil { panic(err) } } diff --git a/plugin/compat/wrap_test.go b/plugin/compat/wrap_test.go index 22cc0eb..b3a4433 100644 --- a/plugin/compat/wrap_test.go +++ b/plugin/compat/wrap_test.go @@ -1,3 +1,4 @@ +//go:build linux || darwin // +build linux darwin package compat diff --git a/plugin/compat/wrap_test_norace.go b/plugin/compat/wrap_test_norace.go index 237663c..c3ee4a5 100644 --- a/plugin/compat/wrap_test_norace.go +++ b/plugin/compat/wrap_test_norace.go @@ -1,3 +1,4 @@ +//go:build !race // +build !race package compat diff --git a/plugin/manager_test.go b/plugin/manager_test.go index d53a2fa..8aee16b 100644 --- a/plugin/manager_test.go +++ b/plugin/manager_test.go @@ -1,3 +1,4 @@ +//go:build (linux || darwin) && !race // +build linux darwin // +build !race diff --git a/plugin/manager_test_norace.go b/plugin/manager_test_norace.go index 805fe39..5af219b 100644 --- a/plugin/manager_test_norace.go +++ b/plugin/manager_test_norace.go @@ -1,3 +1,4 @@ +//go:build !race // +build !race package plugin diff --git a/test/filepath_test.go b/test/filepath_test.go index 195f4ce..d6efbb9 100644 --- a/test/filepath_test.go +++ b/test/filepath_test.go @@ -31,13 +31,13 @@ func TestWithWd(t *testing.T) { WithWd("non_exist", func(string) {}) }) - assert.Nil(t, os.Mkdir(tmpDir.Path(), 0644)) + assert.Nil(t, os.Mkdir(tmpDir.Path(), 0o644)) assert.Panics(t, func() { WithWd(tmpDir.Path(), func(string) {}) }) assert.Nil(t, os.Remove(tmpDir.Path())) - assert.Nil(t, os.Mkdir(tmpDir.Path(), 0755)) + assert.Nil(t, os.Mkdir(tmpDir.Path(), 0o755)) assert.Panics(t, func() { WithWd(tmpDir.Path(), func(string) { assert.Nil(t, os.RemoveAll(tmpDir.Path()))