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

@ -24,7 +24,6 @@ import (
"encoding/json"
"fmt"
"io"
"io/ioutil"
"mime/multipart"
"net/http"
"net/textproto"
@ -114,7 +113,7 @@ func TestClient_CreateAttachment(t *testing.T) {
r.NoError(err)
defer r.NoError(dataFile.Close())
b, err := ioutil.ReadAll(dataFile)
b, err := io.ReadAll(dataFile)
r.NoError(err)
r.Equal(testAttachmentCleartext, string(b))
@ -146,7 +145,7 @@ func TestClient_GetAttachment(t *testing.T) {
defer att.Close() //nolint:errcheck
// In reality, r contains encrypted data
b, err := ioutil.ReadAll(att)
b, err := io.ReadAll(att)
r.NoError(err)
r.Equal(testAttachmentCleartext, string(b))
@ -181,7 +180,7 @@ func TestAttachmentEncrypt(t *testing.T) {
func decryptAndCheck(r *require.Assertions, data io.Reader) {
// First separate KeyPacket from encrypted data. In our case keypacket
// has 271 bytes.
raw, err := ioutil.ReadAll(data)
raw, err := io.ReadAll(data)
r.NoError(err)
rawKeyPacket := raw[:271]
rawDataPacket := raw[271:]
@ -195,7 +194,7 @@ func decryptAndCheck(r *require.Assertions, data io.Reader) {
decryptedReader, err := haveAttachment.Decrypt(bytes.NewBuffer(rawDataPacket), testPrivateKeyRing)
r.NoError(err)
b, err := ioutil.ReadAll(decryptedReader)
b, err := io.ReadAll(decryptedReader)
r.NoError(err)
r.Equal(testAttachmentCleartext, string(b))

View File

@ -20,7 +20,7 @@ package pmapi
import (
"bytes"
"encoding/json"
"io/ioutil"
"io"
"net/http"
"strconv"
"time"
@ -139,6 +139,6 @@ func (r tlsReport) sendReport(cfg Config, uri string) {
logrus.WithField("status", http.StatusOK).Error("StatusCode was not OK")
}
_, _ = ioutil.ReadAll(res.Body)
_, _ = io.ReadAll(res.Body)
_ = res.Body.Close()
}

View File

@ -54,10 +54,10 @@ type Event struct {
type EventAction int
const (
EventDelete EventAction = iota // Item has been deleted.
EventCreate // Item has been created.
EventUpdate // Item has been updated.
EventUpdateFlags // For messages: flags have been updated.
EventDelete EventAction = iota // EventDelete Item has been deleted.
EventCreate // EventCreate Item has been created.
EventUpdate // EventUpdate Item has been updated.
EventUpdateFlags // EventUpdateFlags For messages: flags have been updated.
)
// Flags for event refresh.

View File

@ -29,7 +29,7 @@ import (
const (
MaxImportMessageRequestLength = 10
MaxImportMessageRequestSize = 25 * 1024 * 1024 // 25 MB total limit
MaxImportMessageRequestSize = 25 * 1024 * 1024 // MaxImportMessageRequestSize 25 MB total limit
)
type ImportMsgReq struct {

View File

@ -22,7 +22,6 @@ import (
"encoding/json"
"fmt"
"io"
"io/ioutil"
"math/rand"
"mime/multipart"
"net/http"
@ -76,7 +75,7 @@ func TestClient_Import(t *testing.T) { //nolint:funlen
r.Equal(t, "form-data", contentDisp)
r.Equal(t, "0", params["name"])
b, err := ioutil.ReadAll(p)
b, err := io.ReadAll(p)
r.NoError(t, err)
r.Equal(t, string(testImportReqs[0].Message), string(b))

View File

@ -22,7 +22,6 @@ import (
"encoding/base64"
"encoding/json"
"io"
"io/ioutil"
"github.com/ProtonMail/gopenpgp/v2/crypto"
"github.com/pkg/errors"
@ -231,7 +230,7 @@ func encryptAttachment(kr *crypto.KeyRing, data io.Reader, filename string) (enc
return nil, err
}
dataBytes, err := ioutil.ReadAll(data)
dataBytes, err := io.ReadAll(data)
if err != nil {
return
}
@ -253,7 +252,7 @@ func decryptAttachment(kr *crypto.KeyRing, keyPackets []byte, data io.Reader) (d
if kr == nil {
return nil, ErrNoKeyringAvailable
}
dataBytes, err := ioutil.ReadAll(data)
dataBytes, err := io.ReadAll(data)
if err != nil {
return
}
@ -269,7 +268,7 @@ func signAttachment(encrypter *crypto.KeyRing, data io.Reader) (signature io.Rea
if encrypter == nil {
return nil, ErrNoKeyringAvailable
}
dataBytes, err := ioutil.ReadAll(data)
dataBytes, err := io.ReadAll(data)
if err != nil {
return
}

View File

@ -18,7 +18,7 @@
package pmapi
import (
"io/ioutil"
"io"
"github.com/ProtonMail/gopenpgp/v2/crypto"
"golang.org/x/net/context"
@ -56,7 +56,7 @@ func (m *manager) fetchFile(url string) ([]byte, error) {
return nil, err
}
b, err := ioutil.ReadAll(res.RawBody())
b, err := io.ReadAll(res.RawBody())
if err != nil {
return nil, err
}

View File

@ -20,7 +20,7 @@ package pmapi
import (
"context"
"fmt"
"io/ioutil"
"io"
"net/http"
"net/http/httptest"
"strings"
@ -68,7 +68,7 @@ func TestClient_BugReportWithAttachment(t *testing.T) {
attReader, err := req.MultipartForm.File["log"][0].Open()
r.NoError(t, err)
_, err = ioutil.ReadAll(attReader)
_, err = io.ReadAll(attReader)
r.NoError(t, err)
w.Header().Set("Content-Type", "application/json")

View File

@ -27,7 +27,6 @@ import (
"errors"
"fmt"
"io"
"io/ioutil"
"net/http"
"net/mail"
"net/url"
@ -133,10 +132,10 @@ const (
type LabelsOperation int
const (
KeepLabels LabelsOperation = iota // Do nothing.
ReplaceLabels // Replace current labels with new ones.
AddLabels // Add new labels to current ones.
RemoveLabels // Remove specified labels from current ones.
KeepLabels LabelsOperation = iota // KeepLabels Do nothing.
ReplaceLabels // ReplaceLabels Replace current labels with new ones.
AddLabels // AddLabels Add new labels to current ones.
RemoveLabels // RemoveLabels Remove specified labels from current ones.
)
// Due to API limitations, we shouldn't make requests with more than 100 message IDs at a time.
@ -309,7 +308,7 @@ func (m *Message) ExtractSignatures(kr *crypto.KeyRing) ([]Signature, error) {
return nil, err
}
if _, err := ioutil.ReadAll(msg.UnverifiedBody); err != nil {
if _, err := io.ReadAll(msg.UnverifiedBody); err != nil {
return nil, err
}

View File

@ -18,7 +18,7 @@
package pmapi
import (
"io/ioutil"
"os"
"strings"
"github.com/ProtonMail/gopenpgp/v2/crypto"
@ -65,7 +65,7 @@ func init() {
}
func readTestFile(name string, trimNewlines bool) string { //nolint:unparam
data, err := ioutil.ReadFile("testdata/" + name)
data, err := os.ReadFile("testdata/" + name)
if err != nil {
panic(err)
}