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/analyze.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,10 @@ jobs:
with:
go-version: "^1.24"
- name: golangci-lint
uses: golangci/golangci-lint-action@v6
uses: golangci/golangci-lint-action@v7
with:
version: v1.64.5
args: --out-format=sarif:results.sarif,colored-line-number,github-actions
version: v2.1.6
args: --output.sarif.path=results.sarif
- name: Upload SARIF file
uses: github/codeql-action/upload-sarif@v3
with:
Expand Down
203 changes: 108 additions & 95 deletions .golangci.yaml
Original file line number Diff line number Diff line change
@@ -1,99 +1,112 @@
run:
timeout: 2m

linters-settings:
cyclop:
max-complexity: 30
package-average: 10.0
errcheck:
check-type-assertions: true
funlen:
lines: 100
statements: 50
ignore-comments: true
gocognit:
min-complexity: 30
govet:
enable-all: true
disable:
- fieldalignment # too strict

version: "2"
linters:
disable-all: true
default: none
enable:
## enabled by default
- errcheck # checking for unchecked errors, these unchecked errors can be critical bugs in some cases
- gosimple # specializes in simplifying a code
- govet # reports suspicious constructs, such as Printf calls whose arguments do not align with the format string
- ineffassign # detects when assignments to existing variables are not used
- staticcheck # is a go vet on steroids, applying a ton of static analysis checks
- typecheck # like the front-end of a Go compiler, parses and type-checks Go code
- unused # checks for unused constants, variables, functions and types
## disabled by default
- asciicheck # checks that your code does not contain non-ASCII identifiers
- bidichk # checks for dangerous unicode character sequences
- bodyclose # checks whether HTTP response body is closed successfully
- cyclop # checks function and package cyclomatic complexity
- dupl # tool for code clone detection
- durationcheck # checks for two durations multiplied together
- errname # checks that sentinel errors are prefixed with the Err and error types are suffixed with the Error
- errorlint # finds code that will cause problems with the error wrapping scheme introduced in Go 1.13
- funlen # tool for detection of long functions
- gocognit # computes and checks the cognitive complexity of functions
- goconst # finds repeated strings that could be replaced by a constant
- gocritic # provides diagnostics that check for bugs, performance and style issues
- gocyclo # computes and checks the cyclomatic complexity of functions
- goimports # in addition to fixing imports, goimports also formats your code in the same style as gofmt
- gomoddirectives # manages the use of 'replace', 'retract', and 'excludes' directives in go.mod
- gosec # inspects source code for security problems
- lll # reports long lines
- loggercheck # checks key value pairs for common logger libraries (kitlog,klog,logr,zap)
- makezero # finds slice declarations with non-zero initial length
- nakedret # finds naked returns in functions greater than a specified function length
- nestif # reports deeply nested if statements
- nilerr # finds the code that returns nil even if it checks that the error is not nil
- nilnil # checks that there is no simultaneous return of nil error and an invalid value
- noctx # finds sending http request without context.Context
- nolintlint # reports ill-formed or insufficient nolint directives
- nosprintfhostport # checks for misuse of Sprintf to construct a host with port in a URL
- predeclared # finds code that shadows one of Go's predeclared identifiers
- reassign # checks that package variables are not reassigned
- stylecheck # is a replacement for golint
- usetesting # detects when some calls can be replaced by methods from the testing package
- testableexamples # checks if examples are testable (have an expected output)
- testpackage # makes you use a separate _test package
- tparallel # detects inappropriate usage of t.Parallel() method in your Go test codes
- unconvert # removes unnecessary type conversions
- unparam # reports unused function parameters
- usestdlibvars # detects the possibility to use variables/constants from the Go standard library
- wastedassign # finds wasted assignment statements
- whitespace # detects leading and trailing whitespace
- zerologlint # detects the wrong usage of zerolog that a user forgets to dispatch zerolog.Event
- decorder # checks declaration order and count of types, constants, variables and functions
- ginkgolinter # [if you use ginkgo/gomega] enforces standards of using ginkgo and gomega
- interfacebloat # checks the number of methods inside an interface
- tagalign # checks that struct tags are well aligned

- asciicheck
- bidichk
- bodyclose
- cyclop
- decorder
- dupl
- durationcheck
- errcheck
- errname
- errorlint
- funlen
- ginkgolinter
- gocognit
- goconst
- gocritic
- gocyclo
- gomoddirectives
- gosec
- govet
- ineffassign
- interfacebloat
- lll
- loggercheck
- makezero
- nakedret
- nestif
- nilerr
- nilnil
- noctx
- nolintlint
- nosprintfhostport
- predeclared
- reassign
- staticcheck
- tagalign
- testableexamples
- testpackage
- tparallel
- unconvert
- unparam
- unused
- usestdlibvars
- usetesting
- wastedassign
- whitespace
- zerologlint
settings:
cyclop:
max-complexity: 30
package-average: 10
errcheck:
check-type-assertions: true
funlen:
lines: 100
statements: 50
ignore-comments: true
gocognit:
min-complexity: 30
govet:
disable:
- fieldalignment
enable-all: true
exclusions:
generated: lax
presets:
- comments
- common-false-positives
- legacy
- std-error-handling
rules:
- linters:
- godot
source: (noinspection|TODO)
- linters:
- gocritic
source: //noinspection
- linters:
- bodyclose
- dupl
- funlen
- goconst
- gosec
- noctx
- wrapcheck
path: _test\.go
- linters:
- gosec
text: G115
- linters:
- staticcheck
text: SA5011
- path: (.+)\.go$
text: declaration of "(err|ctx)" shadows declaration at
paths:
- third_party$
- builtin$
- examples$
issues:
max-same-issues: 0
exclude:
- 'declaration of "(err|ctx)" shadows declaration at' # shadowing of err and ctx is acceptable
exclude-rules:
- source: "(noinspection|TODO)"
linters: [ godot ]
- source: "//noinspection"
linters: [ gocritic ]
- path: "_test\\.go"
linters:
- bodyclose
- dupl
- funlen
- goconst
- gosec
- noctx
- wrapcheck
- linters: [gosec]
text: "G115"
- linters:
- staticcheck
text: "SA5011" # SA5011: Should not use unsafe.Pointer - this throws false positives when a nil check does not result in a return
formatters:
enable:
- goimports
exclusions:
generated: lax
paths:
- third_party$
- builtin$
- examples$
5 changes: 3 additions & 2 deletions cmd/internal/library.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,10 @@ func libraryFunc(ctx *context.Context, cmd *cobra.Command, _ []string) {
}

