Skip to content

Commit

Permalink
Merge pull request #3091 from IBM/dnwe/staticcheck
Browse files Browse the repository at this point in the history
feat(ci): add dedicated staticcheck run
  • Loading branch information
dnwe authored Feb 4, 2025
2 parents 865737e + b3aef99 commit 9ae475a
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 17 deletions.
16 changes: 16 additions & 0 deletions .github/actions/staticcheck-matchers.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"problemMatcher": [
{
"owner": "staticcheck",
"pattern": [
{
"regexp": "^\\s*(.+\\.go):(?:(\\d+):(\\d+):)? (.*)",
"file": 1,
"line": 2,
"column": 3,
"message": 4
}
]
}
]
}
9 changes: 9 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,15 @@ jobs:
uses: actions/setup-go@f111f3307d8850f501ac008e886eec1fd1932a34 # v5.3.0
with:
go-version: ${{ matrix.go-version }}
- name: Staticcheck
shell: bash
env:
BUILDTAGS: "functional"
VERSION: "v0.5.1"
run: |
go install "honnef.co/go/tools/cmd/staticcheck@${VERSION}"
echo "::add-matcher::./.github/actions/staticcheck-matchers.json"
$(go env GOPATH)/bin/staticcheck -tags "${BUILDTAGS}" ./...
- name: golangci-lint
env:
GOFLAGS: -tags=functional
Expand Down
12 changes: 5 additions & 7 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
# yaml-language-server: $schema=https://golangci-lint.run/jsonschema/golangci.jsonschema.json
run:
timeout: 5m
deadline: 10m

linters-settings:
govet:
shadow: false
golint:
min-confidence: 0
enable-all: true
disable:
- fieldalignment
- shadow
gocyclo:
min-complexity: 99
maligned:
suggest-new: true
dupl:
threshold: 100
goconst:
Expand Down Expand Up @@ -71,7 +70,6 @@ linters:
- govet
- misspell
- nilerr
- staticcheck
- typecheck
- unconvert
- unused
Expand Down
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ repos:
files: \.go$
args: []
- repo: https://github.com/gitleaks/gitleaks
rev: v8.21.2
rev: v8.23.3
hooks:
- id: gitleaks
- repo: https://github.com/golangci/golangci-lint
rev: v1.61.0
rev: v1.63.4
hooks:
- id: golangci-lint
10 changes: 5 additions & 5 deletions balance_strategy.go
Original file line number Diff line number Diff line change
Expand Up @@ -989,7 +989,7 @@ func (p *partitionMovements) getTheActualPartitionToBeMoved(partition topicParti
return reversePairPartition
}

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

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

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

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

//nolint:unused // this is used but only in unittests as a helper (which are excluded by the integration build tag)
//lint:ignore U1000 // this is used but only in unittests as a helper (which are excluded by the integration build tag)
func indexOfSubList(source []string, target []string) int {
targetSize := len(target)
maxCandidate := len(source) - targetSize
Expand Down
2 changes: 1 addition & 1 deletion metrics_helpers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ func minCountHistogramValidator(name string, minCount int) *metricValidator {
})
}

//nolint:unused // this is used but only in unittests which are excluded by the integration build tag
//lint:ignore U1000 // this is used but only in unittests which are excluded by the integration build tag
func minMaxHistogramValidator(name string, expectedMin int, expectedMax int) *metricValidator {
return histogramValidator(name, func(t *testing.T, histogram metrics.Histogram) {
t.Helper()
Expand Down
4 changes: 2 additions & 2 deletions mocks/mocks.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ func messageValueChecker(f ValueChecker) MessageChecker {

var (
errProduceSuccess error = nil
errOutOfExpectations = errors.New("No more expectations set on mock")
errPartitionConsumerNotStarted = errors.New("The partition consumer was never started")
errOutOfExpectations = errors.New("no more expectations set on mock")
errPartitionConsumerNotStarted = errors.New("the partition consumer was never started")
)

const AnyOffset int64 = -1000
Expand Down

0 comments on commit 9ae475a

Please sign in to comment.