From f0eb770824bb5284342ebcd2ebc1050680dad678 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 1 Apr 2025 08:59:15 +0000 Subject: [PATCH 1/3] chore: Bump golangci/golangci-lint-action from 6 to 7 Bumps [golangci/golangci-lint-action](https://github.com/golangci/golangci-lint-action) from 6 to 7. - [Release notes](https://github.com/golangci/golangci-lint-action/releases) - [Commits](https://github.com/golangci/golangci-lint-action/compare/v6...v7) --- updated-dependencies: - dependency-name: golangci/golangci-lint-action dependency-version: '7' dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- .github/workflows/analyze.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/analyze.yaml b/.github/workflows/analyze.yaml index c0add6c0..891bcc8b 100644 --- a/.github/workflows/analyze.yaml +++ b/.github/workflows/analyze.yaml @@ -52,7 +52,7 @@ 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 From 7d28bbf91ab2fbd885633154b18ddaf9fa904045 Mon Sep 17 00:00:00 2001 From: Jahvon Dockery Date: Mon, 19 May 2025 13:56:48 -0400 Subject: [PATCH 2/3] upgrade golanglint-ci --- .github/workflows/analyze.yaml | 2 +- .golangci.yaml | 203 ++++++++++++++++++--------------- cmd/internal/library.go | 5 +- development.flow | 2 +- internal/io/library/init.go | 15 +-- internal/io/library/update.go | 10 +- tools/docsgen/schema/schema.go | 2 +- types/config/config.go | 5 +- 8 files changed, 131 insertions(+), 113 deletions(-) diff --git a/.github/workflows/analyze.yaml b/.github/workflows/analyze.yaml index 891bcc8b..40a73c18 100644 --- a/.github/workflows/analyze.yaml +++ b/.github/workflows/analyze.yaml @@ -54,7 +54,7 @@ jobs: - name: golangci-lint uses: golangci/golangci-lint-action@v7 with: - version: v1.64.5 + version: v2.1.6 args: --out-format=sarif:results.sarif,colored-line-number,github-actions - name: Upload SARIF file uses: github/codeql-action/upload-sarif@v3 diff --git a/.golangci.yaml b/.golangci.yaml index a9f16631..09143aa7 100644 --- a/.golangci.yaml +++ b/.golangci.yaml @@ -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 \ No newline at end of file +formatters: + enable: + - goimports + exclusions: + generated: lax + paths: + - third_party$ + - builtin$ + - examples$ diff --git a/cmd/internal/library.go b/cmd/internal/library.go index e571a929..4c3f8d55 100644 --- a/cmd/internal/library.go +++ b/cmd/internal/library.go @@ -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 = "" } diff --git a/development.flow b/development.flow index 8b34d7ca..ab2c0f4b 100644 --- a/development.flow +++ b/development.flow @@ -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..." diff --git a/internal/io/library/init.go b/internal/io/library/init.go index e32945e4..096c0a58 100644 --- a/internal/io/library/init.go +++ b/internal/io/library/init.go @@ -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 } } @@ -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 { diff --git a/internal/io/library/update.go b/internal/io/library/update.go index 15830a80..da9c3637 100644 --- a/internal/io/library/update.go +++ b/internal/io/library/update.go @@ -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 } @@ -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 } diff --git a/tools/docsgen/schema/schema.go b/tools/docsgen/schema/schema.go index 63ba09b9..36cfbe55 100644 --- a/tools/docsgen/schema/schema.go +++ b/tools/docsgen/schema/schema.go @@ -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 diff --git a/types/config/config.go b/types/config/config.go index d0623646..2f18f113 100644 --- a/types/config/config.go +++ b/types/config/config.go @@ -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" } From d6797e84434234477da24079d9376f1e5d1e6aaf Mon Sep 17 00:00:00 2001 From: Jahvon Dockery Date: Mon, 19 May 2025 14:04:07 -0400 Subject: [PATCH 3/3] update flag --- .github/workflows/analyze.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/analyze.yaml b/.github/workflows/analyze.yaml index 40a73c18..96908d2c 100644 --- a/.github/workflows/analyze.yaml +++ b/.github/workflows/analyze.yaml @@ -55,7 +55,7 @@ jobs: uses: golangci/golangci-lint-action@v7 with: version: v2.1.6 - args: --out-format=sarif:results.sarif,colored-line-number,github-actions + args: --output.sarif.path=results.sarif - name: Upload SARIF file uses: github/codeql-action/upload-sarif@v3 with: