From d5f4f148798ab3c86d9b23a444e5b581f0616dc7 Mon Sep 17 00:00:00 2001 From: Aditya Menon Date: Mon, 17 Feb 2025 16:13:37 +0100 Subject: [PATCH] fix golangci lint file Signed-off-by: Aditya Menon --- .golangci.yaml | 68 ++++++++++++++++++++++++++++++-------------------- pkg/app/app.go | 2 -- 2 files changed, 41 insertions(+), 29 deletions(-) diff --git a/.golangci.yaml b/.golangci.yaml index d0c0f1c2..e828a482 100644 --- a/.golangci.yaml +++ b/.golangci.yaml @@ -27,10 +27,6 @@ run: # - src/external_libs # - autogenerated_by_my_lib - # default is true. Enables skipping of directories: - # vendor$, third_party$, testdata$, examples$, Godeps$, builtin$ - skip-dirs-use-default: true - # which files to skip: they will be analyzed, but issues from them # won't be reported. Default value is empty list, but there is # no need to include all autogenerated files, we confidently recognize @@ -51,8 +47,35 @@ run: # output configuration options output: - # colored-line-number|line-number|json|tab|checkstyle|code-climate, default is "colored-line-number" - format: line-number + # The formats used to render issues. + # Formats: + # - `colored-line-number` + # - `line-number` + # - `json` + # - `colored-tab` + # - `tab` + # - `html` + # - `checkstyle` + # - `code-climate` + # - `junit-xml` + # - `junit-xml-extended` + # - `github-actions` + # - `teamcity` + # - `sarif` + # Output path can be either `stdout`, `stderr` or path to the file to write to. + # + # For the CLI flag (`--out-format`), multiple formats can be specified by separating them by comma. + # The output can be specified for each of them by separating format name and path by colon symbol. + # Example: "--out-format=checkstyle:report.xml,json:stdout,colored-line-number" + # The CLI flag (`--out-format`) override the configuration file. + # + # Default: + # formats: + # - format: colored-line-number + # path: stdout + formats: + - format: line-number + path: stdout # print lines of code with issue, default is true print-issued-lines: true @@ -88,12 +111,13 @@ linters-settings: # Disable error checking, as errorcheck detects more errors and is more configurable. gosec: - exclude: - - "G104" + excludes: + - "G104" govet: # report about shadowed variables - check-shadowing: false + disable: + - shadow # settings per analyzer settings: @@ -111,13 +135,15 @@ linters-settings: # disable: # - shadow # disable-all: false - golint: + revive: # minimal confidence for issues, default is 0.8 - min-confidence: 0.8 + confidence: 0.8 + ignore-generated-header: true + severity: warning gofmt: # simplify code: gofmt with `-s` option, true by default simplify: true - goimports: + # goimports: # put imports beginning with prefix after 3rd-party packages; # it's a comma-separated list of prefixes # local-prefixes: github.com/org/project @@ -127,9 +153,6 @@ linters-settings: gocognit: # minimal code complexity to report, 30 by default (but we recommend 10-20) min-complexity: 100 - maligned: - # print struct with more effective memory layout or not, false by default - suggest-new: true dupl: # tokens count to trigger issue, 150 by default threshold: 100 @@ -159,12 +182,6 @@ linters-settings: line-length: 120 # tab width in spaces. Default to 1. tab-width: 1 - unused: - # treat code as a program (not a library) and report unused exported identifiers; default is false. - # XXX: if you enable this setting, unused will report a lot of false-positives in text editors: - # if it's called for subdir of a project it can't find funcs usages. All text editor integrations - # with golangci-lint call it on a directory with the changed file. - check-exported: false unparam: # Inspect exported functions, default is false. Set to true if no external program/library imports your code. # XXX: if you enable this setting, unparam will report a lot of false-positives in text editors: @@ -173,7 +190,7 @@ linters-settings: check-exported: false nakedret: # make an issue if func has more lines of code than this setting and it has naked returns; default is 30 - max-func-lines: 50 + max-func-lines: 50 prealloc: # XXX: we don't recommend using this linter before doing performance profiling. # For most programs usage of prealloc will be a premature optimization. @@ -237,9 +254,6 @@ linters-settings: allow-trailing-comment: false # Force newlines in end of case at this limit (0 = never). force-case-trailing-whitespace: 0 - revive: - ignore-generated-header: true - severity: warning funlen: # Checks the number of lines in a function. # If lower than 0, disable the check. @@ -270,7 +284,7 @@ linters: - ineffassign - misspell - nakedret - - exportloopref + - copyloopvar - staticcheck - typecheck - unconvert @@ -357,4 +371,4 @@ issues: # new-from-rev: REV # Show only new issues created in git patch with set file path. - # new-from-patch: path/to/patch/file \ No newline at end of file + # new-from-patch: path/to/patch/file diff --git a/pkg/app/app.go b/pkg/app/app.go index 7bed5766..61e3224e 100644 --- a/pkg/app/app.go +++ b/pkg/app/app.go @@ -1324,7 +1324,6 @@ func (a *App) getSelectedReleases(r *Run, includeTransitiveNeeds bool) ([]state. selectedIds := map[string]state.ReleaseSpec{} selectedCounts := map[string]int{} for _, r := range selected { - r := r id := state.ReleaseToID(&r) selectedIds[id] = r selectedCounts[id]++ @@ -1338,7 +1337,6 @@ func (a *App) getSelectedReleases(r *Run, includeTransitiveNeeds bool) ([]state. groupsByID := map[string][]*state.ReleaseSpec{} for _, r := range allReleases { - r := r groupsByID[state.ReleaseToID(&r)] = append(groupsByID[state.ReleaseToID(&r)], &r) }