Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump golangci-lint, fix discovered problems #1502

Merged
merged 1 commit into from
Sep 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/ci-backend.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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: |
Expand All @@ -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 }}
11 changes: 3 additions & 8 deletions backend/.golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ run:
linters-settings:
govet:
check-shadowing: true
golint:
min-confidence: 0.1
maligned:
suggest-new: true
goconst:
Expand Down Expand Up @@ -38,17 +36,14 @@ linters:
- govet
- unconvert
- megacheck
- structcheck
- gas
- gocyclo
- dupl
- misspell
- unparam
- varcheck
- deadcode
- unused
- typecheck
- ineffassign
- varcheck
- stylecheck
- gochecknoinits
- exportloopref
Expand All @@ -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
Expand Down
5 changes: 2 additions & 3 deletions backend/app/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package main
import (
"fmt"
"io"
"io/ioutil"
"math/rand"
"net"
"net/http"
Expand All @@ -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)

Expand Down Expand Up @@ -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)

Expand Down
5 changes: 2 additions & 3 deletions backend/app/rest/api/migrator.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"context"
"fmt"
"io"
"io/ioutil"
"net/http"
"os"
"sync"
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
}
Expand Down
3 changes: 1 addition & 2 deletions backend/app/store/image/bolt_store_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package image

import (
"context"
"io/ioutil"
"os"
"path"
"testing"
Expand Down Expand Up @@ -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{})
Expand Down
5 changes: 2 additions & 3 deletions backend/app/store/image/fs_store_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"context"
"encoding/base64"
"io"
"io/ioutil"
"math/rand"
"os"
"path"
Expand Down Expand Up @@ -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{
Expand Down
3 changes: 1 addition & 2 deletions backend/app/store/service/service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package service
import (
"context"
"fmt"
"io/ioutil"
"math/rand"
"net/http"
"net/http/httptest"
Expand Down Expand Up @@ -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)
Expand Down