wsFilter := flags.ValueFor[string](ctx, cmd, *flags.FilterWorkspaceFlag, false)
if wsFilter == "." {
switch wsFilter {
case ".":
wsFilter = ctx.Config.CurrentWorkspace
} else if wsFilter == executable.WildcardWorkspace {
case executable.WildcardWorkspace:
wsFilter = ""
}

Expand Down
2 changes: 1 addition & 1 deletion development.flow
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ executables:
echo "installing cobra-cli..."
go install github.com/spf13/cobra-cli@v1.3.0
echo "installing golangci-lint..."
go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.64.5
go install github.com/golangci/golangci-lint/cmd/golangci-lint@v2.1.6
echo "installing ginkgo..."
go install github.com/onsi/ginkgo/v2/ginkgo@v2.20.2
echo "installing goreleaser..."
Expand Down
15 changes: 8 additions & 7 deletions internal/io/library/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,14 @@ func (l *Library) setVisibleExecs() {
}

curNs := l.filter.Namespace
if l.showNamespaces && len(l.visibleNamespaces) > 0 { //nolint:nestif
if l.showNamespaces && len(l.visibleNamespaces) > 0 {
if label := l.visibleNamespaces[l.currentNamespace]; label != "" {
if label == withoutNamespaceLabel {
switch label {
case withoutNamespaceLabel:
curNs = ""
} else if label == allNamespacesLabel {
case allNamespacesLabel:
curNs = executable.WildcardNamespace
} else {
default:
curNs = label
}
}
Expand Down Expand Up @@ -89,10 +90,10 @@ func (l *Library) setVisibleWorkspaces() {

filter := l.filter
filteredWs := l.allWorkspaces
switch {
case filter.Workspace == "":
switch filter.Workspace {
case "":
// do nothing
case filter.Workspace == allWorkspacesLabel || filter.Workspace == executable.WildcardWorkspace:
case allWorkspacesLabel, executable.WildcardWorkspace:
// do nothing
default:
for _, ws := range filteredWs {
Expand Down
10 changes: 6 additions & 4 deletions internal/io/library/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,10 @@ func (l *Library) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
wsPane, wsCmd := l.updateWsPane(msg)
l.paneZeroViewport = wsPane
execPane, execCmd := l.updateExecPanes(msg)
if l.currentPane == 1 {
switch l.currentPane {
case 1:
l.paneOneViewport = execPane
} else if l.currentPane == 2 {
case 2:
l.paneTwoViewport = execPane
}

Expand Down Expand Up @@ -190,9 +191,10 @@ func (l *Library) updateExecPanes(msg tea.Msg) (viewport.Model, tea.Cmd) {
}

var pane viewport.Model
if l.currentPane == 1 {
switch l.currentPane {
case 1:
pane = l.paneOneViewport
} else if l.currentPane == 2 {
case 2:
pane = l.paneTwoViewport
}

Expand Down
2 changes: 1 addition & 1 deletion tools/docsgen/schema/schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ func MergeSchemas(dst, src *JSONSchema, dstFile FileName, schemaMap map[FileName

src.Ref = convertToLocalSchemaRef(src.Ref, dstFile)
if _, found := dst.Definitions[src.Ref.Key()]; !found {
var d JSONSchema //nolint:gosimple
var d JSONSchema
d = *match
d.Schema = ""
d.Definitions = nil
Expand Down
5 changes: 3 additions & 2 deletions types/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,11 @@ func (c *Config) JSON() (string, error) {
func (c *Config) Markdown() string {
mkdwn := "# Global Configurations\n"
mkdwn += fmt.Sprintf("**Current workspace:** `%s`\n", c.CurrentWorkspace)
if c.WorkspaceMode == ConfigWorkspaceModeFixed {
switch c.WorkspaceMode {
case ConfigWorkspaceModeFixed:
mkdwn += "*Workspace mode is set to fixed. This means that your working directory will have no impact on the " +
"current workspace.*\n\n"
} else if c.WorkspaceMode == ConfigWorkspaceModeDynamic {
case ConfigWorkspaceModeDynamic:
mkdwn += "*Workspace mode is set to dynamic. This means that your current workspace is also determined by " +
"your working directory.*\n\n"
}
Expand Down
Loading