Other: Update golangci-lint to v1.50.0

This commit is contained in:
Leander Beernaert
2022-10-17 11:02:56 +02:00
parent e0603f741f
commit 9d800324af
70 changed files with 247 additions and 277 deletions

View File

@ -19,7 +19,6 @@ package accounts
import (
"encoding/json"
"io/ioutil"
"os"
"path/filepath"
"sort"
@ -90,7 +89,7 @@ func (a *TestAccount) initKeys() {
func readTestFile(fileName string) []byte {
testDataFolder := os.Getenv("TEST_DATA")
path := filepath.Join(testDataFolder, fileName)
data, err := ioutil.ReadFile(path) //nolint:gosec
data, err := os.ReadFile(path) //nolint:gosec
if err != nil {
panic(err)
}

View File

@ -19,7 +19,7 @@ package accounts
import (
"encoding/json"
"io/ioutil"
"os"
"github.com/ProtonMail/proton-bridge/v2/pkg/pmapi"
"github.com/pkg/errors"
@ -37,7 +37,7 @@ type TestAccounts struct {
}
func Load(path string) (*TestAccounts, error) {
data, err := ioutil.ReadFile(path) //nolint:gosec
data, err := os.ReadFile(path) //nolint:gosec
if err != nil {
return nil, errors.Wrap(err, "failed to load JSON")
}

View File

@ -19,7 +19,7 @@ package context
import (
"bytes"
"io/ioutil"
"io"
"runtime/pprof"
)
@ -41,7 +41,7 @@ func (ph *panicHandler) HandlePanic() {
r := bytes.NewBufferString("")
_ = pprof.Lookup("goroutine").WriteTo(r, 2)
b, err := ioutil.ReadAll(r)
b, err := io.ReadAll(r)
ph.t.Errorf("pprof details: %s %s", err, b)
ph.t.FailNow()

View File

@ -18,7 +18,7 @@
package context
import (
"io/ioutil"
"os"
"path/filepath"
)
@ -29,7 +29,7 @@ type fakeCache struct {
// newFakeCache creates a temporary folder for files.
// It's expected the test calls `ClearData` before finish to remove it from the file system.
func newFakeCache() *fakeCache {
dir, err := ioutil.TempDir("", "test-cache")
dir, err := os.MkdirTemp("", "test-cache")
if err != nil {
panic(err)
}

View File

@ -18,7 +18,6 @@
package context
import (
"io/ioutil"
"os"
)
@ -27,7 +26,7 @@ type fakeLocations struct {
}
func newFakeLocations() *fakeLocations {
dir, err := ioutil.TempDir("", "test-cache")
dir, err := os.MkdirTemp("", "test-cache")
if err != nil {
panic(err)
}

View File

@ -18,8 +18,8 @@
package context
import (
"io/ioutil"
"math/rand"
"os"
"github.com/ProtonMail/proton-bridge/v2/internal/config/settings"
)
@ -32,7 +32,7 @@ type fakeSettings struct {
// newFakeSettings creates a temporary folder for files.
// It's expected the test calls `ClearData` before finish to remove it from the file system.
func newFakeSettings() *fakeSettings {
dir, err := ioutil.TempDir("", "test-settings")
dir, err := os.MkdirTemp("", "test-settings")
if err != nil {
panic(err)
}

View File

@ -23,7 +23,6 @@ import (
"encoding/base64"
"fmt"
"io"
"io/ioutil"
"net/textproto"
"github.com/ProtonMail/proton-bridge/v2/pkg/pmapi"
@ -32,8 +31,8 @@ import (
// dataPacketOutlineLightInstagram48png is data packet with encrypted data and
// session key
//
// gpg: encrypted with 2048-bit RSA key, ID 70B8CA23079F2167, created 2019-09-23
// "james-test@protonmail.blue <james-test@protonmail.blue>"
// gpg: encrypted with 2048-bit RSA key, ID 70B8CA23079F2167, created 2019-09-23
// "james-test@protonmail.blue <james-test@protonmail.blue>"
//
// If you need to rebuild you can dump KeyPacket string from `CreateAttachment`
// function when called during message sending test.
@ -63,14 +62,14 @@ func (api *FakePMAPI) GetAttachment(_ context.Context, attachmentID string) (io.
return nil, err
}
r := bytes.NewReader(b)
return ioutil.NopCloser(r), nil
return io.NopCloser(r), nil
}
func (api *FakePMAPI) CreateAttachment(_ context.Context, attachment *pmapi.Attachment, data io.Reader, signature io.Reader) (*pmapi.Attachment, error) {
if err := api.checkAndRecordCall(POST, "/mail/v4/attachments", nil); err != nil {
return nil, err
}
bytes, err := ioutil.ReadAll(data)
bytes, err := io.ReadAll(data)
if err != nil {
return nil, err
}

View File

@ -41,13 +41,13 @@ func (api *FakePMAPI) GetMessage(_ context.Context, apiID string) (*pmapi.Messag
}
// ListMessages does not implement following filters:
// * Sort (it sorts by ID only), but Desc works
// * Keyword
// * To
// * Subject
// * ID
// * Attachments
// * AutoWildcard
// - Sort (it sorts by ID only), but Desc works
// - Keyword
// - To
// - Subject
// - ID
// - Attachments
// - AutoWildcard
func (api *FakePMAPI) ListMessages(_ context.Context, filter *pmapi.MessagesFilter) ([]*pmapi.Message, int, error) {
if err := api.checkAndRecordCall(GET, "/mail/v4/messages", filter); err != nil {
return nil, 0, err

View File

@ -64,7 +64,7 @@ func (pc *persistentClient) AuthDelete(_ context.Context) error {
// AuthSalt returns cached string. Otherwise after some time there is an error:
//
// Access token does not have sufficient scope
// Access token does not have sufficient scope
//
// while all other routes works normally. Need to confirm with Aron that this
// is expected behaviour.

View File

@ -18,7 +18,7 @@
package liveapi
import (
"io/ioutil"
"io"
"net/http"
"github.com/pkg/errors"
@ -49,7 +49,7 @@ func (t *fakeTransport) RoundTrip(req *http.Request) (*http.Response, error) {
return nil, errors.Wrap(err, "failed to get body")
}
if bodyReader != nil {
body, err = ioutil.ReadAll(bodyReader)
body, err = io.ReadAll(bodyReader)
if err != nil {
return nil, errors.Wrap(err, "failed to read body")
}