Skip to content

Commit 9ae475a

Browse files
authored
Merge pull request #3091 from IBM/dnwe/staticcheck
feat(ci): add dedicated staticcheck run
2 parents 865737e + b3aef99 commit 9ae475a

7 files changed

+40
-17
lines changed
+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"problemMatcher": [
3+
{
4+
"owner": "staticcheck",
5+
"pattern": [
6+
{
7+
"regexp": "^\\s*(.+\\.go):(?:(\\d+):(\\d+):)? (.*)",
8+
"file": 1,
9+
"line": 2,
10+
"column": 3,
11+
"message": 4
12+
}
13+
]
14+
}
15+
]
16+
}

.github/workflows/ci.yml

+9
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,15 @@ jobs:
3434
uses: actions/setup-go@f111f3307d8850f501ac008e886eec1fd1932a34 # v5.3.0
3535
with:
3636
go-version: ${{ matrix.go-version }}
37+
- name: Staticcheck
38+
shell: bash
39+
env:
40+
BUILDTAGS: "functional"
41+
VERSION: "v0.5.1"
42+
run: |
43+
go install "honnef.co/go/tools/cmd/staticcheck@${VERSION}"
44+
echo "::add-matcher::./.github/actions/staticcheck-matchers.json"
45+
$(go env GOPATH)/bin/staticcheck -tags "${BUILDTAGS}" ./...
3746
- name: golangci-lint
3847
env:
3948
GOFLAGS: -tags=functional

.golangci.yml

+5-7
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
1+
# yaml-language-server: $schema=https://golangci-lint.run/jsonschema/golangci.jsonschema.json
12
run:
23
timeout: 5m
3-
deadline: 10m
44

55
linters-settings:
66
govet:
7-
shadow: false
8-
golint:
9-
min-confidence: 0
7+
enable-all: true
8+
disable:
9+
- fieldalignment
10+
- shadow
1011
gocyclo:
1112
min-complexity: 99
12-
maligned:
13-
suggest-new: true
1413
dupl:
1514
threshold: 100
1615
goconst:
@@ -71,7 +70,6 @@ linters:
7170
- govet
7271
- misspell
7372
- nilerr
74-
- staticcheck
7573
- typecheck
7674
- unconvert
7775
- unused

.pre-commit-config.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,10 @@ repos:
3232
files: \.go$
3333
args: []
3434
- repo: https://github.com/gitleaks/gitleaks
35-
rev: v8.21.2
35+
rev: v8.23.3
3636
hooks:
3737
- id: gitleaks
3838
- repo: https://github.com/golangci/golangci-lint
39-
rev: v1.61.0
39+
rev: v1.63.4
4040
hooks:
4141
- id: golangci-lint

balance_strategy.go

+5-5
Original file line numberDiff line numberDiff line change
@@ -989,7 +989,7 @@ func (p *partitionMovements) getTheActualPartitionToBeMoved(partition topicParti
989989
return reversePairPartition
990990
}
991991

992-
//nolint:unused // this is used but only in unittests as a helper (which are excluded by the integration build tag)
992+
//lint:ignore U1000 // this is used but only in unittests as a helper (which are excluded by the integration build tag)
993993
func (p *partitionMovements) isLinked(src, dst string, pairs []consumerPair, currentPath []string) ([]string, bool) {
994994
if src == dst {
995995
return currentPath, false
@@ -1024,7 +1024,7 @@ func (p *partitionMovements) isLinked(src, dst string, pairs []consumerPair, cur
10241024
return currentPath, false
10251025
}
10261026

1027-
//nolint:unused // this is used but only in unittests as a helper (which are excluded by the integration build tag)
1027+
//lint:ignore U1000 // this is used but only in unittests as a helper (which are excluded by the integration build tag)
10281028
func (p *partitionMovements) in(cycle []string, cycles [][]string) bool {
10291029
superCycle := make([]string, len(cycle)-1)
10301030
for i := 0; i < len(cycle)-1; i++ {
@@ -1039,7 +1039,7 @@ func (p *partitionMovements) in(cycle []string, cycles [][]string) bool {
10391039
return false
10401040
}
10411041

1042-
//nolint:unused // this is used but only in unittests as a helper (which are excluded by the integration build tag)
1042+
//lint:ignore U1000 // this is used but only in unittests as a helper (which are excluded by the integration build tag)
10431043
func (p *partitionMovements) hasCycles(pairs []consumerPair) bool {
10441044
cycles := make([][]string, 0)
10451045
for _, pair := range pairs {
@@ -1071,7 +1071,7 @@ func (p *partitionMovements) hasCycles(pairs []consumerPair) bool {
10711071
return false
10721072
}
10731073

1074-
//nolint:unused // this is used but only in unittests as a helper (which are excluded by the integration build tag)
1074+
//lint:ignore U1000 // this is used but only in unittests as a helper (which are excluded by the integration build tag)
10751075
func (p *partitionMovements) isSticky() bool {
10761076
for topic, movements := range p.PartitionMovementsByTopic {
10771077
movementPairs := make([]consumerPair, len(movements))
@@ -1089,7 +1089,7 @@ func (p *partitionMovements) isSticky() bool {
10891089
return true
10901090
}
10911091

1092-
//nolint:unused // this is used but only in unittests as a helper (which are excluded by the integration build tag)
1092+
//lint:ignore U1000 // this is used but only in unittests as a helper (which are excluded by the integration build tag)
10931093
func indexOfSubList(source []string, target []string) int {
10941094
targetSize := len(target)
10951095
maxCandidate := len(source) - targetSize

metrics_helpers_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ func minCountHistogramValidator(name string, minCount int) *metricValidator {
116116
})
117117
}
118118

119-
//nolint:unused // this is used but only in unittests which are excluded by the integration build tag
119+
//lint:ignore U1000 // this is used but only in unittests which are excluded by the integration build tag
120120
func minMaxHistogramValidator(name string, expectedMin int, expectedMax int) *metricValidator {
121121
return histogramValidator(name, func(t *testing.T, histogram metrics.Histogram) {
122122
t.Helper()

mocks/mocks.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@ func messageValueChecker(f ValueChecker) MessageChecker {
5252

5353
var (
5454
errProduceSuccess error = nil
55-
errOutOfExpectations = errors.New("No more expectations set on mock")
56-
errPartitionConsumerNotStarted = errors.New("The partition consumer was never started")
55+
errOutOfExpectations = errors.New("no more expectations set on mock")
56+
errPartitionConsumerNotStarted = errors.New("the partition consumer was never started")
5757
)
5858

5959
const AnyOffset int64 = -1000

0 commit comments

Comments
 (0)