chore(ci): upgraded linter to 1.62.0 (#4250)

This commit is contained in:
Jarek Kowalski
2024-11-16 07:16:50 -08:00
committed by GitHub
parent 32b9b43a4a
commit eb1cf64c27
38 changed files with 64 additions and 37 deletions

View File

@@ -78,11 +78,9 @@ linters:
enable-all: true
disable:
- depguard
- execinquery
- exhaustruct
- exportloopref
- gochecknoinits
- gomnd
- gci
- ireturn # this one may be interesting to control allocations
- gosmopolitan

View File

@@ -195,7 +195,7 @@ func (c *commandBenchmarkCompression) runCompression(ctx context.Context, data [
continue
}
compressedSize = uint64(compressed.Len())
compressedSize = uint64(compressed.Len()) //nolint:gosec
if c.verifyStable {
h := hashOf(compressed.Bytes())
@@ -277,6 +277,7 @@ func (c *commandBenchmarkCompression) runDecompression(ctx context.Context, data
}
}
//nolint:gosec
return uint64(compressedInput.Length())
}

View File

@@ -70,6 +70,8 @@ func (c *commandBenchmarkEcc) runBenchmark(ctx context.Context) []eccBenchResult
var results []eccBenchResult
data := make([]byte, c.blockSize)
//nolint:gosec
for i := range uint64(c.blockSize) {
data[i] = byte(i%255 + 1)
}

View File

@@ -97,7 +97,7 @@ func askPass(out io.Writer, prompt string) (string, error) {
for range 5 {
fmt.Fprint(out, prompt) //nolint:errcheck
passBytes, err := term.ReadPassword(int(os.Stdin.Fd())) //nolint:gosec
passBytes, err := term.ReadPassword(int(os.Stdin.Fd()))
if err != nil {
return "", errors.Wrap(err, "password prompt error")
}

View File

@@ -92,7 +92,7 @@ func getIntPtrValue(value string, base int) *int {
func getFileModeValue(value string, def os.FileMode) os.FileMode {
if uint32Val, err := strconv.ParseUint(value, 8, 32); err == nil {
return os.FileMode(uint32Val) //nolint:gosec
return os.FileMode(uint32Val)
}
return def

View File

@@ -5,5 +5,5 @@
package localfs
func platformSpecificWidenDev(dev int32) uint64 {
return uint64(dev)
return uint64(dev) //nolint:gosec
}

View File

@@ -8,6 +8,8 @@
)
// UTCTimestamp stores the UTC timestamp in nanoseconds and provides JSON serializability.
//
//nolint:recvcheck
type UTCTimestamp int64
// UnmarshalJSON implements json.Unmarshaler.

View File

@@ -25,7 +25,7 @@ func TestUTCTimestamp(t *testing.T) {
v, err := json.Marshal(x)
require.NoError(t, err)
require.Equal(t, "{\"myts\":\"2022-01-02T03:04:05.000000006Z\"}", string(v))
require.JSONEq(t, "{\"myts\":\"2022-01-02T03:04:05.000000006Z\"}", string(v))
require.NoError(t, json.Unmarshal(v, &y))
require.Equal(t, x, y)

View File

@@ -8,6 +8,8 @@
)
// AccessLevel specifies access level.
//
//nolint:recvcheck
type AccessLevel int
// accessLevelToString maps supported access levels to strings.

View File

@@ -98,7 +98,7 @@ func main() {
// generate key=sha256(i) without allocations.
h.Reset()
binary.LittleEndian.PutUint64(num[:], uint64(i))
binary.LittleEndian.PutUint64(num[:], uint64(i)) //nolint:gosec
h.Write(num[:])
h.Sum(keyBuf[:0])

View File

@@ -220,6 +220,8 @@ func (c *PersistentCache) Close(ctx context.Context) {
}
// A contentMetadataHeap implements heap.Interface and holds blob.Metadata.
//
//nolint:recvcheck
type contentMetadataHeap struct {
data []blob.Metadata
index map[blob.ID]int

View File

@@ -108,7 +108,7 @@ func (r closedIntRange) length() uint {
return 0
}
return uint(r.hi - r.lo + 1)
return uint(r.hi - r.lo + 1) //nolint:gosec
}
func (r closedIntRange) isEmpty() bool {

View File

@@ -50,8 +50,8 @@ func goModeToUnixMode(mode os.FileMode) uint32 {
func populateAttributes(a *fuse.Attr, e fs.Entry) {
a.Mode = goModeToUnixMode(e.Mode())
a.Size = uint64(e.Size())
a.Mtime = uint64(e.ModTime().Unix())
a.Size = uint64(e.Size()) //nolint:gosec
a.Mtime = uint64(e.ModTime().Unix()) //nolint:gosec
a.Ctime = a.Mtime
a.Atime = a.Mtime
a.Nlink = 1

View File

@@ -18,6 +18,8 @@
)
// Bytes represents a sequence of bytes split into slices.
//
//nolint:recvcheck
type Bytes struct {
Slices [][]byte

View File

@@ -87,11 +87,11 @@ func TestAggregation(t *testing.T) {
"counter4": 777,
}, res.Counters)
require.Equal(t,
require.JSONEq(t,
`{"dist1":{"min":50,"max":210,"sum":560,"count":4,"buckets":[2,2,0,0]}}`,
toJSON(res.SizeDistributions))
require.Equal(t,
require.JSONEq(t,
`{"dur1":{"min":50000000000,"max":210000000000,"sum":560000000000,"count":4,"buckets":[2,2,0,0]}}`,
toJSON(res.DurationDistributions))
}

View File

@@ -27,6 +27,7 @@ func GetFileAllocSize(fname string) (uint64, error) {
return 0, err //nolint:wrapcheck
}
//nolint:gosec
return uint64(st.Blocks) * diskBlockSize, nil
}

View File

@@ -15,8 +15,8 @@ func getPlatformVolumeSizeInfo(volumeMountPoint string) (VolumeSizeInfo, error)
}
return VolumeSizeInfo{
TotalSize: stats.Blocks * uint64(stats.Bsize), //nolint:unconvert,nolintlint
UsedSize: (stats.Blocks - stats.Bfree) * uint64(stats.Bsize), //nolint:unconvert,nolintlint
TotalSize: stats.Blocks * uint64(stats.Bsize), //nolint:gosec,unconvert,nolintlint
UsedSize: (stats.Blocks - stats.Bfree) * uint64(stats.Bsize), //nolint:gosec,unconvert,nolintlint
// Conversion to uint64 is needed for some arch/distrib combination.
FilesCount: stats.Files - uint64(stats.Ffree), //nolint:unconvert,nolintlint
}, nil

View File

@@ -10,6 +10,8 @@
type Method string
// MethodConfig represents JSON-serializable configuration of a notification method and parameters.
//
//nolint:recvcheck
type MethodConfig struct {
Type Method
Config any

View File

@@ -7,6 +7,8 @@
)
// ConnectionInfo represents JSON-serializable configuration of a blob storage.
//
//nolint:recvcheck
type ConnectionInfo struct {
Type string
Config interface{}

View File

@@ -21,8 +21,8 @@ func (fs *fsStorage) GetCapacity(ctx context.Context) (blob.Capacity, error) {
}
return blob.Capacity{
SizeB: uint64(stat.Blocks) * uint64(stat.Bsize), //nolint:unconvert
FreeB: uint64(stat.Bavail) * uint64(stat.Bsize), //nolint:unconvert
SizeB: uint64(stat.Blocks) * uint64(stat.Bsize), //nolint:gosec,unconvert,nolintlint
FreeB: uint64(stat.Bavail) * uint64(stat.Bsize), //nolint:gosec,unconvert,nolintlint
}, nil
}, fs.Impl.(*fsImpl).isRetriable) //nolint:forcetypeassert
}

View File

@@ -68,8 +68,8 @@ func (gdrive *gdriveStorage) GetCapacity(ctx context.Context) (blob.Capacity, er
}
return blob.Capacity{
SizeB: uint64(q.Limit),
FreeB: uint64(q.Limit) - uint64(q.Usage),
SizeB: uint64(q.Limit), //nolint:gosec
FreeB: uint64(q.Limit) - uint64(q.Usage), //nolint:gosec
}, nil
}

View File

@@ -183,7 +183,7 @@ func TestMetataJSONString(t *testing.T) {
Timestamp: time.Date(2000, 1, 2, 3, 4, 5, 6, time.UTC),
}
require.Equal(t, `{"id":"foo","length":12345,"timestamp":"2000-01-02T03:04:05.000000006Z"}`, bm.String())
require.JSONEq(t, `{"id":"foo","length":12345,"timestamp":"2000-01-02T03:04:05.000000006Z"}`, bm.String())
}
func TestPutBlobAndGetMetadata(t *testing.T) {

View File

@@ -181,6 +181,7 @@ func (sm *SharedManager) attemptReadPackFileLocalIndex(ctx context.Context, pack
postamble.localIndexOffset -= uint32(offset) //nolint:gosec
//nolint:gosec
if uint64(postamble.localIndexOffset+postamble.localIndexLength) > uint64(payload.Length()) {
// invalid offset/length
return errors.Errorf("unable to find valid local index in file %v - invalid offset/length", packFile)

View File

@@ -2014,7 +2014,7 @@ func (s *contentManagerSuite) verifyReadsOwnWrites(t *testing.T, st blob.Storage
bm := s.newTestContentManagerWithTweaks(t, st, tweaks)
ids := make([]ID, 100)
for i := range len(ids) {
for i := range len(ids) { //nolint:intrange
ids[i] = writeContentAndVerify(ctx, t, bm, seededRandomData(i, maxPackCapacity/2))
for j := range i {
@@ -2035,7 +2035,7 @@ func (s *contentManagerSuite) verifyReadsOwnWrites(t *testing.T, st blob.Storage
require.NoError(t, bm.CloseShared(ctx))
bm = s.newTestContentManagerWithTweaks(t, st, tweaks)
for i := range len(ids) {
for i := range len(ids) { //nolint:intrange
verifyContent(ctx, t, bm, ids[i], seededRandomData(i, maxPackCapacity/2))
}
}
@@ -2378,7 +2378,7 @@ func (s *contentManagerSuite) TestContentIndexPermissiveReadsWithFault(t *testin
bm := s.newTestContentManagerWithTweaks(t, st, tweaks)
ids := make([]ID, 100)
for i := range len(ids) {
for i := range len(ids) { //nolint:intrange
ids[i] = writeContentAndVerify(ctx, t, bm, seededRandomData(i, maxPackCapacity/2))
for j := range i {
@@ -2409,7 +2409,7 @@ func (s *contentManagerSuite) TestContentIndexPermissiveReadsWithFault(t *testin
bm = s.newTestContentManagerWithTweaks(t, st, tweaks)
for i := range len(ids) {
for i := range len(ids) { //nolint:intrange
verifyContent(ctx, t, bm, ids[i], seededRandomData(i, maxPackCapacity/2))
}
}

View File

@@ -30,6 +30,8 @@ func (p IDPrefix) ValidateSingle() error {
}
// ID is an identifier of content in content-addressable storage.
//
//nolint:recvcheck
type ID struct {
data [hashing.MaxHashSize]byte

View File

@@ -111,7 +111,7 @@ func (b Builder) sortedContents() []*Info {
// Phase 3 - merge results from all buckets.
result := make([]*Info, 0, len(b))
for i := range len(buckets) {
for i := range len(buckets) { //nolint:intrange
result = append(result, buckets[i]...)
}

View File

@@ -366,7 +366,7 @@ func (b *indexBuilderV1) formatEntry(entry []byte, it *Info) error {
entryPackFileOffset := entry[8:12]
entryPackedOffset := entry[12:16]
entryPackedLength := entry[16:20]
timestampAndFlags := uint64(it.TimestampSeconds) << 16 //nolint:mnd
timestampAndFlags := uint64(it.TimestampSeconds) << 16 //nolint:mnd,gosec
packBlobID := it.PackBlobID
if len(packBlobID) == 0 {

View File

@@ -8,6 +8,8 @@
)
// Info is an implementation of Info based on a structure.
//
//nolint:recvcheck
type Info struct {
PackBlobID blob.ID `json:"packFile,omitempty"`
TimestampSeconds int64 `json:"time"`

View File

@@ -80,6 +80,7 @@ type nextInfo struct {
ch <-chan Info
}
//nolint:recvcheck
type nextInfoHeap []*nextInfo
func (h nextInfoHeap) Len() int { return len(h) }

View File

@@ -184,7 +184,7 @@ func TestManifestInitCorruptedBlock(t *testing.T) {
for blobID, v := range data {
for _, prefix := range content.PackBlobIDPrefixes {
if strings.HasPrefix(string(blobID), string(prefix)) {
for i := range len(v) {
for i := range len(v) { // nolint:intrange
v[i] ^= 1
}
}

View File

@@ -15,6 +15,8 @@
// 1. In a single content block, this is the most common case for small objects.
// 2. In a series of content blocks with an indirect block pointing at them (multiple indirections are allowed).
// This is used for larger files. Object IDs using indirect blocks start with "I"
//
//nolint:recvcheck
type ID struct {
cid content.ID
indirection byte

View File

@@ -83,7 +83,7 @@ func (rs *rabinKarp64Splitter) MaxSegmentSize() int {
}
func newRabinKarp64SplitterFactory(avgSize int) Factory {
mask := uint64(avgSize - 1)
mask := uint64(avgSize - 1) //nolint:gosec
minSize, maxSize := avgSize/2, avgSize*2 //nolint:mnd
return func() Splitter {

View File

@@ -84,6 +84,8 @@ func (m *Manifest) UpdatePins(add, remove []string) bool {
)
// Permissions encapsulates UNIX permissions for a filesystem entry.
//
//nolint:recvcheck
type Permissions int
// MarshalJSON emits permissions as octal string.

View File

@@ -36,6 +36,8 @@ func (p *VolumeShadowCopyPolicy) Merge(src VolumeShadowCopyPolicy, def *VolumeSh
// OSSnapshotMode specifies whether OS-level snapshots are used for file systems
// that support them.
//
//nolint:recvcheck
type OSSnapshotMode byte
// OS-level snapshot modes.

View File

@@ -17,6 +17,8 @@
)
// TimeOfDay represents the time of day (hh:mm) using 24-hour time format.
//
//nolint:recvcheck
type TimeOfDay struct {
Hour int `json:"hour"`
Minute int `json:"min"`

View File

@@ -5,7 +5,6 @@
"path"
"path/filepath"
"reflect"
"regexp"
"runtime"
"sort"
"strings"
@@ -777,7 +776,7 @@ func TestSnapshotCreateAllSnapshotPath(t *testing.T) {
require.Equal(t, "foo", si[2].Host)
if runtime.GOOS == "windows" {
require.Regexp(t, regexp.MustCompile(`[A-Z]:\\foo\\bar`), si[2].Path)
require.Regexp(t, `[A-Z]:\\foo\\bar`, si[2].Path)
} else {
require.Equal(t, "/foo/bar", si[2].Path)
}

View File

@@ -7,12 +7,12 @@ https://github.com/git-chglog/git-chglog/releases/download/v0.15.1/git-chglog_0.
https://github.com/gohugoio/hugo/releases/download/v0.113.0/hugo_extended_0.113.0_darwin-universal.tar.gz: 1557f896f34743d241e1aecab588be273dde59692b362a9f4488231a2595b2ae
https://github.com/gohugoio/hugo/releases/download/v0.113.0/hugo_extended_0.113.0_linux-amd64.tar.gz: e04bccfa81df6c727f1c03bc858eb21d6f95123d311cafe245f4485d289123f3
https://github.com/gohugoio/hugo/releases/download/v0.113.0/hugo_extended_0.113.0_windows-amd64.zip: 3eabfbfad1431939058e6f7e76573c6bac1fee92f3a7b1ac5739c555940f0e0e
https://github.com/golangci/golangci-lint/releases/download/v1.60.3/golangci-lint-1.60.3-darwin-amd64.tar.gz: faf60366f99bb4010b634a030c45eaf57baae6c0b7e10be151139871e3fef40e
https://github.com/golangci/golangci-lint/releases/download/v1.60.3/golangci-lint-1.60.3-darwin-arm64.tar.gz: deb0fbd0b99992d97808614db1214f57d5bdc12b907581e2ef10d3a392aca11f
https://github.com/golangci/golangci-lint/releases/download/v1.60.3/golangci-lint-1.60.3-linux-amd64.tar.gz: 4037af8122871f401ed874852a471e54f147ff8ce80f5a304e020503bdb806ef
https://github.com/golangci/golangci-lint/releases/download/v1.60.3/golangci-lint-1.60.3-linux-arm64.tar.gz: 74782943b2d2edae1208be3701e0cafe62817ba90b9b4cc5ca52bdef26df12f9
https://github.com/golangci/golangci-lint/releases/download/v1.60.3/golangci-lint-1.60.3-linux-armv6.tar.gz: 9478a9cee4ea48c3025516472624f34f2e3a3406d3ec6642c8cef3cd8359aea9
https://github.com/golangci/golangci-lint/releases/download/v1.60.3/golangci-lint-1.60.3-windows-amd64.zip: ebf030e0c25b99d1b5f301ec5f1ae0005c0d4f92d6ee79474ef170d69f390fef
https://github.com/golangci/golangci-lint/releases/download/v1.62.0/golangci-lint-1.62.0-darwin-amd64.tar.gz: 0ed6f1a216ddb62e293858196799608d63894bd2ec178114484363ca45cde84b
https://github.com/golangci/golangci-lint/releases/download/v1.62.0/golangci-lint-1.62.0-darwin-arm64.tar.gz: dde51958f0f24d442062b5709b6912d91e235115dfe5887e80b3e5602c9cc09b
https://github.com/golangci/golangci-lint/releases/download/v1.62.0/golangci-lint-1.62.0-linux-amd64.tar.gz: 53695531eeb824b6883c703335cef6f07882f8ba6fedc00ed43853ea07fa1fbd
https://github.com/golangci/golangci-lint/releases/download/v1.62.0/golangci-lint-1.62.0-linux-arm64.tar.gz: e1e47209d7bdd288fd8cfe88548b477df2f7eca81b0e9ec1f9d45604f79185eb
https://github.com/golangci/golangci-lint/releases/download/v1.62.0/golangci-lint-1.62.0-linux-armv6.tar.gz: 0a6565ed98da60b470f5652eb1bf434ae84f39ab0632749398176e1a9c477798
https://github.com/golangci/golangci-lint/releases/download/v1.62.0/golangci-lint-1.62.0-windows-amd64.zip: 34e980afe44655c395aa65f96953fc4b6a2e58206f1a7370ab88407b187184c8
https://github.com/goreleaser/goreleaser/releases/download/v0.176.0/goreleaser_Darwin_arm64.tar.gz: 1f95e6561974f4766d8833438b646b06930563ca9867447ea03edb623d876c75
https://github.com/goreleaser/goreleaser/releases/download/v0.176.0/goreleaser_Darwin_x86_64.tar.gz: 17ecad881a50e32f033da5a200c8417d37cae70f09e925645452937998aca506
https://github.com/goreleaser/goreleaser/releases/download/v0.176.0/goreleaser_Linux_arm64.tar.gz: 8bf2a9b9e84498bfa239f2fe91b2d555642c87ab9d3f5d37f29e6e97116910a3

View File

@@ -102,7 +102,7 @@ retry:=
endif
# tool versions
GOLANGCI_LINT_VERSION=1.60.3
GOLANGCI_LINT_VERSION=1.62.0
CHECKLOCKS_VERSION=e8c1fff214d0ecf02cfe5aa9c62d11174130c339
NODE_VERSION=20.15.1
HUGO_VERSION=0.113.0