diff --git a/.github/workflows/ci-backend.yml b/.github/workflows/ci-backend.yml index 6ae22b8b..fbeace65 100644 --- a/.github/workflows/ci-backend.yml +++ b/.github/workflows/ci-backend.yml @@ -36,8 +36,8 @@ jobs: - name: install golangci-lint and goveralls run: | - curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh| sh -s -- -b $GITHUB_WORKSPACE v1.46.1 - go get -u github.com/mattn/goveralls + curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $GITHUB_WORKSPACE v1.49.0 + go install github.com/mattn/goveralls@latest - name: test and lint backend run: | @@ -59,7 +59,7 @@ jobs: TZ: "America/Chicago" - name: submit coverage - run: $(go env GOPATH)/bin/goveralls -service="github" -coverprofile=$GITHUB_WORKSPACE/profile.cov + run: goveralls -service="github" -coverprofile=$GITHUB_WORKSPACE/profile.cov working-directory: backend env: COVERALLS_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/backend/.golangci.yml b/backend/.golangci.yml index 5467f7fc..f611a550 100644 --- a/backend/.golangci.yml +++ b/backend/.golangci.yml @@ -8,8 +8,6 @@ run: linters-settings: govet: check-shadowing: true - golint: - min-confidence: 0.1 maligned: suggest-new: true goconst: @@ -38,17 +36,14 @@ linters: - govet - unconvert - megacheck - - structcheck - gas - gocyclo - dupl - misspell - unparam - - varcheck - - deadcode + - unused - typecheck - ineffassign - - varcheck - stylecheck - gochecknoinits - exportloopref @@ -64,9 +59,9 @@ issues: - text: "at least one file in a package should have a package comment" linters: - stylecheck - - text: "should have a package comment, unless it's in another file for this package" + - text: "package-comments: should have a package comment" linters: - - golint + - revive - path: _test\.go linters: - gosec diff --git a/backend/app/main_test.go b/backend/app/main_test.go index dc383767..4eeb78bb 100644 --- a/backend/app/main_test.go +++ b/backend/app/main_test.go @@ -3,7 +3,6 @@ package main import ( "fmt" "io" - "io/ioutil" "math/rand" "net" "net/http" @@ -22,7 +21,7 @@ import ( ) func Test_Main(t *testing.T) { - dir, err := ioutil.TempDir(os.TempDir(), "remark42") + dir, err := os.MkdirTemp(os.TempDir(), "remark42") require.NoError(t, err) defer os.RemoveAll(dir) @@ -60,7 +59,7 @@ func Test_Main(t *testing.T) { } func TestMain_WithWebhook(t *testing.T) { - dir, err := ioutil.TempDir(os.TempDir(), "remark42") + dir, err := os.MkdirTemp(os.TempDir(), "remark42") require.NoError(t, err) defer os.RemoveAll(dir) diff --git a/backend/app/rest/api/migrator.go b/backend/app/rest/api/migrator.go index bd056c88..3bc54019 100644 --- a/backend/app/rest/api/migrator.go +++ b/backend/app/rest/api/migrator.go @@ -5,7 +5,6 @@ import ( "context" "fmt" "io" - "io/ioutil" "net/http" "os" "sync" @@ -172,7 +171,7 @@ func (m *Migrator) remapCtrl(w http.ResponseWriter, r *http.Request) { defer m.setBusy(siteID, false) // do export - fh, e := ioutil.TempFile("", "remark42_convert") + fh, e := os.CreateTemp("", "remark42_convert") if e != nil { log.Printf("[WARN] failed to make temp file %+v", e) return @@ -250,7 +249,7 @@ func (m *Migrator) runImport(siteID, provider, tmpfile string) { // saveTemp reads from reader and saves to temp file func (m *Migrator) saveTemp(r io.Reader) (string, error) { - tmpfile, err := ioutil.TempFile("", "remark42_import") + tmpfile, err := os.CreateTemp("", "remark42_import") if err != nil { return "", fmt.Errorf("can't make temp file: %w", err) } diff --git a/backend/app/store/image/bolt_store_test.go b/backend/app/store/image/bolt_store_test.go index 8dd1c38d..d9977b19 100644 --- a/backend/app/store/image/bolt_store_test.go +++ b/backend/app/store/image/bolt_store_test.go @@ -2,7 +2,6 @@ package image import ( "context" - "io/ioutil" "os" "path" "testing" @@ -150,7 +149,7 @@ func checkBoltImgData(t *testing.T, db *bolt.DB, bucket, id string, callback fun } func prepareBoltImageStorageTest(t *testing.T) (svc *Bolt, teardown func()) { - loc, err := ioutil.TempDir("", "test_image_r42") + loc, err := os.MkdirTemp("", "test_image_r42") require.NoError(t, err, "failed to make temp dir") svc, err = NewBoltStorage(path.Join(loc, "picture.db"), bolt.Options{}) diff --git a/backend/app/store/image/fs_store_test.go b/backend/app/store/image/fs_store_test.go index c2a3fb3f..3266e2c7 100644 --- a/backend/app/store/image/fs_store_test.go +++ b/backend/app/store/image/fs_store_test.go @@ -4,7 +4,6 @@ import ( "context" "encoding/base64" "io" - "io/ioutil" "math/rand" "os" "path" @@ -254,10 +253,10 @@ func TestFsStore_Info(t *testing.T) { } func prepareImageTest(t *testing.T) (svc *FileSystem, teardown func()) { - loc, err := ioutil.TempDir("", "test_image_r42") + loc, err := os.MkdirTemp("", "test_image_r42") require.NoError(t, err, "failed to make temp dir") - staging, err := ioutil.TempDir("", "test_image_r42.staging") + staging, err := os.MkdirTemp("", "test_image_r42.staging") require.NoError(t, err, "failed to make temp staging dir") svc = &FileSystem{ diff --git a/backend/app/store/service/service_test.go b/backend/app/store/service/service_test.go index a4cd2aa9..9bddc4fa 100644 --- a/backend/app/store/service/service_test.go +++ b/backend/app/store/service/service_test.go @@ -3,7 +3,6 @@ package service import ( "context" "fmt" - "io/ioutil" "math/rand" "net/http" "net/http/httptest" @@ -1558,7 +1557,7 @@ func Benchmark_ServiceCreate(b *testing.B) { // makes new boltdb, put two records func prepStoreEngine(t *testing.T) (e engine.Interface, teardown func()) { - testDBLoc, err := ioutil.TempDir("", "test_image_r42") + testDBLoc, err := os.MkdirTemp("", "test_image_r42") require.NoError(t, err) testDB := path.Join(testDBLoc, "test.db") _ = os.Remove(testDB)