Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
- uses: actions/setup-go@d35c59abb061a4a6fb18e82ac0862c26744d6ab5 # v5
- uses: golangci/golangci-lint-action@2226d7cb06a077cd73e56eedd38eecad18e5d837 # v6.5.0
- uses: golangci/golangci-lint-action@4afd733a84b1f43292c63897423277bb7f4313a9 # v8.0.0
- name: Run tests with Coverage
run: make coverage
- name: Upload Code Coverage
Expand Down
180 changes: 97 additions & 83 deletions .golangci.yaml
Original file line number Diff line number Diff line change
@@ -1,87 +1,101 @@
run:
timeout: 10m
version: "2"
linters:
enable:
- asciicheck
- dogsled
- durationcheck
- exhaustive
- copyloopvar
- gci
- goconst
- gofmt
- gofumpt
- goimports
- gomodguard
- gosec
- govet
- importas
- lll
- gosimple
- staticcheck
- unused
- misspell
- nakedret
- nilerr
- nolintlint
- predeclared
- revive
- stylecheck
- unconvert
- unparam
- wastedassign
- errorlint
- testifylint
issues:
max-same-issues: 0
exclude-rules:
- linters:
- gosec
text: "weak cryptographic primitive"
path: "state/indexers/md5Indexer.*"
- linters:
- asciicheck
- copyloopvar
- dogsled
- durationcheck
- errorlint
- exhaustive
- goconst
- gomodguard
- gosec
text: "weak random number generator"
path: _test\.go
- linters:
- errcheck
text: "Error return value" # ignore err not checked in test files
path: _test\.go
- linters:
- gosec
text: "Expect WriteFile permissions to be 0600 or less"
path: file/codegen/main.go
# ignore unused warnings in test utils files
- linters:
- unused
- unparam
path: test_.*
# ignore SA1019 deprecation warning
- linters:
- importas
- lll
- misspell
- nakedret
- nilerr
- nolintlint
- predeclared
- revive
- staticcheck
text: "SA1019.*"

linters-settings:
goconst:
min-occurrences: 10
gomodguard:
blocked:
modules:
- github.com/ghodss/yaml:
recommendations:
- sigs.k8s.io/yaml
- gopkg.in/yaml.v2:
recommendations:
- sigs.k8s.io/yaml
- gopkg.in/yaml.v3:
recommendations:
- sigs.k8s.io/yaml
- github.com/pkg/errors:
recommendations:
- fmt
- errors
- golang.org/x/net/context:
recommendations:
- context
testifylint:
enable-all: true
- testifylint
- unconvert
- unparam
- wastedassign
settings:
goconst:
min-occurrences: 10
gomodguard:
blocked:
modules:
- github.com/ghodss/yaml:
recommendations:
- sigs.k8s.io/yaml
- gopkg.in/yaml.v2:
recommendations:
- sigs.k8s.io/yaml
- gopkg.in/yaml.v3:
recommendations:
- sigs.k8s.io/yaml
- github.com/pkg/errors:
recommendations:
- fmt
- errors
- golang.org/x/net/context:
recommendations:
- context
testifylint:
enable-all: true
exclusions:
generated: lax
presets:
- comments
- common-false-positives
- legacy
- std-error-handling
rules:
- linters:
- gosec
path: state/indexers/md5Indexer.*
text: weak cryptographic primitive
- linters:
- gosec
path: _test\.go
text: weak random number generator
- linters:
- errcheck
path: _test\.go
text: Error return value
- linters:
- gosec
path: file/codegen/main.go
text: Expect WriteFile permissions to be 0600 or less
- linters:
- unparam
- unused
path: test_.*
- linters:
- staticcheck
text: SA1019.*
- linters:
- staticcheck
text: "QF1008: could remove embedded field.*"
paths:
- third_party$
- builtin$
- examples$
issues:
max-same-issues: 0
formatters:
enable:
- gci
- gofmt
- gofumpt
- goimports
exclusions:
generated: lax
paths:
- third_party$
- builtin$
- examples$
2 changes: 1 addition & 1 deletion pkg/crud/types_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ func TestOpString(t *testing.T) {
op := Op{"foo"}
var op2 Op
assert.Equal("foo", op.String())
assert.Equal("", op2.String())
assert.Empty(op2.String())
}

