Update linter

This commit is contained in:
Jannis Mattheis 2022-05-29 19:44:09 +02:00
parent 13b878781b
commit 59b2ed17a6
11 changed files with 15 additions and 18 deletions

View File

@ -26,7 +26,7 @@ jobs:
- uses: actions/checkout@v2 - uses: actions/checkout@v2
- uses: golangci/golangci-lint-action@v2 - uses: golangci/golangci-lint-action@v2
with: with:
version: v1.31 version: v1.45
args: --timeout=5m args: --timeout=5m
- run: go mod download - run: go mod download
- run: make download-tools - run: make download-tools

View File

@ -9,18 +9,15 @@ linters:
- deadcode - deadcode
- depguard - depguard
- exportloopref - exportloopref
- gci
- godot - godot
- gofmt - gofmt
- gofumpt - gofumpt
- goimports - goimports
- golint
- gomodguard - gomodguard
- goprintffuncname - goprintffuncname
- gosimple - gosimple
- govet - govet
- ineffassign - ineffassign
- interfacer
- misspell - misspell
- nakedret - nakedret
- nolintlint - nolintlint

4
app.go
View File

@ -34,11 +34,11 @@ func main() {
conf := config.Get() conf := config.Get()
if conf.PluginsDir != "" { if conf.PluginsDir != "" {
if err := os.MkdirAll(conf.PluginsDir, 0755); err != nil { if err := os.MkdirAll(conf.PluginsDir, 0o755); err != nil {
panic(err) panic(err)
} }
} }
if err := os.MkdirAll(conf.UploadedImagesDir, 0755); err != nil { if err := os.MkdirAll(conf.UploadedImagesDir, 0o755); err != nil {
panic(err) panic(err)
} }

View File

@ -1,3 +1,4 @@
//go:build !race
// +build !race // +build !race
package auth package auth

View File

@ -1,3 +1,4 @@
//go:build !race
// +build !race // +build !race
package password package password

View File

@ -8,15 +8,9 @@ import (
"github.com/gotify/server/v2/auth/password" "github.com/gotify/server/v2/auth/password"
"github.com/gotify/server/v2/model" "github.com/gotify/server/v2/model"
"github.com/jinzhu/gorm" "github.com/jinzhu/gorm"
_ "github.com/jinzhu/gorm/dialects/mysql" // enable the mysql dialect.
// enable the mysql dialect. _ "github.com/jinzhu/gorm/dialects/postgres" // enable the postgres dialect.
_ "github.com/jinzhu/gorm/dialects/mysql" _ "github.com/jinzhu/gorm/dialects/sqlite" // enable the sqlite3 dialect.
// enable the postgres dialect.
_ "github.com/jinzhu/gorm/dialects/postgres"
// enable the sqlite3 dialect.
_ "github.com/jinzhu/gorm/dialects/sqlite"
) )
var mkdirAll = os.MkdirAll var mkdirAll = os.MkdirAll
@ -95,7 +89,7 @@ func prepareBlobColumn(dialect string, db *gorm.DB) error {
func createDirectoryIfSqlite(dialect, connection string) { func createDirectoryIfSqlite(dialect, connection string) {
if dialect == "sqlite3" { if dialect == "sqlite3" {
if _, err := os.Stat(filepath.Dir(connection)); os.IsNotExist(err) { 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) panic(err)
} }
} }

View File

@ -1,3 +1,4 @@
//go:build linux || darwin
// +build linux darwin // +build linux darwin
package compat package compat

View File

@ -1,3 +1,4 @@
//go:build !race
// +build !race // +build !race
package compat package compat

View File

@ -1,3 +1,4 @@
//go:build (linux || darwin) && !race
// +build linux darwin // +build linux darwin
// +build !race // +build !race

View File

@ -1,3 +1,4 @@
//go:build !race
// +build !race // +build !race
package plugin package plugin

View File

@ -31,13 +31,13 @@ func TestWithWd(t *testing.T) {
WithWd("non_exist", func(string) {}) 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() { assert.Panics(t, func() {
WithWd(tmpDir.Path(), func(string) {}) WithWd(tmpDir.Path(), func(string) {})
}) })
assert.Nil(t, os.Remove(tmpDir.Path())) 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() { assert.Panics(t, func() {
WithWd(tmpDir.Path(), func(string) { WithWd(tmpDir.Path(), func(string) {
assert.Nil(t, os.RemoveAll(tmpDir.Path())) assert.Nil(t, os.RemoveAll(tmpDir.Path()))