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

Upgrade to golangci-lint v1.59.0 #14153

Merged
merged 1 commit into from
May 28, 2024
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ jobs:
with:
args: --verbose
# Make sure to sync this with Makefile.common and scripts/golangci-lint.yml.
version: v1.56.2
version: v1.59.0
fuzzing:
uses: ./.github/workflows/fuzzing.yml
if: github.event_name == 'pull_request'
Expand Down
2 changes: 1 addition & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ issues:
source: "^// ==="
- linters:
- perfsprint
text: "fmt.Sprintf can be replaced with string addition"
text: "fmt.Sprintf can be replaced with string concatenation"
linters-settings:
depguard:
rules:
Expand Down
2 changes: 1 addition & 1 deletion Makefile.common
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ PROMU_URL := https://github.com/prometheus/promu/releases/download/v$(PROMU_
SKIP_GOLANGCI_LINT :=
GOLANGCI_LINT :=
GOLANGCI_LINT_OPTS ?=
GOLANGCI_LINT_VERSION ?= v1.56.2
GOLANGCI_LINT_VERSION ?= v1.59.0
# golangci-lint only supports linux, darwin and windows platforms on i386/amd64/arm64.
# windows isn't included here because of the path separator being different.
ifeq ($(GOHOSTOS),$(filter $(GOHOSTOS),linux darwin))
Expand Down
4 changes: 2 additions & 2 deletions cmd/prometheus/query_log_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ func (p *queryLogTest) run(t *testing.T) {
if p.exactQueryCount() {
require.Equal(t, 1, qc)
} else {
require.Greater(t, qc, 0, "no queries logged")
require.Positive(t, qc, "no queries logged")
}
p.validateLastQuery(t, ql)

Expand Down Expand Up @@ -366,7 +366,7 @@ func (p *queryLogTest) run(t *testing.T) {
if p.exactQueryCount() {
require.Equal(t, 1, qc)
} else {
require.Greater(t, qc, 0, "no queries logged")
require.Positive(t, qc, "no queries logged")
}
}

Expand Down
2 changes: 1 addition & 1 deletion scripts/golangci-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,4 @@ jobs:
- name: Lint
uses: golangci/golangci-lint-action@9d1e0624a798bb64f6c3cea93db47765312263dc # v5.1.0
with:
version: v1.56.2
version: v1.59.0
2 changes: 1 addition & 1 deletion tsdb/chunks/queue_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ func (q *writeJobQueue) assertInvariants(t *testing.T) {
require.Len(t, s.segment, s.nextWrite)
}
// Last segment must have at least one element, or we wouldn't have created it.
require.Greater(t, s.nextWrite, 0)
require.Positive(t, s.nextWrite)
}

require.Equal(t, q.size, totalSize)
Expand Down
10 changes: 5 additions & 5 deletions tsdb/db_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4574,7 +4574,7 @@ func TestOOOCompaction(t *testing.T) {
ms, created, err := db.head.getOrCreate(lbls.Hash(), lbls)
require.NoError(t, err)
require.False(t, created)
require.Greater(t, ms.ooo.oooHeadChunk.chunk.NumSamples(), 0)
require.Positive(t, ms.ooo.oooHeadChunk.chunk.NumSamples())
require.Len(t, ms.ooo.oooMmappedChunks, 14) // 7 original, 7 duplicate.
}
checkNonEmptyOOOChunk(series1)
Expand Down Expand Up @@ -4715,7 +4715,7 @@ func TestOOOCompactionWithNormalCompaction(t *testing.T) {
ms, created, err := db.head.getOrCreate(lbls.Hash(), lbls)
require.NoError(t, err)
require.False(t, created)
require.Greater(t, ms.ooo.oooHeadChunk.chunk.NumSamples(), 0)
require.Positive(t, ms.ooo.oooHeadChunk.chunk.NumSamples())
}

// If the normal Head is not compacted, the OOO head compaction does not take place.
Expand Down Expand Up @@ -4816,7 +4816,7 @@ func TestOOOCompactionWithDisabledWriteLog(t *testing.T) {
ms, created, err := db.head.getOrCreate(lbls.Hash(), lbls)
require.NoError(t, err)
require.False(t, created)
require.Greater(t, ms.ooo.oooHeadChunk.chunk.NumSamples(), 0)
require.Positive(t, ms.ooo.oooHeadChunk.chunk.NumSamples())
}

// If the normal Head is not compacted, the OOO head compaction does not take place.
Expand Down Expand Up @@ -5517,8 +5517,8 @@ func TestWBLAndMmapReplay(t *testing.T) {
addedRecs++
require.NoError(t, newWbl.Log(rec))
}
require.Greater(t, markers, 0)
require.Greater(t, addedRecs, 0)
require.Positive(t, markers)
require.Positive(t, addedRecs)
require.NoError(t, newWbl.Close())
require.NoError(t, sr.Close())
require.NoError(t, os.RemoveAll(wblDir))
Expand Down
4 changes: 2 additions & 2 deletions tsdb/head_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3557,7 +3557,7 @@ func TestHistogramInWALAndMmapChunk(t *testing.T) {
expMmapChunks = append(expMmapChunks, &cpy)
}
expHeadChunkSamples := ms.headChunks.chunk.NumSamples()
require.Greater(t, expHeadChunkSamples, 0)
require.Positive(t, expHeadChunkSamples)

// Series with mix of histograms and float.
s2 := labels.FromStrings("a", "b2")
Expand Down Expand Up @@ -4638,7 +4638,7 @@ func TestChunkSnapshotTakenAfterIncompleteSnapshot(t *testing.T) {
require.NoError(t, err)
require.NotEqual(t, "", name)
require.Equal(t, 0, idx)
require.Greater(t, offset, 0)
require.Positive(t, offset)
}

// TestWBLReplay checks the replay at a low level.
Expand Down
2 changes: 1 addition & 1 deletion tsdb/wlog/checkpoint_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ func TestCheckpoint(t *testing.T) {
require.NoError(t, w.Truncate(107))
require.NoError(t, DeleteCheckpoints(w.Dir(), 106))
require.Equal(t, histogramsInWAL+floatHistogramsInWAL+samplesInWAL, stats.TotalSamples)
require.Greater(t, stats.DroppedSamples, 0)
require.Positive(t, stats.DroppedSamples)

// Only the new checkpoint should be left.
files, err := os.ReadDir(dir)
Expand Down
2 changes: 2 additions & 0 deletions web/api/v1/api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2973,8 +2973,10 @@ func assertAPIError(t *testing.T, got *apiError, exp errorType) {
t.Helper()

if exp == errorNone {
//nolint:testifylint
require.Nil(t, got)
} else {
//nolint:testifylint
require.NotNil(t, got)
require.Equal(t, exp, got.typ, "(%q)", got)
}
Expand Down