func TestActionError(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion pkg/diff/diff_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ func parseDeckEnvVars() []EnvVar {

func MaskEnvVarValue(diffString string) string {
for _, envVar := range parseDeckEnvVars() {
diffString = strings.Replace(diffString, envVar.Value, "[masked]", -1)
diffString = strings.ReplaceAll(diffString, envVar.Value, "[masked]")
}
return diffString
}
2 changes: 1 addition & 1 deletion pkg/file/template.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ func toFloatMocked(_ string) (float64, error) {

func indent(spaces int, v string) string {
pad := strings.Repeat(" ", spaces)
return strings.Replace(v, "\n", "\n"+pad, -1)
return strings.ReplaceAll(v, "\n", "\n"+pad)
}

func renderTemplate(content string, mockEnvVars bool) (string, error) {
Expand Down
2 changes: 1 addition & 1 deletion pkg/state/consumer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -181,5 +181,5 @@ func TestConsumerGetAll(t *testing.T) {
allConsumers, err := collection.GetAll()

require.NoError(t, err)
assert.Equal(len(consumers), len(allConsumers))
assert.Len(allConsumers, len(consumers))
}
2 changes: 1 addition & 1 deletion pkg/state/plugin_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -615,7 +615,7 @@ func TestPluginGetAll(t *testing.T) {

allPlugins, err := collection.GetAll()
require.NoError(t, err)
assert.Equal(len(plugins), len(allPlugins))
assert.Len(allPlugins, len(plugins))

allPlugins, err = collection.GetAllByName("")
require.Error(t, err)
Expand Down
4 changes: 2 additions & 2 deletions pkg/state/service_package_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ func TestServicePackageGetAll(t *testing.T) {
allServices, err := collection.GetAll()

require.NoError(t, err)
assert.Equal(len(services), len(allServices))
assert.Len(allServices, len(services))
}

// Regression test
Expand Down Expand Up @@ -377,7 +377,7 @@ func TestServicePackagesGetAllMemoryReference(t *testing.T) {

allServices, err := collection.GetAll()
require.NoError(t, err)
assert.Equal(len(services), len(allServices))
assert.Len(allServices, len(services))

allServices[0].Description = kong.String("new-service1-desc")
allServices[1].Description = kong.String("new-service2-desc")
Expand Down
4 changes: 2 additions & 2 deletions pkg/state/service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,7 @@ func TestServiceGetAll(t *testing.T) {
allServices, err := collection.GetAll()

require.NoError(t, err)
assert.Equal(len(services), len(allServices))
assert.Len(allServices, len(services))
}

// Regression test
Expand Down Expand Up @@ -434,7 +434,7 @@ func TestServiceGetAllMemoryReference(t *testing.T) {

allServices, err := collection.GetAll()
require.NoError(t, err)
assert.Equal(len(services), len(allServices))
assert.Len(allServices, len(services))

allServices[0].Host = kong.String("new.example.com")
allServices[1].Host = kong.String("new.example.com")
Expand Down
3 changes: 1 addition & 2 deletions tests/integration/test_utils.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
//nolint:deadcode
package integration

import (
Expand Down Expand Up @@ -438,7 +437,7 @@ func mustResetKongState(ctx context.Context, t *testing.T, client *kong.Client,
require.NoError(t, err, "failed to create syncer")

_, errs, _ := sc.Solve(ctx, 1, false, false)
require.Empty(t, errs, 0, "failed to apply diffs to Kong: %d errors occurred", len(errs))
require.Empty(t, errs, "failed to apply diffs to Kong: %d errors occurred", len(errs))
}

func stateFromFile(
Expand Down
Loading