CI: bump lint version and update configuration (#2901)
* bump golangci-lint to 1.56 * lint (testifylint) * update lint configuration * windows test: remove stale code
This commit is contained in:
parent
b63e64ee9f
commit
dd71f0a866
2
.github/workflows/go-tests-windows.yml
vendored
2
.github/workflows/go-tests-windows.yml
vendored
|
@ -56,7 +56,7 @@ jobs:
|
||||||
- name: golangci-lint
|
- name: golangci-lint
|
||||||
uses: golangci/golangci-lint-action@v4
|
uses: golangci/golangci-lint-action@v4
|
||||||
with:
|
with:
|
||||||
version: v1.55
|
version: v1.56
|
||||||
args: --issues-exit-code=1 --timeout 10m
|
args: --issues-exit-code=1 --timeout 10m
|
||||||
only-new-issues: false
|
only-new-issues: false
|
||||||
# the cache is already managed above, enabling it here
|
# the cache is already managed above, enabling it here
|
||||||
|
|
2
.github/workflows/go-tests.yml
vendored
2
.github/workflows/go-tests.yml
vendored
|
@ -157,7 +157,7 @@ jobs:
|
||||||
- name: golangci-lint
|
- name: golangci-lint
|
||||||
uses: golangci/golangci-lint-action@v4
|
uses: golangci/golangci-lint-action@v4
|
||||||
with:
|
with:
|
||||||
version: v1.55
|
version: v1.56
|
||||||
args: --issues-exit-code=1 --timeout 10m
|
args: --issues-exit-code=1 --timeout 10m
|
||||||
only-new-issues: false
|
only-new-issues: false
|
||||||
# the cache is already managed above, enabling it here
|
# the cache is already managed above, enabling it here
|
||||||
|
|
|
@ -4,7 +4,6 @@ run:
|
||||||
skip-dirs:
|
skip-dirs:
|
||||||
- pkg/time/rate
|
- pkg/time/rate
|
||||||
skip-files:
|
skip-files:
|
||||||
- pkg/database/ent/generate.go
|
|
||||||
- pkg/yamlpatch/merge.go
|
- pkg/yamlpatch/merge.go
|
||||||
- pkg/yamlpatch/merge_test.go
|
- pkg/yamlpatch/merge_test.go
|
||||||
|
|
||||||
|
@ -32,17 +31,31 @@ linters-settings:
|
||||||
# Checks the number of lines in a function.
|
# Checks the number of lines in a function.
|
||||||
# If lower than 0, disable the check.
|
# If lower than 0, disable the check.
|
||||||
# Default: 60
|
# Default: 60
|
||||||
lines: -1
|
# lower this after refactoring
|
||||||
|
lines: 437
|
||||||
# Checks the number of statements in a function.
|
# Checks the number of statements in a function.
|
||||||
# If lower than 0, disable the check.
|
# If lower than 0, disable the check.
|
||||||
# Default: 40
|
# Default: 40
|
||||||
statements: -1
|
# lower this after refactoring
|
||||||
|
statements: 122
|
||||||
|
|
||||||
govet:
|
govet:
|
||||||
check-shadowing: true
|
check-shadowing: true
|
||||||
|
enable:
|
||||||
|
- atomicalign
|
||||||
|
- deepequalerrors
|
||||||
|
# TODO: - fieldalignment
|
||||||
|
- findcall
|
||||||
|
- nilness
|
||||||
|
# TODO: - reflectvaluecompare
|
||||||
|
- shadow
|
||||||
|
- sortslice
|
||||||
|
- timeformat
|
||||||
|
- unusedwrite
|
||||||
|
|
||||||
lll:
|
lll:
|
||||||
line-length: 140
|
# lower this after refactoring
|
||||||
|
line-length: 2607
|
||||||
|
|
||||||
maintidx:
|
maintidx:
|
||||||
# raise this after refactoring
|
# raise this after refactoring
|
||||||
|
@ -68,10 +81,16 @@ linters-settings:
|
||||||
|
|
||||||
depguard:
|
depguard:
|
||||||
rules:
|
rules:
|
||||||
main:
|
wrap:
|
||||||
deny:
|
deny:
|
||||||
- pkg: "github.com/pkg/errors"
|
- pkg: "github.com/pkg/errors"
|
||||||
desc: "errors.Wrap() is deprecated in favor of fmt.Errorf()"
|
desc: "errors.Wrap() is deprecated in favor of fmt.Errorf()"
|
||||||
|
files:
|
||||||
|
- "!**/pkg/database/*.go"
|
||||||
|
- "!**/pkg/exprhelpers/*.go"
|
||||||
|
- "!**/pkg/acquisition/modules/appsec/appsec.go"
|
||||||
|
- "!**/pkg/acquisition/modules/loki/internal/lokiclient/loki_client.go"
|
||||||
|
- "!**/pkg/apiserver/controllers/v1/errors.go"
|
||||||
yaml:
|
yaml:
|
||||||
files:
|
files:
|
||||||
- "!**/cmd/crowdsec-cli/alerts.go"
|
- "!**/cmd/crowdsec-cli/alerts.go"
|
||||||
|
@ -105,7 +124,6 @@ linters-settings:
|
||||||
- "!**/pkg/appsec/loader.go"
|
- "!**/pkg/appsec/loader.go"
|
||||||
- "!**/pkg/csplugin/broker.go"
|
- "!**/pkg/csplugin/broker.go"
|
||||||
- "!**/pkg/csplugin/broker_test.go"
|
- "!**/pkg/csplugin/broker_test.go"
|
||||||
- "!**/pkg/dumps/bucker_dump.go"
|
|
||||||
- "!**/pkg/dumps/bucket_dump.go"
|
- "!**/pkg/dumps/bucket_dump.go"
|
||||||
- "!**/pkg/dumps/parser_dump.go"
|
- "!**/pkg/dumps/parser_dump.go"
|
||||||
- "!**/pkg/hubtest/coverage.go"
|
- "!**/pkg/hubtest/coverage.go"
|
||||||
|
@ -177,6 +195,7 @@ linters:
|
||||||
# - importas # Enforces consistent import aliases
|
# - importas # Enforces consistent import aliases
|
||||||
# - ineffassign # Detects when assignments to existing variables are not used
|
# - ineffassign # Detects when assignments to existing variables are not used
|
||||||
# - interfacebloat # A linter that checks the number of methods inside an interface.
|
# - interfacebloat # A linter that checks the number of methods inside an interface.
|
||||||
|
# - lll # Reports long lines
|
||||||
# - logrlint # Check logr arguments.
|
# - logrlint # Check logr arguments.
|
||||||
# - maintidx # maintidx measures the maintainability index of each function.
|
# - maintidx # maintidx measures the maintainability index of each function.
|
||||||
# - makezero # Finds slice declarations with non-zero initial length
|
# - makezero # Finds slice declarations with non-zero initial length
|
||||||
|
@ -214,7 +233,6 @@ linters:
|
||||||
- goimports # In addition to fixing imports, goimports also formats your code in the same style as gofmt.
|
- goimports # In addition to fixing imports, goimports also formats your code in the same style as gofmt.
|
||||||
- gosec # (gas): Inspects source code for security problems
|
- gosec # (gas): Inspects source code for security problems
|
||||||
- inamedparam # reports interfaces with unnamed method parameters
|
- inamedparam # reports interfaces with unnamed method parameters
|
||||||
- lll # Reports long lines
|
|
||||||
- musttag # enforce field tags in (un)marshaled structs
|
- musttag # enforce field tags in (un)marshaled structs
|
||||||
- promlinter # Check Prometheus metrics naming via promlint
|
- promlinter # Check Prometheus metrics naming via promlint
|
||||||
- protogetter # Reports direct reads from proto message fields when getters should be used
|
- protogetter # Reports direct reads from proto message fields when getters should be used
|
||||||
|
@ -363,13 +381,3 @@ issues:
|
||||||
- linters:
|
- linters:
|
||||||
- nonamedreturns
|
- nonamedreturns
|
||||||
text: "named return .* with type .* found"
|
text: "named return .* with type .* found"
|
||||||
|
|
||||||
#
|
|
||||||
# Will fix, might be trickier
|
|
||||||
#
|
|
||||||
|
|
||||||
# https://github.com/pkg/errors/issues/245
|
|
||||||
- linters:
|
|
||||||
- depguard
|
|
||||||
text: "import 'github.com/pkg/errors' is not allowed .*"
|
|
||||||
|
|
||||||
|
|
|
@ -6,13 +6,13 @@ https://grafana.com/docs/loki/latest/api/#get-lokiapiv1tail
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/url"
|
"net/url"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/pkg/errors"
|
|
||||||
"github.com/prometheus/client_golang/prometheus"
|
"github.com/prometheus/client_golang/prometheus"
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
tomb "gopkg.in/tomb.v2"
|
tomb "gopkg.in/tomb.v2"
|
||||||
|
|
|
@ -151,7 +151,7 @@ func TestCreateAlertChannels(t *testing.T) {
|
||||||
wg.Done()
|
wg.Done()
|
||||||
}()
|
}()
|
||||||
|
|
||||||
go lapi.InsertAlertFromFile(t, "./tests/alert_ssh-bf.json")
|
lapi.InsertAlertFromFile(t, "./tests/alert_ssh-bf.json")
|
||||||
wg.Wait()
|
wg.Wait()
|
||||||
assert.Len(t, pd.Alert.Decisions, 1)
|
assert.Len(t, pd.Alert.Decisions, 1)
|
||||||
apiServer.Close()
|
apiServer.Close()
|
||||||
|
|
|
@ -100,10 +100,6 @@ func CheckPerms(path string) error {
|
||||||
return fmt.Errorf("no DACL found on plugin, meaning fully permissive access on plugin %s", path)
|
return fmt.Errorf("no DACL found on plugin, meaning fully permissive access on plugin %s", path)
|
||||||
}
|
}
|
||||||
|
|
||||||
if err != nil {
|
|
||||||
return fmt.Errorf("while looking up current user sid: %w", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
rs := reflect.ValueOf(dacl).Elem()
|
rs := reflect.ValueOf(dacl).Elem()
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -118,7 +118,7 @@ func TestNillClient(t *testing.T) {
|
||||||
|
|
||||||
item, err := CrowdsecCTI("1.2.3.4")
|
item, err := CrowdsecCTI("1.2.3.4")
|
||||||
assert.Equal(t, err, cticlient.ErrDisabled)
|
assert.Equal(t, err, cticlient.ErrDisabled)
|
||||||
assert.Equal(t, item, &cticlient.SmokeItem{})
|
assert.Equal(t, &cticlient.SmokeItem{}, item)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestInvalidAuth(t *testing.T) {
|
func TestInvalidAuth(t *testing.T) {
|
||||||
|
@ -133,7 +133,7 @@ func TestInvalidAuth(t *testing.T) {
|
||||||
}))
|
}))
|
||||||
|
|
||||||
item, err := CrowdsecCTI("1.2.3.4")
|
item, err := CrowdsecCTI("1.2.3.4")
|
||||||
assert.Equal(t, item, &cticlient.SmokeItem{})
|
assert.Equal(t, &cticlient.SmokeItem{}, item)
|
||||||
assert.False(t, CTIApiEnabled)
|
assert.False(t, CTIApiEnabled)
|
||||||
assert.Equal(t, err, cticlient.ErrUnauthorized)
|
assert.Equal(t, err, cticlient.ErrUnauthorized)
|
||||||
|
|
||||||
|
@ -143,7 +143,7 @@ func TestInvalidAuth(t *testing.T) {
|
||||||
}))
|
}))
|
||||||
|
|
||||||
item, err = CrowdsecCTI("1.2.3.4")
|
item, err = CrowdsecCTI("1.2.3.4")
|
||||||
assert.Equal(t, item, &cticlient.SmokeItem{})
|
assert.Equal(t, &cticlient.SmokeItem{}, item)
|
||||||
assert.False(t, CTIApiEnabled)
|
assert.False(t, CTIApiEnabled)
|
||||||
assert.Equal(t, err, cticlient.ErrDisabled)
|
assert.Equal(t, err, cticlient.ErrDisabled)
|
||||||
}
|
}
|
||||||
|
@ -159,7 +159,7 @@ func TestNoKey(t *testing.T) {
|
||||||
}))
|
}))
|
||||||
|
|
||||||
item, err := CrowdsecCTI("1.2.3.4")
|
item, err := CrowdsecCTI("1.2.3.4")
|
||||||
assert.Equal(t, item, &cticlient.SmokeItem{})
|
assert.Equal(t, &cticlient.SmokeItem{}, item)
|
||||||
assert.False(t, CTIApiEnabled)
|
assert.False(t, CTIApiEnabled)
|
||||||
assert.Equal(t, err, cticlient.ErrDisabled)
|
assert.Equal(t, err, cticlient.ErrDisabled)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue