Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,18 @@ jobs:
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v5
- uses: actions/setup-go@v5
with:
go-version: "1.21"
cache: false
- name: golangci-lint
uses: golangci/golangci-lint-action@v4
uses: golangci/golangci-lint-action@v8
with:
# Require: The version of golangci-lint to use.
# When `install-mode` is `binary` (default) the value can be v1.2 or v1.2.3 or `latest` to use the latest version.
# When `install-mode` is `goinstall` the value can be v1.2.3, `latest`, or the hash of a commit.
version: v1.64.4
version: v2.3.1

check-license:
name: License scan
Expand Down
100 changes: 52 additions & 48 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,77 +1,81 @@
version: "2"
run:
# default concurrency is a available CPU number
concurrency: 4

# timeout for analysis, e.g. 30s, 5m, default is 1m
timeout: 5m

# exit code when at least one issue was found, default is 1
issues-exit-code: 1

# include test files or not, default is true
tests: true

linters-settings:
depguard:
rules:
main:
list-mode: lax
allow:
- $gostd
- github.com/stackvista
lll:
line-length: 250
mnd:
checks:
- argument
- case
- condition
- return

nolintlint:
allow-unused: true # report any unused nolint directives
require-specific: true # don't require nolint directives to be specific about which linter is being skipped

stylecheck:

funlen:
lines: 100
statements: 60

linters:
disable-all: true
default: none
enable:
# - bodyclose TODO: enable when fixed
# - depguard
- copyloopvar
- dogsled
- dupl
- errcheck
- exhaustive
- copyloopvar
- funlen
- gochecknoinits
- goconst
- gocritic
- gocyclo
- gofmt
- goimports
- mnd
- goprintffuncname
# - gosec TODO: enable when fixed
- gosimple
- govet
- ineffassign
- lll
- misspell
- mnd
- nakedret
- noctx
- nolintlint
# - revive TODO: enable when fixed
- rowserrcheck
- staticcheck
# - stylecheck TODO: enable when fixed
- typecheck
- unconvert
- unparam
- unused
- whitespace
# - gosec TODO: enable when fixed
# - bodyclose TODO: enable when fixed
# - depguard
# - revive TODO: enable when fixed
# - stylecheck TODO: enable when fixed
settings:
depguard:
rules:
main:
list-mode: lax
allow:
- $gostd
- github.com/stackvista
funlen:
lines: 100
statements: 60
lll:
line-length: 250
mnd:
checks:
- argument
- case
- condition
- return
nolintlint:
require-specific: true
allow-unused: true
exclusions:
generated: lax
presets:
- comments
- common-false-positives
- legacy
- std-error-handling
paths:
- third_party$
- builtin$
- examples$
formatters:
enable:
- gofmt
- goimports
exclusions:
generated: lax
paths:
- third_party$
- builtin$
- examples$
18 changes: 9 additions & 9 deletions cmd/dashboard/dashboard_edit_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ func TestShouldEditDashboard(t *testing.T) {
"scope": "privateDashboard"
}`),
}
cli.Deps.Editor = mockEditor
cli.Editor = mockEditor

di.ExecuteCommandWithContextUnsafe(&cli.Deps, cmd, "--id", "1234")

Expand Down Expand Up @@ -136,7 +136,7 @@ func TestShouldEditDashboardWithIdentifier(t *testing.T) {
"description": "Updated via identifier"
}`),
}
cli.Deps.Editor = mockEditor
cli.Editor = mockEditor

di.ExecuteCommandWithContextUnsafe(&cli.Deps, cmd, "--identifier", "urn:custom:dashboard:edit-test")

Expand All @@ -153,7 +153,7 @@ func TestEditDashboardNoChanges(t *testing.T) {

// Custom editor that returns exactly the same content as input
noChangeEditor := &NoChangeEditor{}
cli.Deps.Editor = noChangeEditor
cli.Editor = noChangeEditor

di.ExecuteCommandWithContextUnsafe(&cli.Deps, cmd, "--id", "1234")

Expand Down Expand Up @@ -186,7 +186,7 @@ func TestEditDashboardWithJsonOutput(t *testing.T) {
"description": "Testing JSON output"
}`),
}
cli.Deps.Editor = mockEditor
cli.Editor = mockEditor

di.ExecuteCommandWithContextUnsafe(&cli.Deps, cmd, "--id", "1234", "--output", "json")

Expand All @@ -204,7 +204,7 @@ func TestEditDashboardNoChangesJsonOutput(t *testing.T) {

// Use NoChangeEditor that returns exactly the same content
noChangeEditor := &NoChangeEditor{}
cli.Deps.Editor = noChangeEditor
cli.Editor = noChangeEditor

di.ExecuteCommandWithContextUnsafe(&cli.Deps, cmd, "--id", "1234", "--output", "json")

Expand All @@ -223,7 +223,7 @@ func TestEditDashboardInvalidJson(t *testing.T) {
mockEditor := &MockEditor{
Content: []byte(`{"invalid": json syntax}`),
}
cli.Deps.Editor = mockEditor
cli.Editor = mockEditor

_, err := di.ExecuteCommandWithContext(&cli.Deps, cmd, "--id", "1234")

Expand All @@ -242,7 +242,7 @@ func TestEditDashboardEditorError(t *testing.T) {
mockEditor := &MockEditor{
Error: errors.New("editor failed to open"),
}
cli.Deps.Editor = mockEditor
cli.Editor = mockEditor

_, err := di.ExecuteCommandWithContext(&cli.Deps, cmd, "--id", "1234")

Expand Down Expand Up @@ -275,7 +275,7 @@ func TestEditDashboardUsesReverseEditorByDefault(t *testing.T) {
mockEditor := &MockEditor{
Content: []byte(`{"name": "changed-by-reverse-editor"}`),
}
cli.Deps.Editor = mockEditor
cli.Editor = mockEditor

di.ExecuteCommandWithContextUnsafe(&cli.Deps, cmd, "--id", "1234")

Expand Down Expand Up @@ -324,7 +324,7 @@ func TestEditDashboardApiErrors(t *testing.T) {
mockEditor := &MockEditor{
Content: []byte(`{"name": "changed"}`),
}
cli.Deps.Editor = mockEditor
cli.Editor = mockEditor
}

_, err := di.ExecuteCommandWithContext(&cli.Deps, cmd, "--id", "1234")
Expand Down
1 change: 1 addition & 0 deletions cmd/stackpack/stackpack_describe.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ func RunStackpackDescribeCommand(args *DescribeArgs) di.CmdWithApiFn {
}
}

//nolint:staticcheck
notFound := fmt.Errorf("StackPack '%s' not found.", args.Name)
if cli.IsJson() {
cli.Printer.PrintErrJson(notFound)
Expand Down
1 change: 1 addition & 0 deletions cmd/stackpack/stackpack_test_cmd_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -437,6 +437,7 @@ func TestConfirmUpload(t *testing.T) {
// In a real test environment, you'd mock the stdin reader

// Just verify the function signature is correct
//nolint:staticcheck
var confirmFunc func(*di.Deps, string) bool = confirmUpload
assert.NotNil(t, confirmFunc)

Expand Down
Binary file not shown.
2 changes: 1 addition & 1 deletion internal/client/stackstate_version.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,5 +63,5 @@ func CheckVersionCompatibility(version stackstate_api.ServerVersion, minVersion
}

func NewAPIVersionMismatchError(got string, expected string) common.CLIError {
return common.NewAPIVersionError(fmt.Errorf("Incompatible API version: got '%s', but need '%s'-compatible version", got, expected))
return common.NewAPIVersionError(fmt.Errorf("incompatible API version: got '%s', but need '%s'-compatible version", got, expected))
}
4 changes: 2 additions & 2 deletions internal/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ func (c *Config) GetContext(name string) (*NamedContext, common.CLIError) {
}
}

return nil, common.NewNotFoundError(fmt.Errorf("Context with name '%s' not found", name))
return nil, common.NewNotFoundError(fmt.Errorf("context with name '%s' not found", name))
}

// UnmarshalYAML unmarshals the StsContext YAML part into a struct, ensuring that any defaults are set.
Expand Down Expand Up @@ -153,7 +153,7 @@ func (c *StsContext) Validate(contextName string) common.CLIError {

authenticationTokens := util.RemoveEmpty([]string{c.APIToken, c.ServiceToken, c.K8sSAToken})
if len(authenticationTokens) > 1 {
errors = append(errors, fmt.Errorf("Can only specify one of {api-token | service-token | k8s-sa-token}"))
errors = append(errors, fmt.Errorf("can only specify one of {api-token | service-token | k8s-sa-token}"))
}

if c.HasCaCertificateFromArgSet() {
Expand Down
2 changes: 1 addition & 1 deletion internal/config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ current-context: default
assert.NoError(t, err)
assert.ErrorContains(t, c.Contexts[0].Context.Validate(c.Contexts[0].Name), `Failed to validate the 'default' context:
* URL localhost:8080 must start with "https://" or "http://"
* Can only specify one of {api-token | service-token | k8s-sa-token}`)
* can only specify one of {api-token | service-token | k8s-sa-token}`)
}

func TestMergeWithNoTokenOverride(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ func TestExitCodeOnError(t *testing.T) {
main()
return
}
cmd := exec.Command(os.Args[0], "-test.run=TestExitCodeOnError") //nolint:gosec
cmd := exec.Command(os.Args[0], "-test.run=TestExitCodeOnError") //nolint:gosec,noctx
cmd.Env = append(os.Environ(), "BE_CRASHER=1")
err := cmd.Run()
if e, ok := err.(*exec.ExitError); ok && !e.Success() {
Expand Down
2 changes: 1 addition & 1 deletion pkg/pflags/relative_time_flag.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ func (d *RelativeTimeValue) Type() string {
return RelativeTimeFlagType
}

func (d *RelativeTimeValue) String() string { return d.Time.Format(time.RFC3339Nano) }
func (d *RelativeTimeValue) String() string { return d.Format(time.RFC3339Nano) }

// GetRelativeTime return the time value of a flag with the given name
func GetRelativeTime(f *pflag.FlagSet, name string) (time.Time, error) {
Expand Down