From 16162127c3536857fb165cbe6c6a2ab64cfea349 Mon Sep 17 00:00:00 2001 From: GolangCI-Lint Releaser <65486276+golangci-releaser@users.noreply.github.com> Date: Sat, 12 Apr 2025 19:35:32 +0200 Subject: [PATCH 01/96] docs: update GitHub Action assets (#5723) --- assets/github-action-config-v1.json | 3 +++ assets/github-action-config-v2.json | 5 ++++- assets/github-action-config.json | 3 +++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/assets/github-action-config-v1.json b/assets/github-action-config-v1.json index 596dfd69ba75..28c21d7b0786 100644 --- a/assets/github-action-config-v1.json +++ b/assets/github-action-config-v1.json @@ -191,6 +191,9 @@ }, "v2.0": { "Error": "golangci-lint version 'v2.0' isn't supported: only v1 versions are supported" + }, + "v2.1": { + "Error": "golangci-lint version 'v2.1' isn't supported: only v1 versions are supported" } } } diff --git a/assets/github-action-config-v2.json b/assets/github-action-config-v2.json index 8ef161513b62..a0a27322f486 100644 --- a/assets/github-action-config-v2.json +++ b/assets/github-action-config-v2.json @@ -1,7 +1,7 @@ { "MinorVersionToConfig": { "latest": { - "TargetVersion": "v2.0.2" + "TargetVersion": "v2.1.0" }, "v1.10": { "Error": "golangci-lint version 'v1.10' isn't supported: we support only v2.0.0 and later versions" @@ -191,6 +191,9 @@ }, "v2.0": { "TargetVersion": "v2.0.2" + }, + "v2.1": { + "TargetVersion": "v2.1.0" } } } diff --git a/assets/github-action-config.json b/assets/github-action-config.json index 596dfd69ba75..28c21d7b0786 100644 --- a/assets/github-action-config.json +++ b/assets/github-action-config.json @@ -191,6 +191,9 @@ }, "v2.0": { "Error": "golangci-lint version 'v2.0' isn't supported: only v1 versions are supported" + }, + "v2.1": { + "Error": "golangci-lint version 'v2.1' isn't supported: only v1 versions are supported" } } } From cb0ee160c341cc1b6f7748b76e5d056cf8eeeb63 Mon Sep 17 00:00:00 2001 From: GolangCI-Lint Releaser <65486276+golangci-releaser@users.noreply.github.com> Date: Sat, 12 Apr 2025 19:54:56 +0200 Subject: [PATCH 02/96] docs: update documentation assets (#5722) Co-authored-by: Fernandez Ludovic --- .golangci.reference.yml | 179 +++++++++++++--------- assets/cli-help.json | 4 +- assets/linters-info.json | 19 ++- jsonschema/golangci.jsonschema.json | 58 ++++++- jsonschema/golangci.next.jsonschema.json | 1 + jsonschema/golangci.v1.64.jsonschema.json | 1 + 6 files changed, 183 insertions(+), 79 deletions(-) diff --git a/.golangci.reference.yml b/.golangci.reference.yml index 446e06780a00..cababbea228f 100644 --- a/.golangci.reference.yml +++ b/.golangci.reference.yml @@ -43,6 +43,7 @@ linters: - fatcontext - forbidigo - forcetypeassert + - funcorder - funlen - ginkgolinter - gocheckcompilerdirectives @@ -121,7 +122,7 @@ linters: - wsl - zerologlint - # Disable specific linter + # Disable specific linter. # https://golangci-lint.run/usage/linters/#disabled-by-default disable: - asasalint @@ -150,6 +151,7 @@ linters: - fatcontext - forbidigo - forcetypeassert + - funcorder - funlen - ginkgolinter - gocheckcompilerdirectives @@ -266,7 +268,7 @@ linters: # Default: 10 max-complexity: 10 # The maximal average package complexity. - # If it's higher than 0.0 (float) the check is enabled + # If it's higher than 0.0 (float) the check is enabled. # Default: 0.0 package-average: 0.5 @@ -279,7 +281,7 @@ linters: - var - func - # If true, underscore vars (vars with "_" as the name) will be ignored at all checks + # If true, underscore vars (vars with "_" as the name) will be ignored at all checks. # Default: false (underscore vars are not ignored) ignore-underscore-vars: false @@ -295,15 +297,15 @@ linters: # Default: true (disabled) disable-dec-num-check: false - # If true, type declarations will be ignored for dec num check + # If true, type declarations will be ignored for dec num check. # Default: false (type statements are not ignored) disable-type-dec-num-check: false - # If true, const declarations will be ignored for dec num check + # If true, const declarations will be ignored for dec num check. # Default: false (const statements are not ignored) disable-const-dec-num-check: false - # If true, var declarations will be ignored for dec num check + # If true, var declarations will be ignored for dec num check. # Default: false (var statements are not ignored) disable-var-dec-num-check: false @@ -335,6 +337,7 @@ linters: # List of file globs that will match this list of settings to compare against. # By default, if a path is relative, it is relative to the directory where the golangci-lint command is executed. # The placeholder '${base-path}' is substituted with a path relative to the mode defined with `run.relative-path-mode`. + # The placeholder '${config-path}' is substituted with a path relative to the configuration file. # Default: $all files: - "!**/*_a _file.go" @@ -428,7 +431,7 @@ linters: # See the https://github.com/polyfloyd/go-errorlint for caveats. # Default: true errorf: false - # Permit more than 1 %w verb, valid per Go 1.20 (Requires errorf:true) + # Permit more than 1 %w verb, valid per Go 1.20 (requires `errorf: true`). # Default: true errorf-multi: false # Check for plain type assertions and type switches. @@ -508,7 +511,7 @@ linters: # Optional message that gets included in error reports. - pattern: ^fmt\.Print.*$ msg: Do not commit print statements. - # Alternatively, put messages at the end of the regex, surrounded by `(# )?` + # Alternatively, put messages at the end of the regex, surrounded by `(# )?`. # Escape any special characters. Those messages get included in error reports. - pattern: 'fmt\.Print.*(# Do not commit print statements\.)?' # Forbid spew Dump, whether it is called as function or method. @@ -529,6 +532,14 @@ linters: # Default: false analyze-types: true + funcorder: + # Checks that constructors are placed after the structure declaration. + # Default: true + constructor: false + # Checks if the exported methods of a structure are placed before the non-exported ones. + # Default: true + struct-method: false + funlen: # Checks the number of lines in a function. # If lower than 0, disable the check. @@ -563,11 +574,11 @@ linters: # Default: false suppress-async-assertion: true - # Suppress warning for comparing values from different types, like `int32` and `uint32` + # Suppress warning for comparing values from different types, like `int32` and `uint32`. # Default: false suppress-type-compare-assertion: true - # Trigger warning for ginkgo focus containers like `FDescribe`, `FContext`, `FWhen` or `FIt` + # Trigger warning for ginkgo focus containers like `FDescribe`, `FContext`, `FWhen` or `FIt`. # Default: false forbid-focus-container: true @@ -581,7 +592,7 @@ linters: force-expect-to: true # Best effort validation of async intervals (timeout and polling). - # Ignored the suppress-async-assertion is true. + # Ignored the `suppress-async-assertion` is true. # Default: false validate-async-intervals: true @@ -597,7 +608,7 @@ linters: # Presence of `default` case in switch statements satisfies exhaustiveness, if all members are not listed. # Default: true default-signifies-exhaustive: false - # Include shared interfaces in the exhaustiviness check. + # Include shared interfaces in the exhaustiveness check. # Default: false include-shared-interfaces: true @@ -619,10 +630,10 @@ linters: # Search also for duplicated numbers. # Default: false numbers: true - # Minimum value, only works with goconst.numbers + # Minimum value, only works with `goconst.numbers`. # Default: 3 min: 2 - # Maximum value, only works with goconst.numbers + # Maximum value, only works with `goconst.numbers`. # Default: 3 max: 2 # Ignore when constant is not used as function argument. @@ -630,7 +641,14 @@ linters: ignore-calls: false # Exclude strings matching the given regular expression. # Default: "" - ignore-strings: 'foo.+' + ignore-string-values: + - 'foo.+' + # Detects constants with identical values. + # Default: false + find-duplicates: true + # Evaluates of constant expressions like Prefix + "suffix". + # Default: false + eval-const-expressions: true gocritic: # Disable all checks. @@ -1095,7 +1113,7 @@ linters: # Settings passed to gocritic. # The settings key is the name of a supported gocritic checker. - # The list of supported checkers can be find in https://go-critic.com/overview. + # The list of supported checkers can be found at https://go-critic.com/overview. settings: # Must be valid enabled check name. captLocal: @@ -1161,6 +1179,7 @@ linters: # Comma-separated list of file paths containing ruleguard rules. # By default, if a path is relative, it is relative to the directory where the golangci-lint command is executed. # The placeholder '${base-path}' is substituted with a path relative to the mode defined with `run.relative-path-mode`. + # The placeholder '${config-path}' is substituted with a path relative to the configuration file. # Glob patterns such as 'rules-*.go' may be specified. # Default: "" rules: '${base-path}/ruleguard/rules-*.go,${base-path}/myrule1.go' @@ -1234,19 +1253,19 @@ linters: # for example: AUTHOR: .*@mycompany\.com # The template used for checking. - # Put here copyright header template for source code files + # Put here copyright header template for source code files. # Note: {{ YEAR }} is a builtin value that returns the year relative to the current machine time. # Default: "" template: |- {{ AUTHOR }} {{ COMPANY }} {{ YEAR }} SPDX-License-Identifier: Apache-2.0 - + Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at: - + http://www.apache.org/licenses/LICENSE-2.0 - + Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -1256,6 +1275,7 @@ linters: # Useful if you need to load the template from a specific file. # By default, if a path is relative, it is relative to the directory where the golangci-lint command is executed. # The placeholder '${base-path}' is substituted with a path relative to the mode defined with `run.relative-path-mode`. + # The placeholder '${config-path}' is substituted with a path relative to the configuration file. # Default: "" template-path: /path/to/my/template.tmpl @@ -1339,7 +1359,6 @@ linters: - G110 # Potential DoS vulnerability via decompression bomb - G111 # Potential directory traversal - G112 # Potential slowloris attack - - G113 # Usage of Rat.SetString in math/big with an overflow (CVE-2022-23772) - G114 # Use of net/http serve function that has no support for setting timeouts - G115 # Potential integer overflow when converting between integer types - G201 # SQL query construction using format string @@ -1384,7 +1403,6 @@ linters: - G110 # Potential DoS vulnerability via decompression bomb - G111 # Potential directory traversal - G112 # Potential slowloris attack - - G113 # Usage of Rat.SetString in math/big with an overflow (CVE-2022-23772) - G114 # Use of net/http serve function that has no support for setting timeouts - G115 # Potential integer overflow when converting between integer types - G201 # SQL query construction using format string @@ -1494,13 +1512,13 @@ linters: # Regexp pattern to find potential directory traversal. # Default: "http\\.Dir\\(\"\\/\"\\)|http\\.Dir\\('\\/'\\)" pattern: "custom\\.Dir\\(\\)" - # Maximum allowed permissions mode for os.Mkdir and os.MkdirAll + # Maximum allowed permissions mode for os.Mkdir and os.MkdirAll. # Default: "0750" G301: "0750" - # Maximum allowed permissions mode for os.OpenFile and os.Chmod + # Maximum allowed permissions mode for os.OpenFile and os.Chmod. # Default: "0600" G302: "0600" - # Maximum allowed permissions mode for os.WriteFile and ioutil.WriteFile + # Maximum allowed permissions mode for os.WriteFile and ioutil.WriteFile. # Default: "0600" G306: "0600" @@ -1536,7 +1554,7 @@ linters: # Default: false disable-all: true # Enable analyzers by name. - # (in addition to default: + # (In addition to default: # appends, asmdecl, assign, atomic, bools, buildtag, cgocall, composites, copylocks, defers, directive, errorsas, # framepointer, httpresponse, ifaceassert, loopclosure, lostcancel, nilfunc, printf, shift, sigchanyzer, slog, # stdmethods, stringintconv, structtag, testinggoroutine, tests, timeformat, unmarshal, unreachable, unsafeptr, @@ -1579,6 +1597,8 @@ linters: - findcall # Report assembly that clobbers the frame pointer before saving it. - framepointer + # Report using Go 1.22 enhanced ServeMux patterns in older Go versions. + - httpmux # Check for mistakes using HTTP responses. - httpresponse # Detect impossible interface-to-interface type assertions. @@ -1636,7 +1656,7 @@ linters: # Default: false enable-all: true # Disable analyzers by name. - # (in addition to default + # (In addition to default # atomicalign, deepequalerrors, fieldalignment, findcall, nilness, reflectvaluecompare, shadow, sortslice, # timeformat, unusedwrite # ). @@ -1660,6 +1680,7 @@ linters: - fieldalignment - findcall - framepointer + - httpmux - httpresponse - ifaceassert - loopclosure @@ -1703,16 +1724,16 @@ linters: # Default: false strict: true unusedresult: - # Comma-separated list of functions whose results must be used - # (in addition to default: + # Comma-separated list of functions whose results must be used. + # (In addition to default: # context.WithCancel, context.WithDeadline, context.WithTimeout, context.WithValue, errors.New, fmt.Errorf, # fmt.Sprint, fmt.Sprintf, sort.Reverse # ). # Default: [] funcs: - pkg.MyFunc - # Comma-separated list of names of methods of type func() string whose results must be used - # (in addition to default Error,String) + # Comma-separated list of names of methods of type func() string whose results must be used. + # (In addition to default Error,String). # Default: [] stringmethods: - MyMethod @@ -1778,7 +1799,7 @@ linters: alias: autoscalingv1alpha1 # You can specify the package path by regular expression, # and alias by regular expression expansion syntax like below. - # see https://github.com/julz/importas#use-regular-expression for details + # See https://github.com/julz/importas#use-regular-expression for details. - pkg: knative.dev/serving/pkg/apis/(\w+)/(v[\w\d]+) alias: $1$2 # An explicit empty alias can be used to ensure no aliases are used for a package. @@ -1917,14 +1938,14 @@ linters: - assign # List of numbers to exclude from analysis. # The numbers should be written as string. - # Values always ignored: "1", "1.0", "0" and "0.0" + # Values always ignored: "1", "1.0", "0" and "0.0". # Default: [] ignored-numbers: - '0666' - '0755' - '42' # List of file patterns to exclude from analysis. - # Values always ignored: `.+_test.go` + # Values always ignored: `.+_test.go`. # Default: [] ignored-files: - 'magic1_.+\.go$' @@ -1979,7 +2000,7 @@ linters: - unsafeptr nlreturn: - # Size of the block (including return statement that is still "OK") + # Size of the block (including return statement that is still "OK"), # so no return split required. # Default: 1 block-size: 2 @@ -2169,10 +2190,10 @@ linters: disabled: false exclude: [""] arguments: - - maxLitCount: "3" - allowStrs: '""' - allowInts: "0,1,2" - allowFloats: "0.0,0.,1.0,1.,2.0,2." + - max-lit-count: "3" + allow-strs: '""' + allow-ints: "0,1,2" + allow-floats: "0.0,0.,1.0,1.,2.0,2." # https://github.com/mgechev/revive/blob/HEAD/RULES_DESCRIPTIONS.md#argument-limit - name: argument-limit severity: warning @@ -2251,7 +2272,7 @@ linters: disabled: false exclude: [""] arguments: - - allowTypesBefore: "*testing.T,*github.com/user/repo/testing.Harness" + - allow-types-before: "*testing.T,*github.com/user/repo/testing.Harness" # https://github.com/mgechev/revive/blob/HEAD/RULES_DESCRIPTIONS.md#context-keys-type - name: context-keys-type severity: warning @@ -2291,7 +2312,7 @@ linters: disabled: false exclude: [""] arguments: - - allowedPackages: ["github.com/onsi/ginkgo/v2", "github.com/onsi/gomega"] + - allowed-packages: ["github.com/onsi/ginkgo/v2", "github.com/onsi/gomega"] # https://github.com/mgechev/revive/blob/HEAD/RULES_DESCRIPTIONS.md#duplicated-imports - name: duplicated-imports severity: warning @@ -2303,8 +2324,8 @@ linters: disabled: false exclude: [""] arguments: - - "preserveScope" - - "allowJump" + - "preserve-scope" + - "allow-jump" # https://github.com/mgechev/revive/blob/HEAD/RULES_DESCRIPTIONS.md#empty-block - name: empty-block severity: warning @@ -2330,8 +2351,8 @@ linters: arguments: - "short" # Or this parameter: - - funcArgStyle: "full" - funcRetValStyle: "short" + - func-arg-style: "full" + func-ret-val-style: "short" # https://github.com/mgechev/revive/blob/HEAD/RULES_DESCRIPTIONS.md#enforce-slice-style - name: enforce-slice-style severity: warning @@ -2367,15 +2388,15 @@ linters: disabled: false exclude: [""] arguments: - - "checkPrivateReceivers" - - "disableStutteringCheck" - - "sayRepetitiveInsteadOfStutters" - - "checkPublicInterface" - - "disableChecksOnConstants" - - "disableChecksOnFunctions" - - "disableChecksOnMethods" - - "disableChecksOnTypes" - - "disableChecksOnVariables" + - "check-private-receivers" + - "disable-stuttering-check" + - "say-repetitive-instead-of-stutters" + - "check-public-interface" + - "disable-checks-on-constants" + - "disable-checks-on-functions" + - "disable-checks-on-methods" + - "disable-checks-on-types" + - "disable-checks-on-variables" # https://github.com/mgechev/revive/blob/HEAD/RULES_DESCRIPTIONS.md#file-header - name: file-header severity: warning @@ -2390,8 +2411,8 @@ linters: exclude: [""] arguments: - max: 100 - skipComments: true - skipBlankLines: true + skip-comments: true + skip-blank-lines: true # https://github.com/mgechev/revive/blob/HEAD/RULES_DESCRIPTIONS.md#filename-format - name: filename-format severity: warning @@ -2439,8 +2460,8 @@ linters: arguments: - "^[a-z][a-z0-9]{0,}$" # Or this parameter: - - allowRegex: "^[a-z][a-z0-9]{0,}$" - denyRegex: '^v\d+$' + - allow-regex: "^[a-z][a-z0-9]{0,}$" + deny-regex: '^v\d+$' # https://github.com/mgechev/revive/blob/HEAD/RULES_DESCRIPTIONS.md#import-shadowing - name: import-shadowing severity: warning @@ -2465,7 +2486,7 @@ linters: disabled: false exclude: [""] arguments: - - "preserveScope" + - "preserve-scope" # https://github.com/mgechev/revive/blob/HEAD/RULES_DESCRIPTIONS.md#line-length-limit - name: line-length-limit severity: warning @@ -2530,7 +2551,7 @@ linters: disabled: false exclude: [""] arguments: - - maxLength: 2 + - max-length: 2 # https://github.com/mgechev/revive/blob/HEAD/RULES_DESCRIPTIONS.md#redefines-builtin-id - name: redefines-builtin-id severity: warning @@ -2585,7 +2606,7 @@ linters: disabled: false exclude: [""] arguments: - - "preserveScope" + - "preserve-scope" # https://github.com/mgechev/revive/blob/HEAD/RULES_DESCRIPTIONS.md#time-equal - name: time-equal severity: warning @@ -2602,7 +2623,7 @@ linters: disabled: false exclude: [""] arguments: - - acceptIgnoredAssertionResult: true + - accept-ignored-assertion-result: true # https://github.com/mgechev/revive/blob/HEAD/RULES_DESCRIPTIONS.md#unconditional-recursion - name: unconditional-recursion severity: warning @@ -2642,14 +2663,14 @@ linters: disabled: false exclude: [""] arguments: - - allowRegex: "^_" + - allow-regex: "^_" # https://github.com/mgechev/revive/blob/HEAD/RULES_DESCRIPTIONS.md#unused-receiver - name: unused-receiver severity: warning disabled: false exclude: [""] arguments: - - allowRegex: "^_" + - allow-regex: "^_" # https://github.com/mgechev/revive/blob/HEAD/RULES_DESCRIPTIONS.md#use-any - name: use-any severity: warning @@ -2678,7 +2699,7 @@ linters: arguments: - [ "ID" ] # AllowList - [ "VM" ] # DenyList - - - upperCaseConst: true # Extra parameter (upperCaseConst|skipPackageNameChecks) + - - upper-case-const: true # Extra parameter (upper-case-const|skip-package-name-checks) # https://github.com/mgechev/revive/blob/HEAD/RULES_DESCRIPTIONS.md#waitgroup-by-value - name: waitgroup-by-value severity: warning @@ -2686,7 +2707,7 @@ linters: exclude: [""] rowserrcheck: - # database/sql is always checked + # database/sql is always checked. # Default: [] packages: - github.com/jmoiron/sqlx @@ -2724,11 +2745,16 @@ linters: # https://github.com/go-simpler/sloglint?tab=readme-ov-file#static-messages # Default: false static-msg: true + # Enforce message style. + # Values: lowercased, capitalized + # https://github.com/go-simpler/sloglint?tab=readme-ov-file#message-style + # Default: "" + msg-style: capitalized # Enforce using constants instead of raw keys. # https://github.com/go-simpler/sloglint?tab=readme-ov-file#no-raw-keys # Default: false no-raw-keys: true - # Enforce a single key naming convention. + # Enforce key naming convention. # Values: snake, kebab, camel, pascal # https://github.com/go-simpler/sloglint?tab=readme-ov-file#key-naming-convention # Default: "" @@ -3272,7 +3298,7 @@ linters: # Align and sort can be used together or separately. # # Whether enable align. If true, the struct tags will be aligned. - # e.g.: + # E.g.: # type FooBar struct { # Bar string `json:"bar" validate:"required"` # FooFoo int8 `json:"foo_foo" validate:"required"` @@ -3286,7 +3312,7 @@ linters: align: false # Whether enable tags sort. # If true, the tags will be sorted by name in ascending order. - # e.g.: `xml:"bar" json:"bar" validate:"required"` -> `json:"bar" validate:"required" xml:"bar"` + # E.g.: `xml:"bar" json:"bar" validate:"required"` -> `json:"bar" validate:"required" xml:"bar"`. # Default: true sort: false # Specify the order of tags, the other tags will be sorted by name. @@ -3757,6 +3783,9 @@ linters: # Default: [] ignore-interface-regexps: - ^(?i)c(?-i)ach(ing|e) + # Determines whether wrapcheck should report errors returned from inside the package. + # Default: false + report-internal-errors: true wsl: # Do strict checking when assigning from append (x = append(x, y)). @@ -3946,7 +3975,7 @@ formatters: gci: # Section configuration to compare against. # Section names are case-insensitive and may contain parameters in (). - # The default order of sections is `standard > default > custom > blank > dot > alias > localmodule`, + # The default order of sections is `standard > default > custom > blank > dot > alias > localmodule`. # If `custom-order` is `true`, it follows the order of `sections` option. # Default: ["standard", "default"] sections: @@ -4021,6 +4050,9 @@ formatters: chain-split-dots: false exclusions: + # Log a warning if an exclusion path is unused. + # Default: false + warn-unused: true # Mode of the generated files analysis. # # - `strict`: sources are excluded by strictly following the Go generated file convention. @@ -4154,9 +4186,16 @@ output: path: ./path/to/output.json # Add a prefix to the output file references. + # This option is ignored when using `output.path-mode: abs` mode. # Default: "" path-prefix: "" + # By default, the report are related to the path obtained by `run.relative-path-mode`. + # The mode `abs` allows to show absolute file paths instead of relative file paths. + # The option `output.path-prefix` is ignored when using `abs` mode. + # Default: "" + path-mode: "abs" + # Order to use when sorting results. # Possible values: `file`, `linter`, and `severity`. # diff --git a/assets/cli-help.json b/assets/cli-help.json index 64c4581bf757..407240d603e0 100644 --- a/assets/cli-help.json +++ b/assets/cli-help.json @@ -1,5 +1,5 @@ { "enable": "Enabled by default linters:\nerrcheck: Errcheck is a program for checking for unchecked errors in Go code. These unchecked errors can be critical bugs in some cases.\ngovet: Vet examines Go source code and reports suspicious constructs. It is roughly the same as 'go vet' and uses its passes. [auto-fix]\nineffassign: Detects when assignments to existing variables are not used. [fast]\nstaticcheck: It's the set of rules from staticcheck. [auto-fix]\nunused: Checks Go code for unused constants, variables, functions and types.", - "help": "Usage:\n golangci-lint run [flags]\n\nFlags:\n -c, --config PATH Read config from file path PATH\n --no-config Don't read config file\n --default string Default set of linters to enable (default \"standard\")\n -D, --disable strings Disable specific linter\n -E, --enable strings Enable specific linter\n --enable-only strings Override linters configuration section to only run the specific linter(s)\n --fast-only Filter enabled linters to run only fast linters\n -j, --concurrency int Number of CPUs to use (Default: Automatically set to match Linux container CPU quota and fall back to the number of logical CPUs in the machine)\n --modules-download-mode string Modules download mode. If not empty, passed as -mod=\u003cmode\u003e to go tools\n --issues-exit-code int Exit code when issues were found (default 1)\n --build-tags strings Build tags\n --timeout duration Timeout for total work. Disabled by default\n --tests Analyze tests (*_test.go) (default true)\n --allow-parallel-runners Allow multiple parallel golangci-lint instances running.\n If false (default) - golangci-lint acquires file lock on start.\n --allow-serial-runners Allow multiple golangci-lint instances running, but serialize them around a lock.\n If false (default) - golangci-lint exits with an error if it fails to acquire file lock on start.\n --path-prefix string Path prefix to add to output\n --show-stats Show statistics per linter (default true)\n --output.text.path stdout Output path can be either stdout, `stderr` or path to the file to write to.\n --output.text.print-linter-name Print linter name in the end of issue text. (default true)\n --output.text.print-issued-lines Print lines of code with issue. (default true)\n --output.text.colors Use colors. (default true)\n --output.json.path stdout Output path can be either stdout, `stderr` or path to the file to write to.\n --output.tab.path stdout Output path can be either stdout, `stderr` or path to the file to write to.\n --output.tab.print-linter-name Print linter name in the end of issue text. (default true)\n --output.tab.colors Use colors. (default true)\n --output.html.path stdout Output path can be either stdout, `stderr` or path to the file to write to.\n --output.checkstyle.path stdout Output path can be either stdout, `stderr` or path to the file to write to.\n --output.code-climate.path stdout Output path can be either stdout, `stderr` or path to the file to write to.\n --output.junit-xml.path stdout Output path can be either stdout, `stderr` or path to the file to write to.\n --output.junit-xml.extended Support extra JUnit XML fields.\n --output.teamcity.path stdout Output path can be either stdout, `stderr` or path to the file to write to.\n --output.sarif.path stdout Output path can be either stdout, `stderr` or path to the file to write to.\n --max-issues-per-linter int Maximum issues count per one linter. Set to 0 to disable (default 50)\n --max-same-issues int Maximum count of issues with the same text. Set to 0 to disable (default 3)\n --uniq-by-line Make issues output unique by line (default true)\n -n, --new Show only new issues: if there are unstaged changes or untracked files, only those changes are analyzed, else only changes in HEAD~ are analyzed.\n It's a super-useful option for integration of golangci-lint into existing large codebase.\n It's not practical to fix all existing issues at the moment of integration: much better to not allow issues in new code.\n For CI setups, prefer --new-from-rev=HEAD~, as --new can skip linting the current patch if any scripts generate unstaged files before golangci-lint runs.\n --new-from-rev REV Show only new issues created after git revision REV\n --new-from-patch PATH Show only new issues created in git patch with file path PATH\n --new-from-merge-base string Show only new issues created after the best common ancestor (merge-base against HEAD)\n --whole-files Show issues in any part of update files (requires new-from-rev or new-from-patch)\n --fix Fix found issues (if it's supported by the linter)\n --cpu-profile-path string Path to CPU profile output file\n --mem-profile-path string Path to memory profile output file\n --print-resources-usage Print avg and max memory usage of golangci-lint and total time\n --trace-path string Path to trace output file\n\nGlobal Flags:\n --color string Use color when printing; can be 'always', 'auto', or 'never' (default \"auto\")\n -h, --help Help for a command\n -v, --verbose Verbose output\n", - "fmtHelp": "Usage:\n golangci-lint fmt [flags]\n\nFlags:\n -c, --config PATH Read config from file path PATH\n --no-config Don't read config file\n -E, --enable strings Enable specific formatter\n -d, --diff Display diffs instead of rewriting files\n --stdin Use standard input for piping source files\n\nGlobal Flags:\n --color string Use color when printing; can be 'always', 'auto', or 'never' (default \"auto\")\n -h, --help Help for a command\n -v, --verbose Verbose output\n" + "help": "Usage:\n golangci-lint run [flags]\n\nFlags:\n -c, --config PATH Read config from file path PATH\n --no-config Don't read config file\n --default string Default set of linters to enable (default \"standard\")\n -D, --disable strings Disable specific linter\n -E, --enable strings Enable specific linter\n --enable-only strings Override linters configuration section to only run the specific linter(s)\n --fast-only Filter enabled linters to run only fast linters\n -j, --concurrency int Number of CPUs to use (Default: Automatically set to match Linux container CPU quota and fall back to the number of logical CPUs in the machine)\n --modules-download-mode string Modules download mode. If not empty, passed as -mod=\u003cmode\u003e to go tools\n --issues-exit-code int Exit code when issues were found (default 1)\n --build-tags strings Build tags\n --timeout duration Timeout for total work. Disabled by default\n --tests Analyze tests (*_test.go) (default true)\n --allow-parallel-runners Allow multiple parallel golangci-lint instances running.\n If false (default) - golangci-lint acquires file lock on start.\n --allow-serial-runners Allow multiple golangci-lint instances running, but serialize them around a lock.\n If false (default) - golangci-lint exits with an error if it fails to acquire file lock on start.\n --path-prefix string Path prefix to add to output\n --path-mode string Path mode to use (empty, or 'abs')\n --show-stats Show statistics per linter (default true)\n --output.text.path stdout Output path can be either stdout, `stderr` or path to the file to write to.\n --output.text.print-linter-name Print linter name in the end of issue text. (default true)\n --output.text.print-issued-lines Print lines of code with issue. (default true)\n --output.text.colors Use colors. (default true)\n --output.json.path stdout Output path can be either stdout, `stderr` or path to the file to write to.\n --output.tab.path stdout Output path can be either stdout, `stderr` or path to the file to write to.\n --output.tab.print-linter-name Print linter name in the end of issue text. (default true)\n --output.tab.colors Use colors. (default true)\n --output.html.path stdout Output path can be either stdout, `stderr` or path to the file to write to.\n --output.checkstyle.path stdout Output path can be either stdout, `stderr` or path to the file to write to.\n --output.code-climate.path stdout Output path can be either stdout, `stderr` or path to the file to write to.\n --output.junit-xml.path stdout Output path can be either stdout, `stderr` or path to the file to write to.\n --output.junit-xml.extended Support extra JUnit XML fields.\n --output.teamcity.path stdout Output path can be either stdout, `stderr` or path to the file to write to.\n --output.sarif.path stdout Output path can be either stdout, `stderr` or path to the file to write to.\n --max-issues-per-linter int Maximum issues count per one linter. Set to 0 to disable (default 50)\n --max-same-issues int Maximum count of issues with the same text. Set to 0 to disable (default 3)\n --uniq-by-line Make issues output unique by line (default true)\n -n, --new Show only new issues: if there are unstaged changes or untracked files, only those changes are analyzed, else only changes in HEAD~ are analyzed.\n It's a super-useful option for integration of golangci-lint into existing large codebase.\n It's not practical to fix all existing issues at the moment of integration: much better to not allow issues in new code.\n For CI setups, prefer --new-from-rev=HEAD~, as --new can skip linting the current patch if any scripts generate unstaged files before golangci-lint runs.\n --new-from-rev REV Show only new issues created after git revision REV\n --new-from-patch PATH Show only new issues created in git patch with file path PATH\n --new-from-merge-base string Show only new issues created after the best common ancestor (merge-base against HEAD)\n --whole-files Show issues in any part of update files (requires new-from-rev or new-from-patch)\n --fix Fix found issues (if it's supported by the linter)\n --cpu-profile-path string Path to CPU profile output file\n --mem-profile-path string Path to memory profile output file\n --print-resources-usage Print avg and max memory usage of golangci-lint and total time\n --trace-path string Path to trace output file\n\nGlobal Flags:\n --color string Use color when printing; can be 'always', 'auto', or 'never' (default \"auto\")\n -h, --help Help for a command\n -v, --verbose Verbose output\n", + "fmtHelp": "Usage:\n golangci-lint fmt [flags]\n\nFlags:\n -c, --config PATH Read config from file path PATH\n --no-config Don't read config file\n -E, --enable strings Enable specific formatter\n -d, --diff Display diffs instead of rewriting files\n --diff-colored Display diffs instead of rewriting files (with colors)\n --stdin Use standard input for piping source files\n\nGlobal Flags:\n --color string Use color when printing; can be 'always', 'auto', or 'never' (default \"auto\")\n -h, --help Help for a command\n -v, --verbose Verbose output\n" } diff --git a/assets/linters-info.json b/assets/linters-info.json index 8711ae5270e4..99ffd81b0865 100644 --- a/assets/linters-info.json +++ b/assets/linters-info.json @@ -246,6 +246,16 @@ "isSlow": true, "since": "v1.38.0" }, + { + "name": "funcorder", + "desc": "checks the order of functions, methods, and constructors", + "Groups": null, + "loadMode": 8199, + "originalURL": "https://github.com/manuelarte/funcorder", + "internal": false, + "isSlow": false, + "since": "v2.1.0" + }, { "name": "fatcontext", "desc": "detects nested contexts in loops and function literals", @@ -331,10 +341,10 @@ "name": "goconst", "desc": "Finds repeated strings that could be replaced by a constant", "Groups": null, - "loadMode": 8199, + "loadMode": 8767, "originalURL": "https://github.com/jgautheron/goconst", "internal": false, - "isSlow": false, + "isSlow": true, "since": "v1.0.0" }, { @@ -570,7 +580,7 @@ }, { "name": "loggercheck", - "desc": "Checks key value pairs for common logger libraries (kitlog,klog,logr,zap).", + "desc": "Checks key value pairs for common logger libraries (kitlog,klog,logr,slog,zap).", "Groups": null, "loadMode": 8767, "originalURL": "https://github.com/timonwong/loggercheck", @@ -614,7 +624,7 @@ "desc": "Finds commonly misspelled English words", "Groups": null, "loadMode": 8199, - "originalURL": "https://github.com/client9/misspell", + "originalURL": "https://github.com/golangci/misspell", "internal": false, "canAutoFix": true, "isSlow": false, @@ -832,6 +842,7 @@ "loadMode": 8767, "originalURL": "https://github.com/go-simpler/sloglint", "internal": false, + "canAutoFix": true, "isSlow": true, "since": "v1.55.0" }, diff --git a/jsonschema/golangci.jsonschema.json b/jsonschema/golangci.jsonschema.json index 437943b5f318..0f2ef5fcc50b 100644 --- a/jsonschema/golangci.jsonschema.json +++ b/jsonschema/golangci.jsonschema.json @@ -490,7 +490,6 @@ "G110", "G111", "G112", - "G113", "G114", "G115", "G201", @@ -540,6 +539,7 @@ "fieldalignment", "findcall", "framepointer", + "httpmux", "httpresponse", "ifaceassert", "loopclosure", @@ -742,6 +742,7 @@ "fatcontext", "forbidigo", "forcetypeassert", + "funcorder", "funlen", "ginkgolinter", "gocheckcompilerdirectives", @@ -1303,6 +1304,22 @@ } } }, + "funcorderSettings": { + "type": "object", + "additionalProperties": false, + "properties": { + "constructor": { + "description": "Checks that constructors are placed after the structure declaration.", + "type": "boolean", + "default": true + }, + "struct-method": { + "description": "Checks if the exported methods of a structure are placed before the non-exported ones.", + "type": "boolean", + "default": true + } + } + }, "funlenSettings": { "type": "object", "additionalProperties": false, @@ -1489,9 +1506,12 @@ "type": "boolean", "default": true }, - "ignore-strings": { + "ignore-string-values": { "description": "Exclude strings matching the given regular expression", - "type": "string" + "type": "array", + "items": { + "type": "string" + } }, "numbers": { "description": "Search also for duplicated numbers.", @@ -1507,6 +1527,16 @@ "description": "Maximum value, only works with `numbers`", "type": "integer", "default": 3 + }, + "find-duplicates": { + "description": "Detects constants with identical values", + "type": "boolean", + "default": false + }, + "eval-const-expressions": { + "description": "Evaluates of constant expressions like Prefix + \"suffix\"", + "type": "boolean", + "default": false } } }, @@ -2964,6 +2994,11 @@ "type": "boolean", "default": false }, + "msg-style": { + "description": "Enforce message style.", + "enum": ["", "lowercased", "capitalized"], + "default": "" + }, "key-naming-case": { "description": "Enforce a single key naming convention.", "enum": ["snake", "kebab", "camel", "pascal"] @@ -3924,6 +3959,11 @@ "items": { "type": "string" } + }, + "report-internal-errors": { + "description": "Determines whether wrapcheck should report errors returned from inside the package.", + "type": "boolean", + "default": false } } }, @@ -4224,6 +4264,11 @@ } } }, + "path-mode": { + "type": "string", + "default": "", + "examples": ["abs"] + }, "path-prefix": { "description": "Add a prefix to the output file references.", "type": "string", @@ -4318,6 +4363,9 @@ "forbidigo": { "$ref": "#/definitions/settings/definitions/forbidigoSettings" }, + "funcorder": { + "$ref": "#/definitions/settings/definitions/funcorderSettings" + }, "funlen": { "$ref": "#/definitions/settings/definitions/funlenSettings" }, @@ -4626,6 +4674,10 @@ "items": { "type": "string" } + }, + "warn-unused": { + "type": "boolean", + "default": false } } } diff --git a/jsonschema/golangci.next.jsonschema.json b/jsonschema/golangci.next.jsonschema.json index 996a5ec3721f..0f2ef5fcc50b 100644 --- a/jsonschema/golangci.next.jsonschema.json +++ b/jsonschema/golangci.next.jsonschema.json @@ -665,6 +665,7 @@ }, "tagliatelle-cases": { "enum": [ + "", "camel", "pascal", "kebab", diff --git a/jsonschema/golangci.v1.64.jsonschema.json b/jsonschema/golangci.v1.64.jsonschema.json index f80ccf06235a..b265c1a8233c 100644 --- a/jsonschema/golangci.v1.64.jsonschema.json +++ b/jsonschema/golangci.v1.64.jsonschema.json @@ -310,6 +310,7 @@ }, "tagliatelle-cases": { "enum": [ + "", "camel", "pascal", "kebab", From d9d46b459b8f1b025ae26a56c233a7bea881590f Mon Sep 17 00:00:00 2001 From: Fernandez Ludovic Date: Sat, 12 Apr 2025 20:08:41 +0200 Subject: [PATCH 03/96] chore: downgrade goreleaser to v2.8.1 Related to a regression inside v2.8.2 --- .github/workflows/release.yml | 2 +- jsonschema/golangci.v1.jsonschema.json | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index e807c3aeaeb3..0a75cb50cfe3 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -69,7 +69,7 @@ jobs: - name: Create release uses: goreleaser/goreleaser-action@v6 with: - version: latest + version: v2.8.1 args: release --clean --timeout=90m env: AUR_KEY: ${{ secrets.AUR_KEY }} diff --git a/jsonschema/golangci.v1.jsonschema.json b/jsonschema/golangci.v1.jsonschema.json index f80ccf06235a..b265c1a8233c 100644 --- a/jsonschema/golangci.v1.jsonschema.json +++ b/jsonschema/golangci.v1.jsonschema.json @@ -310,6 +310,7 @@ }, "tagliatelle-cases": { "enum": [ + "", "camel", "pascal", "kebab", From 93dabf9013aa0cea82ad58e5f90146fc2e62587b Mon Sep 17 00:00:00 2001 From: Fernandez Ludovic Date: Sat, 12 Apr 2025 20:12:29 +0200 Subject: [PATCH 04/96] chore: prepare release --- CHANGELOG.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index d8161a8a8c9b..9be50477f621 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,11 @@ If you value it, consider supporting us, we appreciate it! ❤️ [![Open Collective backers and sponsors](https://img.shields.io/badge/OpenCollective-Donate-blue?logo=opencollective&style=for-the-badge)](https://opencollective.com/golangci-lint) [![GitHub Sponsors](https://img.shields.io/badge/GitHub-Donate-blue?logo=github&style=for-the-badge)](https://github.com/sponsors/golangci) +### v2.1.1 + +The release process of the v2.1.0 as failed due to a regression inside goreleaser. +The binaries of v2.1.0 has been published but not the other articfacts (AUR, Docker, etc.) + ### v2.1.0 1. Enhancements From d1b1db7a7cd23e633149c65de1a86a1b3d7e597e Mon Sep 17 00:00:00 2001 From: Fernandez Ludovic Date: Sat, 12 Apr 2025 20:47:50 +0200 Subject: [PATCH 05/96] docs: update changelog --- CHANGELOG.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9be50477f621..e6d6689591c4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,8 +9,9 @@ If you value it, consider supporting us, we appreciate it! ❤️ ### v2.1.1 -The release process of the v2.1.0 as failed due to a regression inside goreleaser. -The binaries of v2.1.0 has been published but not the other articfacts (AUR, Docker, etc.) +The release process of v2.1.0 failed due to a regression inside goreleaser. + +The binaries of v2.1.0 have been published, but not the other artifacts (AUR, Docker, etc.). ### v2.1.0 From 50f7446eda68cbf0219a8b09d6421a023e4d7543 Mon Sep 17 00:00:00 2001 From: GolangCI-Lint Releaser <65486276+golangci-releaser@users.noreply.github.com> Date: Sat, 12 Apr 2025 20:53:32 +0200 Subject: [PATCH 06/96] docs: update GitHub Action assets (#5724) --- assets/github-action-config-v2.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/assets/github-action-config-v2.json b/assets/github-action-config-v2.json index a0a27322f486..470995520d2c 100644 --- a/assets/github-action-config-v2.json +++ b/assets/github-action-config-v2.json @@ -1,7 +1,7 @@ { "MinorVersionToConfig": { "latest": { - "TargetVersion": "v2.1.0" + "TargetVersion": "v2.1.1" }, "v1.10": { "Error": "golangci-lint version 'v1.10' isn't supported: we support only v2.0.0 and later versions" @@ -193,7 +193,7 @@ "TargetVersion": "v2.0.2" }, "v2.1": { - "TargetVersion": "v2.1.0" + "TargetVersion": "v2.1.1" } } } From 997470cefa6efbcf9ff8387e8c4343d2307c7f94 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 14 Apr 2025 00:10:11 +0200 Subject: [PATCH 07/96] build(deps): bump github.com/ghostiam/protogetter from 0.3.13 to 0.3.14 (#5727) --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index c229136ae43d..478da1d73d14 100644 --- a/go.mod +++ b/go.mod @@ -40,7 +40,7 @@ require ( github.com/fatih/color v1.18.0 github.com/firefart/nonamedreturns v1.0.6 github.com/fzipp/gocyclo v0.6.0 - github.com/ghostiam/protogetter v0.3.13 + github.com/ghostiam/protogetter v0.3.14 github.com/go-critic/go-critic v0.13.0 github.com/go-viper/mapstructure/v2 v2.2.1 github.com/go-xmlfmt/xmlfmt v1.1.3 diff --git a/go.sum b/go.sum index f657816a2e6c..055044042393 100644 --- a/go.sum +++ b/go.sum @@ -172,8 +172,8 @@ github.com/fsnotify/fsnotify v1.5.4 h1:jRbGcIw6P2Meqdwuo0H1p6JVLbL5DHKAKlYndzMwV github.com/fsnotify/fsnotify v1.5.4/go.mod h1:OVB6XrOHzAwXMpEM7uPOzcehqUV2UqJxmVXmkdnm1bU= github.com/fzipp/gocyclo v0.6.0 h1:lsblElZG7d3ALtGMx9fmxeTKZaLLpU8mET09yN4BBLo= github.com/fzipp/gocyclo v0.6.0/go.mod h1:rXPyn8fnlpa0R2csP/31uerbiVBugk5whMdlyaLkLoA= -github.com/ghostiam/protogetter v0.3.13 h1:T4qt1JU0xvx8+jO30+JaA49fngUd6YNajqwk0Rn3t1s= -github.com/ghostiam/protogetter v0.3.13/go.mod h1:WZ0nw9pfzsgxuRsPOFQomgDVSWtDLJRfQJEhsGbmQMA= +github.com/ghostiam/protogetter v0.3.14 h1:4vabcsVL3M4YDaAcq3r0nDVRPjfVGxJCEk5viVY+TuI= +github.com/ghostiam/protogetter v0.3.14/go.mod h1:WZ0nw9pfzsgxuRsPOFQomgDVSWtDLJRfQJEhsGbmQMA= github.com/go-critic/go-critic v0.13.0 h1:kJzM7wzltQasSUXtYyTl6UaPVySO6GkaR1thFnJ6afY= github.com/go-critic/go-critic v0.13.0/go.mod h1:M/YeuJ3vOCQDnP2SU+ZhjgRzwzcBW87JqLpMJLrZDLI= github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU= From 624edd14d9ee6b0ea8248639913de7435d33a9a0 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 14 Apr 2025 00:24:36 +0200 Subject: [PATCH 08/96] build(deps): bump mvdan.cc/gofumpt from 0.7.0 to 0.8.0 (#5728) --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 478da1d73d14..0a7572c96443 100644 --- a/go.mod +++ b/go.mod @@ -133,7 +133,7 @@ require ( golang.org/x/tools v0.32.0 gopkg.in/yaml.v3 v3.0.1 honnef.co/go/tools v0.6.1 - mvdan.cc/gofumpt v0.7.0 + mvdan.cc/gofumpt v0.8.0 mvdan.cc/unparam v0.0.0-20250301125049-0df0534333a4 ) diff --git a/go.sum b/go.sum index 055044042393..1b873c45f40b 100644 --- a/go.sum +++ b/go.sum @@ -1015,8 +1015,8 @@ honnef.co/go/tools v0.0.1-2020.1.3/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9 honnef.co/go/tools v0.0.1-2020.1.4/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= honnef.co/go/tools v0.6.1 h1:R094WgE8K4JirYjBaOpz/AvTyUu/3wbmAoskKN/pxTI= honnef.co/go/tools v0.6.1/go.mod h1:3puzxxljPCe8RGJX7BIy1plGbxEOZni5mR2aXe3/uk4= -mvdan.cc/gofumpt v0.7.0 h1:bg91ttqXmi9y2xawvkuMXyvAA/1ZGJqYAEGjXuP0JXU= -mvdan.cc/gofumpt v0.7.0/go.mod h1:txVFJy/Sc/mvaycET54pV8SW8gWxTlUuGHVEcncmNUo= +mvdan.cc/gofumpt v0.8.0 h1:nZUCeC2ViFaerTcYKstMmfysj6uhQrA2vJe+2vwGU6k= +mvdan.cc/gofumpt v0.8.0/go.mod h1:vEYnSzyGPmjvFkqJWtXkh79UwPWP9/HMxQdGEXZHjpg= mvdan.cc/unparam v0.0.0-20250301125049-0df0534333a4 h1:WjUu4yQoT5BHT1w8Zu56SP8367OuBV5jvo+4Ulppyf8= mvdan.cc/unparam v0.0.0-20250301125049-0df0534333a4/go.mod h1:rthT7OuvRbaGcd5ginj6dA2oLE7YNlta9qhBNNdCaLE= rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8= From 15817283fd6b2c1049f5f8215df94084a9597cd4 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 14 Apr 2025 02:42:41 +0200 Subject: [PATCH 09/96] build(deps): bump github.com/ldez/exptostd from 0.4.2 to 0.4.3 (#5730) --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 0a7572c96443..9e2018998f69 100644 --- a/go.mod +++ b/go.mod @@ -67,7 +67,7 @@ require ( github.com/kulti/thelper v0.6.3 github.com/kunwardeep/paralleltest v1.0.14 github.com/lasiar/canonicalheader v1.1.2 - github.com/ldez/exptostd v0.4.2 + github.com/ldez/exptostd v0.4.3 github.com/ldez/gomoddirectives v0.6.1 github.com/ldez/grignotin v0.9.0 github.com/ldez/tagliatelle v0.7.1 diff --git a/go.sum b/go.sum index 1b873c45f40b..c1d7f1fc4a55 100644 --- a/go.sum +++ b/go.sum @@ -371,8 +371,8 @@ github.com/kunwardeep/paralleltest v1.0.14 h1:wAkMoMeGX/kGfhQBPODT/BL8XhK23ol/nu github.com/kunwardeep/paralleltest v1.0.14/go.mod h1:di4moFqtfz3ToSKxhNjhOZL+696QtJGCFe132CbBLGk= github.com/lasiar/canonicalheader v1.1.2 h1:vZ5uqwvDbyJCnMhmFYimgMZnJMjwljN5VGY0VKbMXb4= github.com/lasiar/canonicalheader v1.1.2/go.mod h1:qJCeLFS0G/QlLQ506T+Fk/fWMa2VmBUiEI2cuMK4djI= -github.com/ldez/exptostd v0.4.2 h1:l5pOzHBz8mFOlbcifTxzfyYbgEmoUqjxLFHZkjlbHXs= -github.com/ldez/exptostd v0.4.2/go.mod h1:iZBRYaUmcW5jwCR3KROEZ1KivQQp6PHXbDPk9hqJKCQ= +github.com/ldez/exptostd v0.4.3 h1:Ag1aGiq2epGePuRJhez2mzOpZ8sI9Gimcb4Sb3+pk9Y= +github.com/ldez/exptostd v0.4.3/go.mod h1:iZBRYaUmcW5jwCR3KROEZ1KivQQp6PHXbDPk9hqJKCQ= github.com/ldez/gomoddirectives v0.6.1 h1:Z+PxGAY+217f/bSGjNZr/b2KTXcyYLgiWI6geMBN2Qc= github.com/ldez/gomoddirectives v0.6.1/go.mod h1:cVBiu3AHR9V31em9u2kwfMKD43ayN5/XDgr+cdaFaKs= github.com/ldez/grignotin v0.9.0 h1:MgOEmjZIVNn6p5wPaGp/0OKWyvq42KnzAt/DAb8O4Ow= From 3afce899b2a3b477168b847c34d565c62d4fad18 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 14 Apr 2025 02:42:47 +0200 Subject: [PATCH 10/96] build(deps): bump github.com/ldez/usetesting from 0.4.2 to 0.4.3 (#5729) --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 9e2018998f69..d70d8f9e5569 100644 --- a/go.mod +++ b/go.mod @@ -71,7 +71,7 @@ require ( github.com/ldez/gomoddirectives v0.6.1 github.com/ldez/grignotin v0.9.0 github.com/ldez/tagliatelle v0.7.1 - github.com/ldez/usetesting v0.4.2 + github.com/ldez/usetesting v0.4.3 github.com/leonklingele/grouper v1.1.2 github.com/macabu/inamedparam v0.2.0 github.com/manuelarte/funcorder v0.2.1 diff --git a/go.sum b/go.sum index c1d7f1fc4a55..7a42d3c50572 100644 --- a/go.sum +++ b/go.sum @@ -379,8 +379,8 @@ github.com/ldez/grignotin v0.9.0 h1:MgOEmjZIVNn6p5wPaGp/0OKWyvq42KnzAt/DAb8O4Ow= github.com/ldez/grignotin v0.9.0/go.mod h1:uaVTr0SoZ1KBii33c47O1M8Jp3OP3YDwhZCmzT9GHEk= github.com/ldez/tagliatelle v0.7.1 h1:bTgKjjc2sQcsgPiT902+aadvMjCeMHrY7ly2XKFORIk= github.com/ldez/tagliatelle v0.7.1/go.mod h1:3zjxUpsNB2aEZScWiZTHrAXOl1x25t3cRmzfK1mlo2I= -github.com/ldez/usetesting v0.4.2 h1:J2WwbrFGk3wx4cZwSMiCQQ00kjGR0+tuuyW0Lqm4lwA= -github.com/ldez/usetesting v0.4.2/go.mod h1:eEs46T3PpQ+9RgN9VjpY6qWdiw2/QmfiDeWmdZdrjIQ= +github.com/ldez/usetesting v0.4.3 h1:pJpN0x3fMupdTf/IapYjnkhiY1nSTN+pox1/GyBRw3k= +github.com/ldez/usetesting v0.4.3/go.mod h1:eEs46T3PpQ+9RgN9VjpY6qWdiw2/QmfiDeWmdZdrjIQ= github.com/leonklingele/grouper v1.1.2 h1:o1ARBDLOmmasUaNDesWqWCIFH3u7hoFlM84YrjT3mIY= github.com/leonklingele/grouper v1.1.2/go.mod h1:6D0M/HVkhs2yRKRFZUoGjeDy7EZTfFBE9gl4kjmIGkA= github.com/lucasb-eyer/go-colorful v1.2.0 h1:1nnpGOrhyZZuNyfu1QjKiUICQ74+3FNCN69Aj6K7nkY= From a05ea26b7bce86298e3e7fa6800af90142122675 Mon Sep 17 00:00:00 2001 From: Oleksandr Redko Date: Mon, 14 Apr 2025 14:16:29 +0300 Subject: [PATCH 11/96] dev: simplify mnd implementation (#5731) --- pkg/golinters/mnd/mnd.go | 7 +++---- pkg/golinters/mnd/testdata/mnd_custom.go | 24 +++++++++++++++++++++++ pkg/golinters/mnd/testdata/mnd_custom.yml | 7 +++++++ 3 files changed, 34 insertions(+), 4 deletions(-) create mode 100644 pkg/golinters/mnd/testdata/mnd_custom.go create mode 100644 pkg/golinters/mnd/testdata/mnd_custom.yml diff --git a/pkg/golinters/mnd/mnd.go b/pkg/golinters/mnd/mnd.go index 744186bc3e63..52521e92dd15 100644 --- a/pkg/golinters/mnd/mnd.go +++ b/pkg/golinters/mnd/mnd.go @@ -9,11 +9,10 @@ import ( ) func New(settings *config.MndSettings) *goanalysis.Linter { - return newMND(mnd.Analyzer, settings, nil) -} + a := mnd.Analyzer -func newMND(a *analysis.Analyzer, settings *config.MndSettings, linterCfg map[string]map[string]any) *goanalysis.Linter { - if len(linterCfg) == 0 && settings != nil { + var linterCfg map[string]map[string]any + if settings != nil { cfg := make(map[string]any) if len(settings.Checks) > 0 { cfg["checks"] = settings.Checks diff --git a/pkg/golinters/mnd/testdata/mnd_custom.go b/pkg/golinters/mnd/testdata/mnd_custom.go new file mode 100644 index 000000000000..75530516b3ab --- /dev/null +++ b/pkg/golinters/mnd/testdata/mnd_custom.go @@ -0,0 +1,24 @@ +//golangcitest:args -Emnd +//golangcitest:config_path testdata/mnd_custom.yml +package testdata + +import ( + "log" + "net/http" + "time" +) + +func Mnd() { + c := &http.Client{ + Timeout: 5 * time.Second, + } + + res, err := c.Get("https://www.google.com") + if err != nil { + log.Fatal(err) + } + defer res.Body.Close() + if res.StatusCode != 200 { // want "Magic number: 200, in detected" + log.Println("Something went wrong") + } +} diff --git a/pkg/golinters/mnd/testdata/mnd_custom.yml b/pkg/golinters/mnd/testdata/mnd_custom.yml new file mode 100644 index 000000000000..7987bf91019e --- /dev/null +++ b/pkg/golinters/mnd/testdata/mnd_custom.yml @@ -0,0 +1,7 @@ +version: "2" + +linters: + settings: + mnd: + ignored-numbers: + - '5' From 7dde13b4c5c8972cba342bde837b1e7aeddbb16b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 14 Apr 2025 17:26:31 +0200 Subject: [PATCH 12/96] build(deps): bump github.com/ghostiam/protogetter from 0.3.14 to 0.3.15 (#5732) --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index d70d8f9e5569..00695fdf37ad 100644 --- a/go.mod +++ b/go.mod @@ -40,7 +40,7 @@ require ( github.com/fatih/color v1.18.0 github.com/firefart/nonamedreturns v1.0.6 github.com/fzipp/gocyclo v0.6.0 - github.com/ghostiam/protogetter v0.3.14 + github.com/ghostiam/protogetter v0.3.15 github.com/go-critic/go-critic v0.13.0 github.com/go-viper/mapstructure/v2 v2.2.1 github.com/go-xmlfmt/xmlfmt v1.1.3 diff --git a/go.sum b/go.sum index 7a42d3c50572..9bc80fb7cd9b 100644 --- a/go.sum +++ b/go.sum @@ -172,8 +172,8 @@ github.com/fsnotify/fsnotify v1.5.4 h1:jRbGcIw6P2Meqdwuo0H1p6JVLbL5DHKAKlYndzMwV github.com/fsnotify/fsnotify v1.5.4/go.mod h1:OVB6XrOHzAwXMpEM7uPOzcehqUV2UqJxmVXmkdnm1bU= github.com/fzipp/gocyclo v0.6.0 h1:lsblElZG7d3ALtGMx9fmxeTKZaLLpU8mET09yN4BBLo= github.com/fzipp/gocyclo v0.6.0/go.mod h1:rXPyn8fnlpa0R2csP/31uerbiVBugk5whMdlyaLkLoA= -github.com/ghostiam/protogetter v0.3.14 h1:4vabcsVL3M4YDaAcq3r0nDVRPjfVGxJCEk5viVY+TuI= -github.com/ghostiam/protogetter v0.3.14/go.mod h1:WZ0nw9pfzsgxuRsPOFQomgDVSWtDLJRfQJEhsGbmQMA= +github.com/ghostiam/protogetter v0.3.15 h1:1KF5sXel0HE48zh1/vn0Loiw25A9ApyseLzQuif1mLY= +github.com/ghostiam/protogetter v0.3.15/go.mod h1:WZ0nw9pfzsgxuRsPOFQomgDVSWtDLJRfQJEhsGbmQMA= github.com/go-critic/go-critic v0.13.0 h1:kJzM7wzltQasSUXtYyTl6UaPVySO6GkaR1thFnJ6afY= github.com/go-critic/go-critic v0.13.0/go.mod h1:M/YeuJ3vOCQDnP2SU+ZhjgRzwzcBW87JqLpMJLrZDLI= github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU= From 6de1453c15a923e0b2782e7fdb6d8c58d38e7313 Mon Sep 17 00:00:00 2001 From: Chris Reeves Date: Tue, 15 Apr 2025 11:51:51 +0100 Subject: [PATCH 13/96] docs: fix default value of linters.exclusions.generated (#5735) --- .golangci.next.reference.yml | 4 ++-- .golangci.reference.yml | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.golangci.next.reference.yml b/.golangci.next.reference.yml index cababbea228f..37866ff00f2c 100644 --- a/.golangci.next.reference.yml +++ b/.golangci.next.reference.yml @@ -3902,8 +3902,8 @@ linters: # - `lax`: sources are excluded if they contain lines like `autogenerated file`, `code generated`, `do not edit`, etc. # - `disable`: disable the generated files exclusion. # - # Default: lax - generated: strict + # Default: strict + generated: lax # Log a warning if an exclusion rule is unused. # Default: false warn-unused: true diff --git a/.golangci.reference.yml b/.golangci.reference.yml index cababbea228f..37866ff00f2c 100644 --- a/.golangci.reference.yml +++ b/.golangci.reference.yml @@ -3902,8 +3902,8 @@ linters: # - `lax`: sources are excluded if they contain lines like `autogenerated file`, `code generated`, `do not edit`, etc. # - `disable`: disable the generated files exclusion. # - # Default: lax - generated: strict + # Default: strict + generated: lax # Log a warning if an exclusion rule is unused. # Default: false warn-unused: true From 00a561d9a79578a2800dece2f04c60ad479a3798 Mon Sep 17 00:00:00 2001 From: Fernandez Ludovic Date: Mon, 14 Apr 2025 00:27:34 +0200 Subject: [PATCH 14/96] chore: prepare release --- CHANGELOG.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index e6d6689591c4..08b729267d2c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,14 @@ If you value it, consider supporting us, we appreciate it! ❤️ [![Open Collective backers and sponsors](https://img.shields.io/badge/OpenCollective-Donate-blue?logo=opencollective&style=for-the-badge)](https://opencollective.com/golangci-lint) [![GitHub Sponsors](https://img.shields.io/badge/GitHub-Donate-blue?logo=github&style=for-the-badge)](https://github.com/sponsors/golangci) +### v2.1.2 + +1. Linters bug fixes + * `exptostd`: from 0.4.2 to 0.4.3 + * `gofumpt`: from 0.7.0 to 0.8.0 + * `protogetter`: from 0.3.13 to 0.3.15 + * `usetesting`: from 0.4.2 to 0.4.3 + ### v2.1.1 The release process of v2.1.0 failed due to a regression inside goreleaser. From 50e1e98922da68aa39dc17b1293842031114cf14 Mon Sep 17 00:00:00 2001 From: GolangCI-Lint Releaser <65486276+golangci-releaser@users.noreply.github.com> Date: Tue, 15 Apr 2025 16:07:47 +0200 Subject: [PATCH 15/96] docs: update GitHub Action assets (#5738) --- assets/github-action-config-v2.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/assets/github-action-config-v2.json b/assets/github-action-config-v2.json index 470995520d2c..4ec367aa9ef7 100644 --- a/assets/github-action-config-v2.json +++ b/assets/github-action-config-v2.json @@ -1,7 +1,7 @@ { "MinorVersionToConfig": { "latest": { - "TargetVersion": "v2.1.1" + "TargetVersion": "v2.1.2" }, "v1.10": { "Error": "golangci-lint version 'v1.10' isn't supported: we support only v2.0.0 and later versions" @@ -193,7 +193,7 @@ "TargetVersion": "v2.0.2" }, "v2.1": { - "TargetVersion": "v2.1.1" + "TargetVersion": "v2.1.2" } } } From 60f4cffc211d3719e68f3318ed90ae7d687c2246 Mon Sep 17 00:00:00 2001 From: Nikita Mironov Date: Wed, 16 Apr 2025 13:01:09 +0200 Subject: [PATCH 16/96] docs: update section about GoLand integration (#5740) --- docs/src/docs/welcome/integrations.mdx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/src/docs/welcome/integrations.mdx b/docs/src/docs/welcome/integrations.mdx index 8658e2aa3f5c..02850e1a60c7 100644 --- a/docs/src/docs/welcome/integrations.mdx +++ b/docs/src/docs/welcome/integrations.mdx @@ -6,9 +6,9 @@ title: Integrations ### GoLand -The integration for golangci-lint v2 is currently in work in progress: [GO-18363](https://youtrack.jetbrains.com/issue/GO-18363/Go-Linter-plugin-fails-with-golangci-lint-v2). - -Install [plugin](https://plugins.jetbrains.com/plugin/12496-go-linter). +Starting from the version 2025.1, GoLand has built-in support of golangci-lint. +For IntelliJ IDEA with the Go plugin, please install the [plugin](https://plugins.jetbrains.com/plugin/12496-go-linter). +Both v1 and v2 versions are supported. ### Visual Studio Code From 43e07c47273e04c4d721ce3fef80562ab3333959 Mon Sep 17 00:00:00 2001 From: sivchari Date: Wed, 16 Apr 2025 23:46:05 +0900 Subject: [PATCH 17/96] fix: order of staticcheck settings during migration (#5741) Co-authored-by: Fernandez Ludovic --- .../migrate/migrate_linters_settings.go | 26 ++- ...ters-settings_staticcheck_merge.golden.yml | 204 ++++++++++++++++++ .../linters-settings_staticcheck_merge.yml | 172 +++++++++++++++ 3 files changed, 400 insertions(+), 2 deletions(-) create mode 100644 pkg/commands/internal/migrate/testdata/yaml/linters-settings_staticcheck_merge.golden.yml create mode 100644 pkg/commands/internal/migrate/testdata/yaml/linters-settings_staticcheck_merge.yml diff --git a/pkg/commands/internal/migrate/migrate_linters_settings.go b/pkg/commands/internal/migrate/migrate_linters_settings.go index a0559388d403..5accd9f593e5 100644 --- a/pkg/commands/internal/migrate/migrate_linters_settings.go +++ b/pkg/commands/internal/migrate/migrate_linters_settings.go @@ -789,10 +789,32 @@ func toSpancheckSettings(old versionone.SpancheckSettings) versiontwo.SpancheckS } func toStaticCheckSettings(old versionone.LintersSettings) versiontwo.StaticCheckSettings { - checks := slices.Concat(old.Staticcheck.Checks, old.Stylecheck.Checks, old.Gosimple.Checks) + var checks []string + + for _, check := range slices.Concat(old.Staticcheck.Checks, old.Stylecheck.Checks, old.Gosimple.Checks) { + if check == "*" { + checks = append(checks, "all") + continue + } + checks = append(checks, check) + } + + checks = Unique(checks) + + slices.SortFunc(checks, func(a, b string) int { + if a == "all" { + return -1 + } + + if b == "all" { + return 1 + } + + return strings.Compare(a, b) + }) return versiontwo.StaticCheckSettings{ - Checks: Unique(checks), + Checks: checks, Initialisms: old.Stylecheck.Initialisms, DotImportWhitelist: old.Stylecheck.DotImportWhitelist, HTTPStatusCodeWhitelist: old.Stylecheck.HTTPStatusCodeWhitelist, diff --git a/pkg/commands/internal/migrate/testdata/yaml/linters-settings_staticcheck_merge.golden.yml b/pkg/commands/internal/migrate/testdata/yaml/linters-settings_staticcheck_merge.golden.yml new file mode 100644 index 000000000000..229a095f01f8 --- /dev/null +++ b/pkg/commands/internal/migrate/testdata/yaml/linters-settings_staticcheck_merge.golden.yml @@ -0,0 +1,204 @@ +version: "2" +linters: + settings: + staticcheck: + checks: + - all + - -S1000 + - -S1001 + - -S1002 + - -SA1000 + - -SA1001 + - -SA1002 + - -ST1000 + - -ST1001 + - -ST1003 + - S1003 + - S1004 + - S1005 + - S1006 + - S1007 + - S1008 + - S1009 + - S1010 + - S1011 + - S1012 + - S1016 + - S1017 + - S1018 + - S1019 + - S1020 + - S1021 + - S1023 + - S1024 + - S1025 + - S1028 + - S1029 + - S1030 + - S1031 + - S1032 + - S1033 + - S1034 + - S1035 + - S1036 + - S1037 + - S1038 + - S1039 + - S1040 + - SA1003 + - SA1004 + - SA1005 + - SA1006 + - SA1007 + - SA1008 + - SA1010 + - SA1011 + - SA1012 + - SA1013 + - SA1014 + - SA1015 + - SA1016 + - SA1017 + - SA1018 + - SA1019 + - SA1020 + - SA1021 + - SA1023 + - SA1024 + - SA1025 + - SA1026 + - SA1027 + - SA1028 + - SA1029 + - SA1030 + - SA1031 + - SA1032 + - SA2000 + - SA2001 + - SA2002 + - SA2003 + - SA3000 + - SA3001 + - SA4000 + - SA4001 + - SA4003 + - SA4004 + - SA4005 + - SA4006 + - SA4008 + - SA4009 + - SA4010 + - SA4011 + - SA4012 + - SA4013 + - SA4014 + - SA4015 + - SA4016 + - SA4017 + - SA4018 + - SA4019 + - SA4020 + - SA4021 + - SA4022 + - SA4023 + - SA4024 + - SA4025 + - SA4026 + - SA4027 + - SA4028 + - SA4029 + - SA4030 + - SA4031 + - SA4032 + - SA5000 + - SA5001 + - SA5002 + - SA5003 + - SA5004 + - SA5005 + - SA5007 + - SA5008 + - SA5009 + - SA5010 + - SA5011 + - SA5012 + - SA6000 + - SA6001 + - SA6002 + - SA6003 + - SA6005 + - SA6006 + - SA9001 + - SA9002 + - SA9003 + - SA9004 + - SA9005 + - SA9006 + - SA9007 + - SA9008 + - SA9009 + - ST1005 + - ST1006 + - ST1008 + - ST1011 + - ST1012 + - ST1013 + - ST1015 + - ST1016 + - ST1017 + - ST1018 + - ST1019 + - ST1020 + - ST1021 + - ST1022 + - ST1023 + initialisms: + - ACL + - API + - ASCII + - CPU + - CSS + - DNS + - EOF + - GUID + - HTML + - HTTP + - HTTPS + - ID + - IP + - JSON + - QPS + - RAM + - RPC + - SLA + - SMTP + - SQL + - SSH + - TCP + - TLS + - TTL + - UDP + - UI + - GID + - UID + - UUID + - URI + - URL + - UTF8 + - VM + - XML + - XMPP + - XSRF + - XSS + - SIP + - RTP + - AMQP + - DB + - TS + dot-import-whitelist: + - fmt + http-status-code-whitelist: + - "200" + - "400" + - "404" + - "500" diff --git a/pkg/commands/internal/migrate/testdata/yaml/linters-settings_staticcheck_merge.yml b/pkg/commands/internal/migrate/testdata/yaml/linters-settings_staticcheck_merge.yml new file mode 100644 index 000000000000..3d9fe3cbbfc0 --- /dev/null +++ b/pkg/commands/internal/migrate/testdata/yaml/linters-settings_staticcheck_merge.yml @@ -0,0 +1,172 @@ +issues: + # Only to not generate unrelated elements inside golden. + exclude-use-default: false + # Only to not generate unrelated elements inside golden. + exclude-generated: strict + # Only to not generate unrelated elements inside golden. + exclude-dirs-use-default: false + +linters-settings: + staticcheck: + checks: + - all + - '-SA1000' + - '-SA1001' + - '-SA1002' + - SA1003 + - SA1004 + - SA1005 + - SA1006 + - SA1007 + - SA1008 + - SA1010 + - SA1011 + - SA1012 + - SA1013 + - SA1014 + - SA1015 + - SA1016 + - SA1017 + - SA1018 + - SA1019 + - SA1020 + - SA1021 + - SA1023 + - SA1024 + - SA1025 + - SA1026 + - SA1027 + - SA1028 + - SA1029 + - SA1030 + - SA1031 + - SA1032 + - SA2000 + - SA2001 + - SA2002 + - SA2003 + - SA3000 + - SA3001 + - SA4000 + - SA4001 + - SA4003 + - SA4004 + - SA4005 + - SA4006 + - SA4008 + - SA4009 + - SA4010 + - SA4011 + - SA4012 + - SA4013 + - SA4014 + - SA4015 + - SA4016 + - SA4017 + - SA4018 + - SA4019 + - SA4020 + - SA4021 + - SA4022 + - SA4023 + - SA4024 + - SA4025 + - SA4026 + - SA4027 + - SA4028 + - SA4029 + - SA4030 + - SA4031 + - SA4032 + - SA5000 + - SA5001 + - SA5002 + - SA5003 + - SA5004 + - SA5005 + - SA5007 + - SA5008 + - SA5009 + - SA5010 + - SA5011 + - SA5012 + - SA6000 + - SA6001 + - SA6002 + - SA6003 + - SA6005 + - SA6006 + - SA9001 + - SA9002 + - SA9003 + - SA9004 + - SA9005 + - SA9006 + - SA9007 + - SA9008 + - SA9009 + + gosimple: + checks: + - '*' + - '-S1000' + - '-S1001' + - '-S1002' + - S1003 + - S1004 + - S1005 + - S1006 + - S1007 + - S1008 + - S1009 + - S1010 + - S1011 + - S1012 + - S1016 + - S1017 + - S1018 + - S1019 + - S1020 + - S1021 + - S1023 + - S1024 + - S1025 + - S1028 + - S1029 + - S1030 + - S1031 + - S1032 + - S1033 + - S1034 + - S1035 + - S1036 + - S1037 + - S1038 + - S1039 + - S1040 + + stylecheck: + dot-import-whitelist: + - fmt + initialisms: [ "ACL", "API", "ASCII", "CPU", "CSS", "DNS", "EOF", "GUID", "HTML", "HTTP", "HTTPS", "ID", "IP", "JSON", "QPS", "RAM", "RPC", "SLA", "SMTP", "SQL", "SSH", "TCP", "TLS", "TTL", "UDP", "UI", "GID", "UID", "UUID", "URI", "URL", "UTF8", "VM", "XML", "XMPP", "XSRF", "XSS", "SIP", "RTP", "AMQP", "DB", "TS" ] + http-status-code-whitelist: [ "200", "400", "404", "500" ] + checks: + - all + - '-ST1000' + - '-ST1001' + - '-ST1003' + - ST1005 + - ST1006 + - ST1008 + - ST1011 + - ST1012 + - ST1013 + - ST1015 + - ST1016 + - ST1017 + - ST1018 + - ST1019 + - ST1020 + - ST1021 + - ST1022 + - ST1023 From f1e4d89b5b2cf524e0aa095173c7ec4145eebb68 Mon Sep 17 00:00:00 2001 From: Ludovic Fernandez Date: Wed, 16 Apr 2025 16:46:16 +0200 Subject: [PATCH 18/96] fix: add go.mod hash to the cache salt (#5739) --- pkg/commands/run.go | 43 ++++++++++++++++++++++++++++++++++++++-- pkg/config/config.go | 12 ++++++++--- pkg/config/loader.go | 2 +- pkg/logutils/logutils.go | 1 + 4 files changed, 52 insertions(+), 6 deletions(-) diff --git a/pkg/commands/run.go b/pkg/commands/run.go index a3e9df6de3fc..53902eafac24 100644 --- a/pkg/commands/run.go +++ b/pkg/commands/run.go @@ -21,10 +21,12 @@ import ( "github.com/fatih/color" "github.com/gofrs/flock" + "github.com/ldez/grignotin/goenv" "github.com/spf13/cobra" "github.com/spf13/pflag" "github.com/spf13/viper" "go.uber.org/automaxprocs/maxprocs" + "golang.org/x/mod/sumdb/dirhash" "gopkg.in/yaml.v3" "github.com/golangci/golangci-lint/v2/internal/cache" @@ -216,7 +218,7 @@ func (c *runCommand) preRunE(_ *cobra.Command, args []string) error { c.contextBuilder = lint.NewContextBuilder(c.cfg, pkgLoader, pkgCache, guard) - if err = initHashSalt(c.buildInfo.Version, c.cfg); err != nil { + if err = initHashSalt(c.log.Child(logutils.DebugKeyGoModSalt), c.buildInfo.Version, c.cfg); err != nil { return fmt.Errorf("failed to init hash salt: %w", err) } @@ -618,7 +620,7 @@ func formatMemory(memBytes uint64) string { // Related to cache. -func initHashSalt(version string, cfg *config.Config) error { +func initHashSalt(logger logutils.Log, version string, cfg *config.Config) error { binSalt, err := computeBinarySalt(version) if err != nil { return fmt.Errorf("failed to calculate binary salt: %w", err) @@ -629,9 +631,18 @@ func initHashSalt(version string, cfg *config.Config) error { return fmt.Errorf("failed to calculate config salt: %w", err) } + goModSalt, err := computeGoModSalt() + if err != nil { + // NOTE: missing go.mod must be ignored. + logger.Warnf("Failed to calculate go.mod salt: %v", err) + } + b := bytes.NewBuffer(binSalt) b.Write(configSalt) + b.WriteString(goModSalt) + cache.SetSalt(b) + return nil } @@ -648,15 +659,19 @@ func computeBinarySalt(version string) ([]byte, error) { if err != nil { return nil, err } + f, err := os.Open(p) if err != nil { return nil, err } + defer f.Close() + h := sha256.New() if _, err := io.Copy(h, f); err != nil { return nil, err } + return h.Sum(nil), nil } @@ -678,5 +693,29 @@ func computeConfigSalt(cfg *config.Config) ([]byte, error) { if _, err := h.Write(configData.Bytes()); err != nil { return nil, err } + return h.Sum(nil), nil } + +func computeGoModSalt() (string, error) { + values, err := goenv.Get(context.Background(), goenv.GOMOD) + if err != nil { + return "", fmt.Errorf("failed to get goenv: %w", err) + } + + goModPath := filepath.Clean(values[goenv.GOMOD]) + + data, err := os.ReadFile(goModPath) + if err != nil { + return "", fmt.Errorf("failed to read go.mod: %w", err) + } + + sum, err := dirhash.Hash1([]string{goModPath}, func(string) (io.ReadCloser, error) { + return io.NopCloser(bytes.NewReader(data)), nil + }) + if err != nil { + return "", fmt.Errorf("failed to compute go.sum: %w", err) + } + + return sum, nil +} diff --git a/pkg/config/config.go b/pkg/config/config.go index a6236a23f3af..6d7586621d8b 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -13,6 +13,8 @@ import ( "github.com/ldez/grignotin/goenv" "github.com/ldez/grignotin/gomod" "golang.org/x/mod/modfile" + + "github.com/golangci/golangci-lint/v2/pkg/logutils" ) // defaultGoVersion the value should be "oldstable" - 1. @@ -102,8 +104,8 @@ func IsGoGreaterThanOrEqual(current, limit string) bool { return v1.GreaterThanOrEqual(l) } -func detectGoVersion(ctx context.Context) string { - return cmp.Or(detectGoVersionFromGoMod(ctx), defaultGoVersion) +func detectGoVersion(ctx context.Context, log logutils.Log) string { + return cmp.Or(detectGoVersionFromGoMod(ctx, log), defaultGoVersion) } // detectGoVersionFromGoMod tries to get Go version from go.mod. @@ -111,7 +113,7 @@ func detectGoVersion(ctx context.Context) string { // else it returns `go` version if present, // else it returns `GOVERSION` version if present, // else it returns empty. -func detectGoVersionFromGoMod(ctx context.Context) string { +func detectGoVersionFromGoMod(ctx context.Context, log logutils.Log) string { values, err := goenv.Get(ctx, goenv.GOMOD, goenv.GOVERSION) if err != nil { values = map[string]string{ @@ -128,6 +130,10 @@ func detectGoVersionFromGoMod(ctx context.Context) string { return parseGoVersion(values[goenv.GOVERSION]) } + if file.Module != nil { + log.Infof("Module name %q", file.Module.Mod.Path) + } + // The toolchain exists only if 'toolchain' version > 'go' version. // If 'toolchain' version <= 'go' version, `go mod tidy` will remove 'toolchain' version from go.mod. if file.Toolchain != nil && file.Toolchain.Name != "" { diff --git a/pkg/config/loader.go b/pkg/config/loader.go index 19a17e7d71db..3ff9306486ab 100644 --- a/pkg/config/loader.go +++ b/pkg/config/loader.go @@ -161,7 +161,7 @@ func (l *Loader) checkConfigurationVersion() error { func (l *Loader) handleGoVersion() { if l.cfg.Run.Go == "" { - l.cfg.Run.Go = detectGoVersion(context.Background()) + l.cfg.Run.Go = detectGoVersion(context.Background(), l.log) } l.cfg.Linters.Settings.Govet.Go = l.cfg.Run.Go diff --git a/pkg/logutils/logutils.go b/pkg/logutils/logutils.go index 2fbb4a7b2493..0ee48a3664bd 100644 --- a/pkg/logutils/logutils.go +++ b/pkg/logutils/logutils.go @@ -17,6 +17,7 @@ const envDebug = "GL_DEBUG" const ( DebugKeyBinSalt = "bin_salt" + DebugKeyGoModSalt = "gomod_salt" DebugKeyConfigReader = "config_reader" DebugKeyEmpty = "" DebugKeyEnabledLinters = "enabled_linters" From 7326c96cc1e5664263ce376c47c7d03beca1fb10 Mon Sep 17 00:00:00 2001 From: Ludovic Fernandez Date: Wed, 16 Apr 2025 22:56:36 +0200 Subject: [PATCH 19/96] dev: disable check-generated job (#5742) --- .github/workflows/pr-checks.yml | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/.github/workflows/pr-checks.yml b/.github/workflows/pr-checks.yml index e46b77a06362..f5c69841abef 100644 --- a/.github/workflows/pr-checks.yml +++ b/.github/workflows/pr-checks.yml @@ -27,21 +27,22 @@ jobs: git diff --exit-code go.mod git diff --exit-code go.sum + # This check is disabled because of GitHub API instability: 504 Gateway Timeout. # Checks: GitHub action assets - check-generated: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - uses: actions/setup-go@v5 - with: - go-version: ${{ env.GO_VERSION }} - - name: Check generated files are up-to-date - run: make fast_check_generated - env: - # needed for github-action-config.json generation - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} +# check-generated: +# runs-on: ubuntu-latest +# steps: +# - uses: actions/checkout@v4 +# with: +# fetch-depth: 0 +# - uses: actions/setup-go@v5 +# with: +# go-version: ${{ env.GO_VERSION }} +# - name: Check generated files are up-to-date +# run: make fast_check_generated +# env: +# # needed for github-action-config.json generation +# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} check-local-install-script: name: Installation script (local) From 221803a464609c9c6454ff56752854260e4715f6 Mon Sep 17 00:00:00 2001 From: Ludovic Fernandez Date: Thu, 17 Apr 2025 23:02:11 +0200 Subject: [PATCH 20/96] fix: related information position (#5746) --- pkg/goanalysis/runners.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/pkg/goanalysis/runners.go b/pkg/goanalysis/runners.go index 5ffc1529363b..fe8d8fe854d3 100644 --- a/pkg/goanalysis/runners.go +++ b/pkg/goanalysis/runners.go @@ -136,10 +136,16 @@ func buildIssues(diags []Diagnostic, linterNameBuilder func(diag *Diagnostic) st if len(diag.Related) > 0 { for _, info := range diag.Related { + relatedPos := diag.Pkg.Fset.Position(info.Pos) + + if relatedPos.Filename != diag.Position.Filename { + relatedPos = diag.Position + } + issues = append(issues, result.Issue{ FromLinter: linterName, Text: fmt.Sprintf("%s(related information): %s", diag.Analyzer.Name, info.Message), - Pos: diag.Pkg.Fset.Position(info.Pos), + Pos: relatedPos, Pkg: diag.Pkg, }) } From c77bb6ba8cbd512446d576b43db9c196a1f1fb4d Mon Sep 17 00:00:00 2001 From: Ludovic Fernandez Date: Sat, 19 Apr 2025 16:25:44 +0200 Subject: [PATCH 21/96] docs: GoLand IDE only support v1 for now (#5750) --- docs/src/docs/welcome/integrations.mdx | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/docs/src/docs/welcome/integrations.mdx b/docs/src/docs/welcome/integrations.mdx index 02850e1a60c7..5ffa4c6e73db 100644 --- a/docs/src/docs/welcome/integrations.mdx +++ b/docs/src/docs/welcome/integrations.mdx @@ -6,9 +6,10 @@ title: Integrations ### GoLand -Starting from the version 2025.1, GoLand has built-in support of golangci-lint. +Starting from version 2025.1, GoLand has built-in support of golangci-lint. For IntelliJ IDEA with the Go plugin, please install the [plugin](https://plugins.jetbrains.com/plugin/12496-go-linter). -Both v1 and v2 versions are supported. + +**Only v1 is supported for now.** ### Visual Studio Code From d0588f0b92414cf65930b33e1b197428600a6359 Mon Sep 17 00:00:00 2001 From: Ludovic Fernandez Date: Mon, 21 Apr 2025 16:34:49 +0200 Subject: [PATCH 22/96] fix: convert uint as pointer of uint for the migration (#5755) --- .../internal/migrate/cloner/cloner.go | 2 +- .../linters-settings_nakedret_zero.golden.yml | 6 ++++ .../yaml/linters-settings_nakedret_zero.yml | 11 +++++++ .../migrate/versionone/linters_settings.go | 2 +- .../internal/migrate/versiontwo/formatters.go | 5 +-- .../migrate/versiontwo/linters_settings.go | 32 +++++++++++++------ .../internal/migrate/versiontwo/output.go | 3 +- 7 files changed, 47 insertions(+), 14 deletions(-) create mode 100644 pkg/commands/internal/migrate/testdata/yaml/linters-settings_nakedret_zero.golden.yml create mode 100644 pkg/commands/internal/migrate/testdata/yaml/linters-settings_nakedret_zero.yml diff --git a/pkg/commands/internal/migrate/cloner/cloner.go b/pkg/commands/internal/migrate/cloner/cloner.go index 9c2400bc69b1..9a94aaf8e070 100644 --- a/pkg/commands/internal/migrate/cloner/cloner.go +++ b/pkg/commands/internal/migrate/cloner/cloner.go @@ -142,7 +142,7 @@ func convertType(expr ast.Expr) ast.Expr { } switch ident.Name { - case "bool", "string", "int", "int8", "int16", "int32", "int64", "float32", "float64": + case "bool", "string", "uint", "uint8", "uint16", "uint32", "uint64", "int", "int8", "int16", "int32", "int64", "float32", "float64": return &ast.StarExpr{X: ident} default: diff --git a/pkg/commands/internal/migrate/testdata/yaml/linters-settings_nakedret_zero.golden.yml b/pkg/commands/internal/migrate/testdata/yaml/linters-settings_nakedret_zero.golden.yml new file mode 100644 index 000000000000..69e5a3b11394 --- /dev/null +++ b/pkg/commands/internal/migrate/testdata/yaml/linters-settings_nakedret_zero.golden.yml @@ -0,0 +1,6 @@ +version: "2" + +linters: + settings: + nakedret: + max-func-lines: 0 diff --git a/pkg/commands/internal/migrate/testdata/yaml/linters-settings_nakedret_zero.yml b/pkg/commands/internal/migrate/testdata/yaml/linters-settings_nakedret_zero.yml new file mode 100644 index 000000000000..c15f3c7bab1a --- /dev/null +++ b/pkg/commands/internal/migrate/testdata/yaml/linters-settings_nakedret_zero.yml @@ -0,0 +1,11 @@ +issues: + # Only to not generate unrelated elements inside golden. + exclude-use-default: false + # Only to not generate unrelated elements inside golden. + exclude-generated: strict + # Only to not generate unrelated elements inside golden. + exclude-dirs-use-default: false + +linters-settings: + nakedret: + max-func-lines: 0 diff --git a/pkg/commands/internal/migrate/versionone/linters_settings.go b/pkg/commands/internal/migrate/versionone/linters_settings.go index 49427c447530..44583b7d34e0 100644 --- a/pkg/commands/internal/migrate/versionone/linters_settings.go +++ b/pkg/commands/internal/migrate/versionone/linters_settings.go @@ -489,7 +489,7 @@ type MustTagSettings struct { } type NakedretSettings struct { - MaxFuncLines uint `mapstructure:"max-func-lines"` + MaxFuncLines *uint `mapstructure:"max-func-lines"` } type NestifSettings struct { diff --git a/pkg/commands/internal/migrate/versiontwo/formatters.go b/pkg/commands/internal/migrate/versiontwo/formatters.go index bd1b6f931155..417714947a69 100644 --- a/pkg/commands/internal/migrate/versiontwo/formatters.go +++ b/pkg/commands/internal/migrate/versiontwo/formatters.go @@ -9,6 +9,7 @@ type Formatters struct { } type FormatterExclusions struct { - Generated *string `yaml:"generated,omitempty" toml:"generated,multiline,omitempty"` - Paths []string `yaml:"paths,omitempty" toml:"paths,multiline,omitempty"` + Generated *string `yaml:"generated,omitempty" toml:"generated,multiline,omitempty"` + Paths []string `yaml:"paths,omitempty" toml:"paths,multiline,omitempty"` + WarnUnused *bool `yaml:"warn-unused,omitempty" toml:"warn-unused,multiline,omitempty"` } diff --git a/pkg/commands/internal/migrate/versiontwo/linters_settings.go b/pkg/commands/internal/migrate/versiontwo/linters_settings.go index 3461620e20f7..3a0d6b7b6a2a 100644 --- a/pkg/commands/internal/migrate/versiontwo/linters_settings.go +++ b/pkg/commands/internal/migrate/versiontwo/linters_settings.go @@ -21,6 +21,7 @@ type LintersSettings struct { Exhaustruct ExhaustructSettings `yaml:"exhaustruct,omitempty" toml:"exhaustruct,multiline,omitempty"` Fatcontext FatcontextSettings `yaml:"fatcontext,omitempty" toml:"fatcontext,multiline,omitempty"` Forbidigo ForbidigoSettings `yaml:"forbidigo,omitempty" toml:"forbidigo,multiline,omitempty"` + FuncOrder FuncOrderSettings `yaml:"funcorder,omitempty" toml:"funcorder,multiline,omitempty"` Funlen FunlenSettings `yaml:"funlen,omitempty" toml:"funlen,multiline,omitempty"` GinkgoLinter GinkgoLinterSettings `yaml:"ginkgolinter,omitempty" toml:"ginkgolinter,multiline,omitempty"` Gocognit GocognitSettings `yaml:"gocognit,omitempty" toml:"gocognit,multiline,omitempty"` @@ -210,6 +211,11 @@ type ForbidigoPattern struct { Msg *string `yaml:"msg,omitempty,omitempty" toml:"msg,omitempty,multiline,omitempty"` } +type FuncOrderSettings struct { + Constructor *bool `yaml:"constructor,omitempty,omitempty" toml:"constructor,omitempty,multiline,omitempty"` + StructMethod *bool `yaml:"struct-method,omitempty,omitempty" toml:"struct-method,omitempty,multiline,omitempty"` +} + type FunlenSettings struct { Lines *int `yaml:"lines,omitempty" toml:"lines,multiline,omitempty"` Statements *int `yaml:"statements,omitempty" toml:"statements,multiline,omitempty"` @@ -241,14 +247,18 @@ type GocognitSettings struct { } type GoConstSettings struct { - IgnoreStrings *string `yaml:"ignore-strings,omitempty" toml:"ignore-strings,multiline,omitempty"` - MatchWithConstants *bool `yaml:"match-constant,omitempty" toml:"match-constant,multiline,omitempty"` - MinStringLen *int `yaml:"min-len,omitempty" toml:"min-len,multiline,omitempty"` - MinOccurrencesCount *int `yaml:"min-occurrences,omitempty" toml:"min-occurrences,multiline,omitempty"` - ParseNumbers *bool `yaml:"numbers,omitempty" toml:"numbers,multiline,omitempty"` - NumberMin *int `yaml:"min,omitempty" toml:"min,multiline,omitempty"` - NumberMax *int `yaml:"max,omitempty" toml:"max,multiline,omitempty"` - IgnoreCalls *bool `yaml:"ignore-calls,omitempty" toml:"ignore-calls,multiline,omitempty"` + IgnoreStringValues []string `yaml:"ignore-string-values,omitempty" toml:"ignore-string-values,multiline,omitempty"` + MatchWithConstants *bool `yaml:"match-constant,omitempty" toml:"match-constant,multiline,omitempty"` + MinStringLen *int `yaml:"min-len,omitempty" toml:"min-len,multiline,omitempty"` + MinOccurrencesCount *int `yaml:"min-occurrences,omitempty" toml:"min-occurrences,multiline,omitempty"` + ParseNumbers *bool `yaml:"numbers,omitempty" toml:"numbers,multiline,omitempty"` + NumberMin *int `yaml:"min,omitempty" toml:"min,multiline,omitempty"` + NumberMax *int `yaml:"max,omitempty" toml:"max,multiline,omitempty"` + IgnoreCalls *bool `yaml:"ignore-calls,omitempty" toml:"ignore-calls,multiline,omitempty"` + FindDuplicates *bool `yaml:"find-duplicates,omitempty" toml:"find-duplicates,multiline,omitempty"` + EvalConstExpressions *bool `yaml:"eval-const-expressions,omitempty" toml:"eval-const-expressions,multiline,omitempty"` + + IgnoreStrings *string `yaml:"ignore-strings,omitempty" toml:"ignore-strings,multiline,omitempty"` } type GoCriticSettings struct { @@ -436,7 +446,7 @@ type MustTagFunction struct { } type NakedretSettings struct { - MaxFuncLines uint `yaml:"max-func-lines,omitempty" toml:"max-func-lines,multiline,omitempty"` + MaxFuncLines *uint `yaml:"max-func-lines,omitempty" toml:"max-func-lines,multiline,omitempty"` } type NestifSettings struct { @@ -444,6 +454,7 @@ type NestifSettings struct { } type NilNilSettings struct { + OnlyTwo *bool `yaml:"only-two,omitempty" toml:"only-two,multiline,omitempty"` DetectOpposite *bool `yaml:"detect-opposite,omitempty" toml:"detect-opposite,multiline,omitempty"` CheckedTypes []string `yaml:"checked-types,omitempty" toml:"checked-types,multiline,omitempty"` } @@ -560,6 +571,7 @@ type SlogLintSettings struct { NoGlobal *string `yaml:"no-global,omitempty" toml:"no-global,multiline,omitempty"` Context *string `yaml:"context,omitempty" toml:"context,multiline,omitempty"` StaticMsg *bool `yaml:"static-msg,omitempty" toml:"static-msg,multiline,omitempty"` + MsgStyle *string `yaml:"msg-style,omitempty" toml:"msg-style,multiline,omitempty"` NoRawKeys *bool `yaml:"no-raw-keys,omitempty" toml:"no-raw-keys,multiline,omitempty"` KeyNamingCase *string `yaml:"key-naming-case,omitempty" toml:"key-naming-case,multiline,omitempty"` ForbiddenKeys []string `yaml:"forbidden-keys,omitempty" toml:"forbidden-keys,multiline,omitempty"` @@ -639,6 +651,7 @@ type TestifylintExpectedActual struct { type TestifylintFormatter struct { CheckFormatString *bool `yaml:"check-format-string,omitempty" toml:"check-format-string,multiline,omitempty"` RequireFFuncs *bool `yaml:"require-f-funcs,omitempty" toml:"require-f-funcs,multiline,omitempty"` + RequireStringMsg *bool `yaml:"require-string-msg,omitempty" toml:"require-string-msg,multiline,omitempty"` } type TestifylintGoRequire struct { @@ -736,6 +749,7 @@ type WrapcheckSettings struct { IgnoreSigRegexps []string `yaml:"ignore-sig-regexps,omitempty" toml:"ignore-sig-regexps,multiline,omitempty"` IgnorePackageGlobs []string `yaml:"ignore-package-globs,omitempty" toml:"ignore-package-globs,multiline,omitempty"` IgnoreInterfaceRegexps []string `yaml:"ignore-interface-regexps,omitempty" toml:"ignore-interface-regexps,multiline,omitempty"` + ReportInternalErrors *bool `yaml:"report-internal-errors,omitempty" toml:"report-internal-errors,multiline,omitempty"` } type WSLSettings struct { diff --git a/pkg/commands/internal/migrate/versiontwo/output.go b/pkg/commands/internal/migrate/versiontwo/output.go index ed6bab7e375d..16afb6701eef 100644 --- a/pkg/commands/internal/migrate/versiontwo/output.go +++ b/pkg/commands/internal/migrate/versiontwo/output.go @@ -5,6 +5,7 @@ package versiontwo type Output struct { Formats Formats `yaml:"formats,omitempty" toml:"formats,multiline,omitempty"` SortOrder []string `yaml:"sort-order,omitempty" toml:"sort-order,multiline,omitempty"` - PathPrefix *string `yaml:"path-prefix,omitempty" toml:"path-prefix,multiline,omitempty"` ShowStats *bool `yaml:"show-stats,omitempty" toml:"show-stats,multiline,omitempty"` + PathPrefix *string `yaml:"path-prefix,omitempty" toml:"path-prefix,multiline,omitempty"` + PathMode *string `yaml:"path-mode,omitempty" toml:"path-mode,multiline,omitempty"` } From 6d2a94be6b20f1c06e95d79479c6fdc34a69c45f Mon Sep 17 00:00:00 2001 From: Ludovic Fernandez Date: Mon, 21 Apr 2025 20:11:02 +0200 Subject: [PATCH 23/96] build(deps): bump go.augendre.info/fatcontext from 0.7.2 to 0.8.0 (#5757) --- go.mod | 2 +- go.sum | 4 ++-- pkg/golinters/fatcontext/fatcontext.go | 2 +- scripts/website/expand_templates/thanks.go | 3 +++ 4 files changed, 7 insertions(+), 4 deletions(-) diff --git a/go.mod b/go.mod index 00695fdf37ad..a8835e203561 100644 --- a/go.mod +++ b/go.mod @@ -11,7 +11,6 @@ require ( github.com/Antonboom/nilnil v1.1.0 github.com/Antonboom/testifylint v1.6.1 github.com/BurntSushi/toml v1.5.0 - github.com/Crocmagnon/fatcontext v0.7.2 github.com/Djarvur/go-err113 v0.0.0-20210108212216-aea10b59be24 github.com/GaijinEntertainment/go-exhaustruct/v3 v3.3.1 github.com/OpenPeeDeeP/depguard/v2 v2.2.1 @@ -127,6 +126,7 @@ require ( gitlab.com/bosi/decorder v0.4.2 go-simpler.org/musttag v0.13.0 go-simpler.org/sloglint v0.11.0 + go.augendre.info/fatcontext v0.8.0 go.uber.org/automaxprocs v1.6.0 golang.org/x/mod v0.24.0 golang.org/x/sys v0.32.0 diff --git a/go.sum b/go.sum index 9bc80fb7cd9b..ff028d1c4652 100644 --- a/go.sum +++ b/go.sum @@ -49,8 +49,6 @@ github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03 github.com/BurntSushi/toml v1.5.0 h1:W5quZX/G/csjUnuI8SUYlsHs9M38FC7znL0lIO+DvMg= github.com/BurntSushi/toml v1.5.0/go.mod h1:ukJfTF/6rtPPRCnwkur4qwRxa8vTRFBF0uk2lLoLwho= github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= -github.com/Crocmagnon/fatcontext v0.7.2 h1:BY5/dUhs2kuD3sDn7vZrgOneRib5EHk9GOiyK8Vg+14= -github.com/Crocmagnon/fatcontext v0.7.2/go.mod h1:OAZCUteH59eiddbJZ9/bF4ppC140jYD/hepU2FDkFk4= github.com/Djarvur/go-err113 v0.0.0-20210108212216-aea10b59be24 h1:sHglBQTwgx+rWPdisA5ynNEsoARbiCBOyGcJM4/OzsM= github.com/Djarvur/go-err113 v0.0.0-20210108212216-aea10b59be24/go.mod h1:4UJr5HIiMZrwgkSPdsjy2uOQExX/WEILpIrO9UPGuXs= github.com/GaijinEntertainment/go-exhaustruct/v3 v3.3.1 h1:Sz1JIXEcSfhz7fUi7xHnhpIE0thVASYjvosApmHuD2k= @@ -630,6 +628,8 @@ go-simpler.org/musttag v0.13.0 h1:Q/YAW0AHvaoaIbsPj3bvEI5/QFP7w696IMUpnKXQfCE= go-simpler.org/musttag v0.13.0/go.mod h1:FTzIGeK6OkKlUDVpj0iQUXZLUO1Js9+mvykDQy9C5yM= go-simpler.org/sloglint v0.11.0 h1:JlR1X4jkbeaffiyjLtymeqmGDKBDO1ikC6rjiuFAOco= go-simpler.org/sloglint v0.11.0/go.mod h1:CFDO8R1i77dlciGfPEPvYke2ZMx4eyGiEIWkyeW2Pvw= +go.augendre.info/fatcontext v0.8.0 h1:2dfk6CQbDGeu1YocF59Za5Pia7ULeAM6friJ3LP7lmk= +go.augendre.info/fatcontext v0.8.0/go.mod h1:oVJfMgwngMsHO+KB2MdgzcO+RvtNdiCEOlWvSFtax/s= go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU= go.opencensus.io v0.22.0/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8= go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= diff --git a/pkg/golinters/fatcontext/fatcontext.go b/pkg/golinters/fatcontext/fatcontext.go index 8f34064dc057..e0506259bee9 100644 --- a/pkg/golinters/fatcontext/fatcontext.go +++ b/pkg/golinters/fatcontext/fatcontext.go @@ -1,7 +1,7 @@ package fatcontext import ( - "github.com/Crocmagnon/fatcontext/pkg/analyzer" + "go.augendre.info/fatcontext/pkg/analyzer" "golang.org/x/tools/go/analysis" "github.com/golangci/golangci-lint/v2/pkg/config" diff --git a/scripts/website/expand_templates/thanks.go b/scripts/website/expand_templates/thanks.go index 66ee8511c6e8..a3a0035cf60c 100644 --- a/scripts/website/expand_templates/thanks.go +++ b/scripts/website/expand_templates/thanks.go @@ -99,6 +99,9 @@ func extractInfo(lc *linter.Config) authorInfo { case "misspell": return authorInfo{Author: "client9", Host: hostGitHub} + case "fatcontext": + return authorInfo{Author: "Crocmagnon", Host: hostGitHub} + default: if strings.HasPrefix(lc.OriginalURL, "https://pkg.go.dev/") { return authorInfo{Author: "golang", Host: hostGitHub} From 2f6a2f41948d57d4d837a8c89c071f739d5434e6 Mon Sep 17 00:00:00 2001 From: Ludovic Fernandez Date: Tue, 22 Apr 2025 12:28:51 +0200 Subject: [PATCH 24/96] docs: GoLand IDE support v2 (#5758) --- docs/src/docs/welcome/integrations.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/src/docs/welcome/integrations.mdx b/docs/src/docs/welcome/integrations.mdx index 5ffa4c6e73db..747b7ee29e2d 100644 --- a/docs/src/docs/welcome/integrations.mdx +++ b/docs/src/docs/welcome/integrations.mdx @@ -9,7 +9,7 @@ title: Integrations Starting from version 2025.1, GoLand has built-in support of golangci-lint. For IntelliJ IDEA with the Go plugin, please install the [plugin](https://plugins.jetbrains.com/plugin/12496-go-linter). -**Only v1 is supported for now.** +Both v1 and v2 versions are supported. ### Visual Studio Code From ce777622c61db6fbcc8c5d1c6c733eb97829bfa3 Mon Sep 17 00:00:00 2001 From: Fernandez Ludovic Date: Tue, 22 Apr 2025 22:50:13 +0200 Subject: [PATCH 25/96] chore: prepare release --- CHANGELOG.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 08b729267d2c..b2b57f004361 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,16 @@ If you value it, consider supporting us, we appreciate it! ❤️ ### v2.1.2 +1. Linters bug fixes + * `fatcontext`: from 0.7.2 to 0.8.0 +2. Misc. + * migration: fix `nakedret.max-func-lines: 0` + * migration: fix order of `staticcheck` settings + * fix: add `go.mod` hash to the cache salt + * fix: use diagnostic position for related information position + +### v2.1.2 + 1. Linters bug fixes * `exptostd`: from 0.4.2 to 0.4.3 * `gofumpt`: from 0.7.0 to 0.8.0 From 8ac3c76d49578ec3ac50d27a88a8a3c88760b2b2 Mon Sep 17 00:00:00 2001 From: GolangCI-Lint Releaser <65486276+golangci-releaser@users.noreply.github.com> Date: Thu, 24 Apr 2025 19:25:27 +0200 Subject: [PATCH 26/96] docs: update GitHub Action assets (#5762) --- assets/github-action-config-v2.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/assets/github-action-config-v2.json b/assets/github-action-config-v2.json index 4ec367aa9ef7..99f2a6f8b3c9 100644 --- a/assets/github-action-config-v2.json +++ b/assets/github-action-config-v2.json @@ -1,7 +1,7 @@ { "MinorVersionToConfig": { "latest": { - "TargetVersion": "v2.1.2" + "TargetVersion": "v2.1.3" }, "v1.10": { "Error": "golangci-lint version 'v1.10' isn't supported: we support only v2.0.0 and later versions" @@ -193,7 +193,7 @@ "TargetVersion": "v2.0.2" }, "v2.1": { - "TargetVersion": "v2.1.2" + "TargetVersion": "v2.1.3" } } } From 6ed40806ab563c7fc5bd7bb1d8b441f2d76a0f8a Mon Sep 17 00:00:00 2001 From: Ludovic Fernandez Date: Thu, 24 Apr 2025 19:31:36 +0200 Subject: [PATCH 27/96] chore: prepare release (#5763) --- CHANGELOG.md | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b2b57f004361..6fe75cef256a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,7 +7,13 @@ If you value it, consider supporting us, we appreciate it! ❤️ [![Open Collective backers and sponsors](https://img.shields.io/badge/OpenCollective-Donate-blue?logo=opencollective&style=for-the-badge)](https://opencollective.com/golangci-lint) [![GitHub Sponsors](https://img.shields.io/badge/GitHub-Donate-blue?logo=github&style=for-the-badge)](https://github.com/sponsors/golangci) -### v2.1.2 +### v2.1.4 + +Due to an error related to Snapcraft, some artifacts of the v2.1.3 release have not been published. + +This release contains the same things as v2.1.3. + +### v2.1.3 1. Linters bug fixes * `fatcontext`: from 0.7.2 to 0.8.0 From b20759833c1d9974349b26b800c545b925ccb771 Mon Sep 17 00:00:00 2001 From: GolangCI-Lint Releaser <65486276+golangci-releaser@users.noreply.github.com> Date: Thu, 24 Apr 2025 20:10:44 +0200 Subject: [PATCH 28/96] docs: update GitHub Action assets (#5764) --- assets/github-action-config-v2.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/assets/github-action-config-v2.json b/assets/github-action-config-v2.json index 99f2a6f8b3c9..21655966a391 100644 --- a/assets/github-action-config-v2.json +++ b/assets/github-action-config-v2.json @@ -1,7 +1,7 @@ { "MinorVersionToConfig": { "latest": { - "TargetVersion": "v2.1.3" + "TargetVersion": "v2.1.4" }, "v1.10": { "Error": "golangci-lint version 'v1.10' isn't supported: we support only v2.0.0 and later versions" @@ -193,7 +193,7 @@ "TargetVersion": "v2.0.2" }, "v2.1": { - "TargetVersion": "v2.1.3" + "TargetVersion": "v2.1.4" } } } From 8c14421d29bd005dee63044d07aa897b7d1bf8b0 Mon Sep 17 00:00:00 2001 From: Ludovic Fernandez Date: Thu, 24 Apr 2025 21:22:31 +0200 Subject: [PATCH 29/96] chore: prepare release (#5765) --- CHANGELOG.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6fe75cef256a..c0d05c10ac45 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,12 @@ If you value it, consider supporting us, we appreciate it! ❤️ [![Open Collective backers and sponsors](https://img.shields.io/badge/OpenCollective-Donate-blue?logo=opencollective&style=for-the-badge)](https://opencollective.com/golangci-lint) [![GitHub Sponsors](https://img.shields.io/badge/GitHub-Donate-blue?logo=github&style=for-the-badge)](https://github.com/sponsors/golangci) +### v2.1.5 + +Due to an error related to Snapcraft, some artifacts of the v2.1.4 release have not been published. + +This release contains the same things as v2.1.3. + ### v2.1.4 Due to an error related to Snapcraft, some artifacts of the v2.1.3 release have not been published. From f6c2e6c999dfae444d1fe7f1b0d49becdae44547 Mon Sep 17 00:00:00 2001 From: GolangCI-Lint Releaser <65486276+golangci-releaser@users.noreply.github.com> Date: Thu, 24 Apr 2025 21:58:42 +0200 Subject: [PATCH 30/96] docs: update GitHub Action assets (#5766) --- assets/github-action-config-v2.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/assets/github-action-config-v2.json b/assets/github-action-config-v2.json index 21655966a391..45ba44130ecc 100644 --- a/assets/github-action-config-v2.json +++ b/assets/github-action-config-v2.json @@ -1,7 +1,7 @@ { "MinorVersionToConfig": { "latest": { - "TargetVersion": "v2.1.4" + "TargetVersion": "v2.1.5" }, "v1.10": { "Error": "golangci-lint version 'v1.10' isn't supported: we support only v2.0.0 and later versions" @@ -193,7 +193,7 @@ "TargetVersion": "v2.0.2" }, "v2.1": { - "TargetVersion": "v2.1.4" + "TargetVersion": "v2.1.5" } } } From 46b086a9ad559fd1fc69cd9310455cda0fdc0d2a Mon Sep 17 00:00:00 2001 From: Tom Vendolsky <75443136+lvlcn-t@users.noreply.github.com> Date: Sat, 26 Apr 2025 16:46:38 +0200 Subject: [PATCH 31/96] docs: add note about golangci-lint v2 integration in VS Code (#5768) --- docs/src/docs/welcome/integrations.mdx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/src/docs/welcome/integrations.mdx b/docs/src/docs/welcome/integrations.mdx index 747b7ee29e2d..03e6d7e8d57e 100644 --- a/docs/src/docs/welcome/integrations.mdx +++ b/docs/src/docs/welcome/integrations.mdx @@ -15,6 +15,8 @@ Both v1 and v2 versions are supported. Install the [extension](https://marketplace.visualstudio.com/items?itemName=golang.Go). +**Note:** To use golangci-lint v2, you may need to switch to the pre-release version of the extension: [vscode-go#3732](https://github.com/golang/vscode-go/issues/3732#issuecomment-2805974456). +
Recommended settings for those who installed golangci-lint manually From 69778fe6e7f8c8c6d211be3d105a645352267d79 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sun, 27 Apr 2025 13:37:09 +0200 Subject: [PATCH 32/96] build(deps): bump go-simpler.org/musttag from 0.13.0 to 0.13.1 (#5769) --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index a8835e203561..299b00f4b7ad 100644 --- a/go.mod +++ b/go.mod @@ -124,7 +124,7 @@ require ( github.com/yeya24/promlinter v0.3.0 github.com/ykadowak/zerologlint v0.1.5 gitlab.com/bosi/decorder v0.4.2 - go-simpler.org/musttag v0.13.0 + go-simpler.org/musttag v0.13.1 go-simpler.org/sloglint v0.11.0 go.augendre.info/fatcontext v0.8.0 go.uber.org/automaxprocs v1.6.0 diff --git a/go.sum b/go.sum index ff028d1c4652..f6145378e65f 100644 --- a/go.sum +++ b/go.sum @@ -624,8 +624,8 @@ gitlab.com/bosi/decorder v0.4.2 h1:qbQaV3zgwnBZ4zPMhGLW4KZe7A7NwxEhJx39R3shffo= gitlab.com/bosi/decorder v0.4.2/go.mod h1:muuhHoaJkA9QLcYHq4Mj8FJUwDZ+EirSHRiaTcTf6T8= go-simpler.org/assert v0.9.0 h1:PfpmcSvL7yAnWyChSjOz6Sp6m9j5lyK8Ok9pEL31YkQ= go-simpler.org/assert v0.9.0/go.mod h1:74Eqh5eI6vCK6Y5l3PI8ZYFXG4Sa+tkr70OIPJAUr28= -go-simpler.org/musttag v0.13.0 h1:Q/YAW0AHvaoaIbsPj3bvEI5/QFP7w696IMUpnKXQfCE= -go-simpler.org/musttag v0.13.0/go.mod h1:FTzIGeK6OkKlUDVpj0iQUXZLUO1Js9+mvykDQy9C5yM= +go-simpler.org/musttag v0.13.1 h1:lw2sJyu7S1X8lc8zWUAdH42y+afdcCnHhWpnkWvd6vU= +go-simpler.org/musttag v0.13.1/go.mod h1:8r450ehpMLQgvpb6sg+hV5Ur47eH6olp/3yEanfG97k= go-simpler.org/sloglint v0.11.0 h1:JlR1X4jkbeaffiyjLtymeqmGDKBDO1ikC6rjiuFAOco= go-simpler.org/sloglint v0.11.0/go.mod h1:CFDO8R1i77dlciGfPEPvYke2ZMx4eyGiEIWkyeW2Pvw= go.augendre.info/fatcontext v0.8.0 h1:2dfk6CQbDGeu1YocF59Za5Pia7ULeAM6friJ3LP7lmk= From 896c0417487bfc7ab34c328dded269e5c4e1acc9 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sun, 27 Apr 2025 13:55:13 +0200 Subject: [PATCH 33/96] build(deps): bump github.com/alecthomas/chroma/v2 from 2.16.0 to 2.17.0 (#5772) --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 299b00f4b7ad..721d47da1d09 100644 --- a/go.mod +++ b/go.mod @@ -14,7 +14,7 @@ require ( github.com/Djarvur/go-err113 v0.0.0-20210108212216-aea10b59be24 github.com/GaijinEntertainment/go-exhaustruct/v3 v3.3.1 github.com/OpenPeeDeeP/depguard/v2 v2.2.1 - github.com/alecthomas/chroma/v2 v2.16.0 + github.com/alecthomas/chroma/v2 v2.17.0 github.com/alecthomas/go-check-sumtype v0.3.1 github.com/alexkohler/nakedret/v2 v2.0.6 github.com/alexkohler/prealloc v1.0.0 diff --git a/go.sum b/go.sum index f6145378e65f..ae592c359d42 100644 --- a/go.sum +++ b/go.sum @@ -59,8 +59,8 @@ github.com/OpenPeeDeeP/depguard/v2 v2.2.1 h1:vckeWVESWp6Qog7UZSARNqfu/cZqvki8zsu github.com/OpenPeeDeeP/depguard/v2 v2.2.1/go.mod h1:q4DKzC4UcVaAvcfd41CZh0PWpGgzrVxUYBlgKNGquUo= github.com/alecthomas/assert/v2 v2.11.0 h1:2Q9r3ki8+JYXvGsDyBXwH3LcJ+WK5D0gc5E8vS6K3D0= github.com/alecthomas/assert/v2 v2.11.0/go.mod h1:Bze95FyfUr7x34QZrjL+XP+0qgp/zg8yS+TtBj1WA3k= -github.com/alecthomas/chroma/v2 v2.16.0 h1:QC5ZMizk67+HzxFDjQ4ASjni5kWBTGiigRG1u23IGvA= -github.com/alecthomas/chroma/v2 v2.16.0/go.mod h1:RVX6AvYm4VfYe/zsk7mjHueLDZor3aWCNE14TFlepBk= +github.com/alecthomas/chroma/v2 v2.17.0 h1:3r2Cgk+nXNICMBxIFGnTRTbQFUwMiLisW+9uos0TtUI= +github.com/alecthomas/chroma/v2 v2.17.0/go.mod h1:RVX6AvYm4VfYe/zsk7mjHueLDZor3aWCNE14TFlepBk= github.com/alecthomas/go-check-sumtype v0.3.1 h1:u9aUvbGINJxLVXiFvHUlPEaD7VDULsrxJb4Aq31NLkU= github.com/alecthomas/go-check-sumtype v0.3.1/go.mod h1:A8TSiN3UPRw3laIgWEUOHHLPa6/r9MtoigdlP5h3K/E= github.com/alecthomas/repr v0.4.0 h1:GhI2A8MACjfegCPVq9f1FLvIBS+DrQ2KQBFZP1iFzXc= From 1b791de9afa9dfae80a029ed2141918063b26c20 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sun, 27 Apr 2025 14:06:48 +0200 Subject: [PATCH 34/96] build(deps): bump github.com/tetafro/godot from 1.5.0 to 1.5.1 (#5770) Co-authored-by: Fernandez Ludovic --- go.mod | 2 +- go.sum | 4 ++-- pkg/golinters/godot/testdata/fix/in/godot.go | 7 +++++++ pkg/golinters/godot/testdata/fix/out/godot.go | 7 +++++++ pkg/golinters/godot/testdata/godot.go | 9 +++++++++ 5 files changed, 26 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 721d47da1d09..ec68a6153c50 100644 --- a/go.mod +++ b/go.mod @@ -109,7 +109,7 @@ require ( github.com/stbenjam/no-sprintf-host-port v0.2.0 github.com/stretchr/testify v1.10.0 github.com/tdakkota/asciicheck v0.4.1 - github.com/tetafro/godot v1.5.0 + github.com/tetafro/godot v1.5.1 github.com/timakin/bodyclose v0.0.0-20241222091800-1db5c5ca4d67 github.com/timonwong/loggercheck v0.11.0 github.com/tomarrell/wrapcheck/v2 v2.11.0 diff --git a/go.sum b/go.sum index ae592c359d42..f1d4e0d34ecf 100644 --- a/go.sum +++ b/go.sum @@ -575,8 +575,8 @@ github.com/tenntenn/modver v1.0.1 h1:2klLppGhDgzJrScMpkj9Ujy3rXPUspSjAcev9tSEBgA github.com/tenntenn/modver v1.0.1/go.mod h1:bePIyQPb7UeioSRkw3Q0XeMhYZSMx9B8ePqg6SAMGH0= github.com/tenntenn/text/transform v0.0.0-20200319021203-7eef512accb3 h1:f+jULpRQGxTSkNYKJ51yaw6ChIqO+Je8UqsTKN/cDag= github.com/tenntenn/text/transform v0.0.0-20200319021203-7eef512accb3/go.mod h1:ON8b8w4BN/kE1EOhwT0o+d62W65a6aPw1nouo9LMgyY= -github.com/tetafro/godot v1.5.0 h1:aNwfVI4I3+gdxjMgYPus9eHmoBeJIbnajOyqZYStzuw= -github.com/tetafro/godot v1.5.0/go.mod h1:2oVxTBSftRTh4+MVfUaUXR6bn2GDXCaMcOG4Dk3rfio= +github.com/tetafro/godot v1.5.1 h1:PZnjCol4+FqaEzvZg5+O8IY2P3hfY9JzRBNPv1pEDS4= +github.com/tetafro/godot v1.5.1/go.mod h1:cCdPtEndkmqqrhiCfkmxDodMQJ/f3L1BCNskCUZdTwk= github.com/timakin/bodyclose v0.0.0-20241222091800-1db5c5ca4d67 h1:9LPGD+jzxMlnk5r6+hJnar67cgpDIz/iyD+rfl5r2Vk= github.com/timakin/bodyclose v0.0.0-20241222091800-1db5c5ca4d67/go.mod h1:mkjARE7Yr8qU23YcGMSALbIxTQ9r9QBVahQOBRfU460= github.com/timonwong/loggercheck v0.11.0 h1:jdaMpYBl+Uq9mWPXv1r8jc5fC3gyXx4/WGwTnnNKn4M= diff --git a/pkg/golinters/godot/testdata/fix/in/godot.go b/pkg/golinters/godot/testdata/fix/in/godot.go index 13b8da1c0ea9..d662c7ca53de 100644 --- a/pkg/golinters/godot/testdata/fix/in/godot.go +++ b/pkg/golinters/godot/testdata/fix/in/godot.go @@ -11,3 +11,10 @@ func godot(a, b int) int { // Nothing to do here return a + b } + +// Foo Lorem ipsum dolor sit amet, consectetur adipiscing elit. +// Aenean rhoncus odio enim, et pulvinar libero ultrices quis. +// Nulla at erat tellus. Maecenas id dapibus velit, ut porttitor ipsum +func Foo() { + // nothing to do here +} diff --git a/pkg/golinters/godot/testdata/fix/out/godot.go b/pkg/golinters/godot/testdata/fix/out/godot.go index 6960f06c044c..11d633e280c1 100644 --- a/pkg/golinters/godot/testdata/fix/out/godot.go +++ b/pkg/golinters/godot/testdata/fix/out/godot.go @@ -11,3 +11,10 @@ func godot(a, b int) int { // Nothing to do here return a + b } + +// Foo Lorem ipsum dolor sit amet, consectetur adipiscing elit. +// Aenean rhoncus odio enim, et pulvinar libero ultrices quis. +// Nulla at erat tellus. Maecenas id dapibus velit, ut porttitor ipsum. +func Foo() { + // nothing to do here +} diff --git a/pkg/golinters/godot/testdata/godot.go b/pkg/golinters/godot/testdata/godot.go index 93a904894691..c81134687b2a 100644 --- a/pkg/golinters/godot/testdata/godot.go +++ b/pkg/golinters/godot/testdata/godot.go @@ -7,3 +7,12 @@ package testdata func Godot() { // nothing to do here } + +// want +4 "Comment should end in a period" + +// Foo Lorem ipsum dolor sit amet, consectetur adipiscing elit. +// Aenean rhoncus odio enim, et pulvinar libero ultrices quis. +// Nulla at erat tellus. Maecenas id dapibus velit, ut porttitor ipsum +func Foo() { + // nothing to do here +} From 6973f4cf335f10e81bbcb2488cc27e6bb8729062 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 30 Apr 2025 21:37:05 +0200 Subject: [PATCH 35/96] build(deps): bump base-x from 3.0.9 to 3.0.11 in /docs (#5776) --- docs/package-lock.json | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/docs/package-lock.json b/docs/package-lock.json index 5693665902e0..ccf2b1809d7f 100644 --- a/docs/package-lock.json +++ b/docs/package-lock.json @@ -5885,9 +5885,10 @@ } }, "node_modules/base-x": { - "version": "3.0.9", - "resolved": "https://registry.npmjs.org/base-x/-/base-x-3.0.9.tgz", - "integrity": "sha512-H7JU6iBHTal1gp56aKoaa//YUxEaAOUiydvrV/pILqIHXTtqxSkATOnDA2u+jZ/61sD+L/412+7kzXRtWukhpQ==", + "version": "3.0.11", + "resolved": "https://registry.npmjs.org/base-x/-/base-x-3.0.11.tgz", + "integrity": "sha512-xz7wQ8xDhdyP7tQxwdteLYeFfS68tSMNCZ/Y37WJ4bhGfKPpqEIlmIyueQHqOyoPhE6xNUqjzRr8ra0eF9VRvA==", + "license": "MIT", "dependencies": { "safe-buffer": "^5.0.1" } @@ -28360,9 +28361,9 @@ } }, "base-x": { - "version": "3.0.9", - "resolved": "https://registry.npmjs.org/base-x/-/base-x-3.0.9.tgz", - "integrity": "sha512-H7JU6iBHTal1gp56aKoaa//YUxEaAOUiydvrV/pILqIHXTtqxSkATOnDA2u+jZ/61sD+L/412+7kzXRtWukhpQ==", + "version": "3.0.11", + "resolved": "https://registry.npmjs.org/base-x/-/base-x-3.0.11.tgz", + "integrity": "sha512-xz7wQ8xDhdyP7tQxwdteLYeFfS68tSMNCZ/Y37WJ4bhGfKPpqEIlmIyueQHqOyoPhE6xNUqjzRr8ra0eF9VRvA==", "requires": { "safe-buffer": "^5.0.1" } From 2ea61ac0ae9adeddc5551e444eb2c852df09e941 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 1 May 2025 13:55:08 +0200 Subject: [PATCH 36/96] build(deps): bump the linter-testdata group across 2 directories with 2 updates (#5777) --- pkg/golinters/ginkgolinter/testdata/go.mod | 9 ++++---- pkg/golinters/ginkgolinter/testdata/go.sum | 27 ++++++++++++++-------- pkg/golinters/protogetter/testdata/go.mod | 4 ++-- pkg/golinters/protogetter/testdata/go.sum | 8 +++---- 4 files changed, 29 insertions(+), 19 deletions(-) diff --git a/pkg/golinters/ginkgolinter/testdata/go.mod b/pkg/golinters/ginkgolinter/testdata/go.mod index b9c242a0ded4..fe2cc945898c 100644 --- a/pkg/golinters/ginkgolinter/testdata/go.mod +++ b/pkg/golinters/ginkgolinter/testdata/go.mod @@ -3,7 +3,7 @@ module ginkgolinter go 1.23.0 require ( - github.com/onsi/ginkgo/v2 v2.23.3 + github.com/onsi/ginkgo/v2 v2.23.4 github.com/onsi/gomega v1.37.0 ) @@ -11,10 +11,11 @@ require ( github.com/go-logr/logr v1.4.2 // indirect github.com/go-task/slim-sprig/v3 v3.0.0 // indirect github.com/google/go-cmp v0.7.0 // indirect - github.com/google/pprof v0.0.0-20241210010833-40e02aabc2ad // indirect + github.com/google/pprof v0.0.0-20250403155104-27863c87afa6 // indirect + go.uber.org/automaxprocs v1.6.0 // indirect golang.org/x/net v0.37.0 // indirect - golang.org/x/sys v0.31.0 // indirect + golang.org/x/sys v0.32.0 // indirect golang.org/x/text v0.23.0 // indirect - golang.org/x/tools v0.30.0 // indirect + golang.org/x/tools v0.31.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/pkg/golinters/ginkgolinter/testdata/go.sum b/pkg/golinters/ginkgolinter/testdata/go.sum index 4a6722c54bc5..0acd79618257 100644 --- a/pkg/golinters/ginkgolinter/testdata/go.sum +++ b/pkg/golinters/ginkgolinter/testdata/go.sum @@ -6,27 +6,36 @@ github.com/go-task/slim-sprig/v3 v3.0.0 h1:sUs3vkvUymDpBKi3qH1YSqBQk9+9D/8M2mN1v github.com/go-task/slim-sprig/v3 v3.0.0/go.mod h1:W848ghGpv3Qj3dhTPRyJypKRiqCdHZiAzKg9hl15HA8= github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8= github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU= -github.com/google/pprof v0.0.0-20241210010833-40e02aabc2ad h1:a6HEuzUHeKH6hwfN/ZoQgRgVIWFJljSWa/zetS2WTvg= -github.com/google/pprof v0.0.0-20241210010833-40e02aabc2ad/go.mod h1:vavhavw2zAxS5dIdcRluK6cSGGPlZynqzFM8NdvU144= -github.com/onsi/ginkgo/v2 v2.23.3 h1:edHxnszytJ4lD9D5Jjc4tiDkPBZ3siDeJJkUZJJVkp0= -github.com/onsi/ginkgo/v2 v2.23.3/go.mod h1:zXTP6xIp3U8aVuXN8ENK9IXRaTjFnpVB9mGmaSRvxnM= +github.com/google/pprof v0.0.0-20250403155104-27863c87afa6 h1:BHT72Gu3keYf3ZEu2J0b1vyeLSOYI8bm5wbJM/8yDe8= +github.com/google/pprof v0.0.0-20250403155104-27863c87afa6/go.mod h1:boTsfXsheKC2y+lKOCMpSfarhxDeIzfZG1jqGcPl3cA= +github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI= +github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= +github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= +github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= +github.com/onsi/ginkgo/v2 v2.23.4 h1:ktYTpKJAVZnDT4VjxSbiBenUjmlL/5QkBEocaWXiQus= +github.com/onsi/ginkgo/v2 v2.23.4/go.mod h1:Bt66ApGPBFzHyR+JO10Zbt0Gsp4uWxu5mIOTusL46e8= github.com/onsi/gomega v1.37.0 h1:CdEG8g0S133B4OswTDC/5XPSzE1OeP29QOioj2PID2Y= github.com/onsi/gomega v1.37.0/go.mod h1:8D9+Txp43QWKhM24yyOBEdpkzN8FvJyAwecBgsU4KU0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/prashantv/gostub v1.1.0 h1:BTyx3RfQjRHnUWaGF9oQos79AlQ5k8WNktv7VGvVH4g= +github.com/prashantv/gostub v1.1.0/go.mod h1:A5zLQHz7ieHGG7is6LLXLz7I8+3LZzsrV0P1IAHhP5U= github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= +go.uber.org/automaxprocs v1.6.0 h1:O3y2/QNTOdbF+e/dpXNNW7Rx2hZ4sTIPyybbxyNqTUs= +go.uber.org/automaxprocs v1.6.0/go.mod h1:ifeIMSnPZuznNm6jmdzmU3/bfk01Fe2fotchwEFJ8r8= golang.org/x/net v0.37.0 h1:1zLorHbz+LYj7MQlSf1+2tPIIgibq2eL5xkrGk6f+2c= golang.org/x/net v0.37.0/go.mod h1:ivrbrMbzFq5J41QOQh0siUuly180yBYtLp+CKbEaFx8= -golang.org/x/sys v0.31.0 h1:ioabZlmFYtWhL+TRYpcnNlLwhyxaM9kWTDEmfnprqik= -golang.org/x/sys v0.31.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k= +golang.org/x/sys v0.32.0 h1:s77OFDvIQeibCmezSnk/q6iAfkdiQaJi4VzroCFrN20= +golang.org/x/sys v0.32.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k= golang.org/x/text v0.23.0 h1:D71I7dUrlY+VX0gQShAThNGHFxZ13dGLBHQLVl1mJlY= golang.org/x/text v0.23.0/go.mod h1:/BLNzu4aZCJ1+kcD0DNRotWKage4q2rGVAg4o22unh4= -golang.org/x/tools v0.30.0 h1:BgcpHewrV5AUp2G9MebG4XPFI1E2W41zU1SaqVA9vJY= -golang.org/x/tools v0.30.0/go.mod h1:c347cR/OJfw5TI+GfX7RUPNMdDRRbjvYTS0jPyvsVtY= +golang.org/x/tools v0.31.0 h1:0EedkvKDbh+qistFTd0Bcwe/YLh4vHwWEkiI0toFIBU= +golang.org/x/tools v0.31.0/go.mod h1:naFTU+Cev749tSJRXJlna0T3WxKvb1kWEx15xA4SdmQ= google.golang.org/protobuf v1.36.5 h1:tPhr+woSbjfYvY6/GPufUoYizxw1cF/yFoxJ2fmpwlM= google.golang.org/protobuf v1.36.5/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE= -gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY= +gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/pkg/golinters/protogetter/testdata/go.mod b/pkg/golinters/protogetter/testdata/go.mod index 64d3739fe4e5..0cca1725136e 100644 --- a/pkg/golinters/protogetter/testdata/go.mod +++ b/pkg/golinters/protogetter/testdata/go.mod @@ -3,7 +3,7 @@ module protogetter go 1.23.0 require ( - google.golang.org/grpc v1.71.1 + google.golang.org/grpc v1.72.0 google.golang.org/protobuf v1.36.6 ) @@ -11,5 +11,5 @@ require ( golang.org/x/net v0.38.0 // indirect golang.org/x/sys v0.31.0 // indirect golang.org/x/text v0.23.0 // indirect - google.golang.org/genproto/googleapis/rpc v0.0.0-20250115164207-1a7da9e5054f // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20250218202821-56aae31c358a // indirect ) diff --git a/pkg/golinters/protogetter/testdata/go.sum b/pkg/golinters/protogetter/testdata/go.sum index 98076ebf7ddb..11d34e556344 100644 --- a/pkg/golinters/protogetter/testdata/go.sum +++ b/pkg/golinters/protogetter/testdata/go.sum @@ -26,9 +26,9 @@ golang.org/x/sys v0.31.0 h1:ioabZlmFYtWhL+TRYpcnNlLwhyxaM9kWTDEmfnprqik= golang.org/x/sys v0.31.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k= golang.org/x/text v0.23.0 h1:D71I7dUrlY+VX0gQShAThNGHFxZ13dGLBHQLVl1mJlY= golang.org/x/text v0.23.0/go.mod h1:/BLNzu4aZCJ1+kcD0DNRotWKage4q2rGVAg4o22unh4= -google.golang.org/genproto/googleapis/rpc v0.0.0-20250115164207-1a7da9e5054f h1:OxYkA3wjPsZyBylwymxSHa7ViiW1Sml4ToBrncvFehI= -google.golang.org/genproto/googleapis/rpc v0.0.0-20250115164207-1a7da9e5054f/go.mod h1:+2Yz8+CLJbIfL9z73EW45avw8Lmge3xVElCP9zEKi50= -google.golang.org/grpc v1.71.1 h1:ffsFWr7ygTUscGPI0KKK6TLrGz0476KUvvsbqWK0rPI= -google.golang.org/grpc v1.71.1/go.mod h1:H0GRtasmQOh9LkFoCPDu3ZrwUtD1YGE+b2vYBYd/8Ec= +google.golang.org/genproto/googleapis/rpc v0.0.0-20250218202821-56aae31c358a h1:51aaUVRocpvUOSQKM6Q7VuoaktNIaMCLuhZB6DKksq4= +google.golang.org/genproto/googleapis/rpc v0.0.0-20250218202821-56aae31c358a/go.mod h1:uRxBH1mhmO8PGhU89cMcHaXKZqO+OfakD8QQO0oYwlQ= +google.golang.org/grpc v1.72.0 h1:S7UkcVa60b5AAQTaO6ZKamFp1zMZSU0fGDK2WZLbBnM= +google.golang.org/grpc v1.72.0/go.mod h1:wH5Aktxcg25y1I3w7H69nHfXdOG3UiadoBtjh3izSDM= google.golang.org/protobuf v1.36.6 h1:z1NpPI8ku2WgiWnf+t9wTPsn6eP1L7ksHUlkfLvd9xY= google.golang.org/protobuf v1.36.6/go.mod h1:jduwjTPXsFjZGTmRluh+L6NjiWu7pchiJ2/5YcXBHnY= From 999631accee0624ba7f17e3f754455d02e2c79aa Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sun, 4 May 2025 16:07:04 +0200 Subject: [PATCH 37/96] build(deps): bump github.com/shirou/gopsutil/v4 from 4.25.3 to 4.25.4 (#5778) --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index ec68a6153c50..ed601d61b551 100644 --- a/go.mod +++ b/go.mod @@ -97,7 +97,7 @@ require ( github.com/sashamelentyev/interfacebloat v1.1.0 github.com/sashamelentyev/usestdlibvars v1.28.0 github.com/securego/gosec/v2 v2.22.3 - github.com/shirou/gopsutil/v4 v4.25.3 + github.com/shirou/gopsutil/v4 v4.25.4 github.com/sirupsen/logrus v1.9.3 github.com/sivchari/containedctx v1.0.3 github.com/sonatard/noctx v0.1.0 diff --git a/go.sum b/go.sum index f1d4e0d34ecf..e3ef36b2d472 100644 --- a/go.sum +++ b/go.sum @@ -519,8 +519,8 @@ github.com/securego/gosec/v2 v2.22.3 h1:mRrCNmRF2NgZp4RJ8oJ6yPJ7G4x6OCiAXHd8x4tr github.com/securego/gosec/v2 v2.22.3/go.mod h1:42M9Xs0v1WseinaB/BmNGO8AVqG8vRfhC2686ACY48k= github.com/sergi/go-diff v1.2.0 h1:XU+rvMAioB0UC3q1MFrIQy4Vo5/4VsRDQQXHsEya6xQ= github.com/sergi/go-diff v1.2.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM= -github.com/shirou/gopsutil/v4 v4.25.3 h1:SeA68lsu8gLggyMbmCn8cmp97V1TI9ld9sVzAUcKcKE= -github.com/shirou/gopsutil/v4 v4.25.3/go.mod h1:xbuxyoZj+UsgnZrENu3lQivsngRR5BdjbJwf2fv4szA= +github.com/shirou/gopsutil/v4 v4.25.4 h1:cdtFO363VEOOFrUCjZRh4XVJkb548lyF0q0uTeMqYPw= +github.com/shirou/gopsutil/v4 v4.25.4/go.mod h1:xbuxyoZj+UsgnZrENu3lQivsngRR5BdjbJwf2fv4szA= github.com/shurcooL/go v0.0.0-20180423040247-9e1955d9fb6e/go.mod h1:TDJrrUr11Vxrven61rcy3hJMUqaf/CLWYhHNPmT14Lk= github.com/shurcooL/go-goon v0.0.0-20170922171312-37c2f522c041/go.mod h1:N5mDOmsrJOB+vfqUK+7DmDyjhSLIIBnXo9lvZJj3MWQ= github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= From 75865b1cbd423e9529ed5ff3e1ec6f6aeec1fb86 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sun, 4 May 2025 16:14:48 +0200 Subject: [PATCH 38/96] build(deps): bump github.com/alecthomas/chroma/v2 from 2.17.0 to 2.17.2 (#5779) --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index ed601d61b551..97b5fa5cfb14 100644 --- a/go.mod +++ b/go.mod @@ -14,7 +14,7 @@ require ( github.com/Djarvur/go-err113 v0.0.0-20210108212216-aea10b59be24 github.com/GaijinEntertainment/go-exhaustruct/v3 v3.3.1 github.com/OpenPeeDeeP/depguard/v2 v2.2.1 - github.com/alecthomas/chroma/v2 v2.17.0 + github.com/alecthomas/chroma/v2 v2.17.2 github.com/alecthomas/go-check-sumtype v0.3.1 github.com/alexkohler/nakedret/v2 v2.0.6 github.com/alexkohler/prealloc v1.0.0 diff --git a/go.sum b/go.sum index e3ef36b2d472..2ed1a4b31878 100644 --- a/go.sum +++ b/go.sum @@ -59,8 +59,8 @@ github.com/OpenPeeDeeP/depguard/v2 v2.2.1 h1:vckeWVESWp6Qog7UZSARNqfu/cZqvki8zsu github.com/OpenPeeDeeP/depguard/v2 v2.2.1/go.mod h1:q4DKzC4UcVaAvcfd41CZh0PWpGgzrVxUYBlgKNGquUo= github.com/alecthomas/assert/v2 v2.11.0 h1:2Q9r3ki8+JYXvGsDyBXwH3LcJ+WK5D0gc5E8vS6K3D0= github.com/alecthomas/assert/v2 v2.11.0/go.mod h1:Bze95FyfUr7x34QZrjL+XP+0qgp/zg8yS+TtBj1WA3k= -github.com/alecthomas/chroma/v2 v2.17.0 h1:3r2Cgk+nXNICMBxIFGnTRTbQFUwMiLisW+9uos0TtUI= -github.com/alecthomas/chroma/v2 v2.17.0/go.mod h1:RVX6AvYm4VfYe/zsk7mjHueLDZor3aWCNE14TFlepBk= +github.com/alecthomas/chroma/v2 v2.17.2 h1:Rm81SCZ2mPoH+Q8ZCc/9YvzPUN/E7HgPiPJD8SLV6GI= +github.com/alecthomas/chroma/v2 v2.17.2/go.mod h1:RVX6AvYm4VfYe/zsk7mjHueLDZor3aWCNE14TFlepBk= github.com/alecthomas/go-check-sumtype v0.3.1 h1:u9aUvbGINJxLVXiFvHUlPEaD7VDULsrxJb4Aq31NLkU= github.com/alecthomas/go-check-sumtype v0.3.1/go.mod h1:A8TSiN3UPRw3laIgWEUOHHLPa6/r9MtoigdlP5h3K/E= github.com/alecthomas/repr v0.4.0 h1:GhI2A8MACjfegCPVq9f1FLvIBS+DrQ2KQBFZP1iFzXc= From eabc2638a66daf5bb6c6fb052a32fa3ef7b6600d Mon Sep 17 00:00:00 2001 From: Fernandez Ludovic Date: Sun, 4 May 2025 17:36:36 +0200 Subject: [PATCH 39/96] chore: prepare release --- CHANGELOG.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index c0d05c10ac45..403a833fcb27 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,14 @@ If you value it, consider supporting us, we appreciate it! ❤️ [![Open Collective backers and sponsors](https://img.shields.io/badge/OpenCollective-Donate-blue?logo=opencollective&style=for-the-badge)](https://opencollective.com/golangci-lint) [![GitHub Sponsors](https://img.shields.io/badge/GitHub-Donate-blue?logo=github&style=for-the-badge)](https://github.com/sponsors/golangci) +### v2.1.6 + +1. Linters bug fixes + * `godot`: from 1.5.0 to 1.5.1 + * `musttag`: from 0.13.0 to 0.13.1 +2. Documentation + * Add note about golangci-lint v2 integration in VS Code + ### v2.1.5 Due to an error related to Snapcraft, some artifacts of the v2.1.4 release have not been published. From 66dba6452068fd4074691ccde56e388c5b9deaa1 Mon Sep 17 00:00:00 2001 From: Fernandez Ludovic Date: Sun, 4 May 2025 21:16:10 +0200 Subject: [PATCH 40/96] docs: update GitHub Action assets --- assets/github-action-config-v2.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/assets/github-action-config-v2.json b/assets/github-action-config-v2.json index 45ba44130ecc..2a099a8ff534 100644 --- a/assets/github-action-config-v2.json +++ b/assets/github-action-config-v2.json @@ -1,7 +1,7 @@ { "MinorVersionToConfig": { "latest": { - "TargetVersion": "v2.1.5" + "TargetVersion": "v2.1.6" }, "v1.10": { "Error": "golangci-lint version 'v1.10' isn't supported: we support only v2.0.0 and later versions" @@ -193,7 +193,7 @@ "TargetVersion": "v2.0.2" }, "v2.1": { - "TargetVersion": "v2.1.5" + "TargetVersion": "v2.1.6" } } } From fd9a0f2150183f66d8f2f41bbea8706b48881c7d Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sun, 4 May 2025 22:13:28 +0200 Subject: [PATCH 41/96] build(deps): bump github.com/manuelarte/funcorder from 0.2.1 to 0.3.0 (#5743) Co-authored-by: Fernandez Ludovic --- .golangci.next.reference.yml | 3 +++ go.mod | 2 +- go.sum | 4 ++-- jsonschema/golangci.next.jsonschema.json | 5 +++++ pkg/config/linters_settings.go | 1 + pkg/golinters/funcorder/funcorder.go | 1 + 6 files changed, 13 insertions(+), 3 deletions(-) diff --git a/.golangci.next.reference.yml b/.golangci.next.reference.yml index 37866ff00f2c..dbcc0377a400 100644 --- a/.golangci.next.reference.yml +++ b/.golangci.next.reference.yml @@ -539,6 +539,9 @@ linters: # Checks if the exported methods of a structure are placed before the non-exported ones. # Default: true struct-method: false + # Checks if the constructors and/or structure methods are sorted alphabetically. + # Default: false + alphabetical: true funlen: # Checks the number of lines in a function. diff --git a/go.mod b/go.mod index 97b5fa5cfb14..b2a3c45e11cc 100644 --- a/go.mod +++ b/go.mod @@ -73,7 +73,7 @@ require ( github.com/ldez/usetesting v0.4.3 github.com/leonklingele/grouper v1.1.2 github.com/macabu/inamedparam v0.2.0 - github.com/manuelarte/funcorder v0.2.1 + github.com/manuelarte/funcorder v0.3.0 github.com/maratori/testableexamples v1.0.0 github.com/maratori/testpackage v1.1.1 github.com/matoous/godox v1.1.0 diff --git a/go.sum b/go.sum index 2ed1a4b31878..182df4b27f2b 100644 --- a/go.sum +++ b/go.sum @@ -389,8 +389,8 @@ github.com/macabu/inamedparam v0.2.0 h1:VyPYpOc10nkhI2qeNUdh3Zket4fcZjEWe35poddB github.com/macabu/inamedparam v0.2.0/go.mod h1:+Pee9/YfGe5LJ62pYXqB89lJ+0k5bsR8Wgz/C0Zlq3U= github.com/magiconair/properties v1.8.6 h1:5ibWZ6iY0NctNGWo87LalDlEZ6R41TqbbDamhfG/Qzo= github.com/magiconair/properties v1.8.6/go.mod h1:y3VJvCyxH9uVvJTWEGAELF3aiYNyPKd5NZ3oSwXrF60= -github.com/manuelarte/funcorder v0.2.1 h1:7QJsw3qhljoZ5rH0xapIvjw31EcQeFbF31/7kQ/xS34= -github.com/manuelarte/funcorder v0.2.1/go.mod h1:BQQ0yW57+PF9ZpjpeJDKOffEsQbxDFKW8F8zSMe/Zd0= +github.com/manuelarte/funcorder v0.3.0 h1:mV1joNYIjIUnnyZ6wfaC+sCWB6IvG62ay3xuhbklHps= +github.com/manuelarte/funcorder v0.3.0/go.mod h1:wBFktqsi8PyQvNYEUpF5Lt+V/xqgaevfCi4SSpUhyPo= github.com/maratori/testableexamples v1.0.0 h1:dU5alXRrD8WKSjOUnmJZuzdxWOEQ57+7s93SLMxb2vI= github.com/maratori/testableexamples v1.0.0/go.mod h1:4rhjL1n20TUTT4vdh3RDqSizKLyXp7K2u6HgraZCGzE= github.com/maratori/testpackage v1.1.1 h1:S58XVV5AD7HADMmD0fNnziNHqKvSdDuEKdPD1rNTU04= diff --git a/jsonschema/golangci.next.jsonschema.json b/jsonschema/golangci.next.jsonschema.json index 0f2ef5fcc50b..9af538279cbc 100644 --- a/jsonschema/golangci.next.jsonschema.json +++ b/jsonschema/golangci.next.jsonschema.json @@ -1317,6 +1317,11 @@ "description": "Checks if the exported methods of a structure are placed before the non-exported ones.", "type": "boolean", "default": true + }, + "alphabetical": { + "description": "Checks if the constructors and/or structure methods are sorted alphabetically.", + "type": "boolean", + "default": false } } }, diff --git a/pkg/config/linters_settings.go b/pkg/config/linters_settings.go index 16a8bb9501b9..065abfab47c1 100644 --- a/pkg/config/linters_settings.go +++ b/pkg/config/linters_settings.go @@ -428,6 +428,7 @@ type ForbidigoPattern struct { type FuncOrderSettings struct { Constructor bool `mapstructure:"constructor,omitempty"` StructMethod bool `mapstructure:"struct-method,omitempty"` + Alphabetical bool `mapstructure:"alphabetical,omitempty"` } type FunlenSettings struct { diff --git a/pkg/golinters/funcorder/funcorder.go b/pkg/golinters/funcorder/funcorder.go index 7b8e9689e587..605304f26203 100644 --- a/pkg/golinters/funcorder/funcorder.go +++ b/pkg/golinters/funcorder/funcorder.go @@ -17,6 +17,7 @@ func New(settings *config.FuncOrderSettings) *goanalysis.Linter { cfg[a.Name] = map[string]any{ analyzer.ConstructorCheckName: settings.Constructor, analyzer.StructMethodCheckName: settings.StructMethod, + analyzer.AlphabeticalCheckName: settings.Alphabetical, } } From af60e9f6c7bc26abd82dc0da1d1cc3dc0dddaecf Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sun, 4 May 2025 23:06:05 +0200 Subject: [PATCH 42/96] build(deps): bump github.com/sonatard/noctx from 0.1.0 to 0.3.3 (#5771) Co-authored-by: Fernandez Ludovic --- go.mod | 2 +- go.sum | 4 +- pkg/golinters/noctx/noctx.go | 2 +- pkg/golinters/noctx/testdata/noctx.go | 134 +++++++++++++++------- pkg/golinters/noctx/testdata/noctx_cgo.go | 133 ++++++++++++++------- 5 files changed, 188 insertions(+), 87 deletions(-) diff --git a/go.mod b/go.mod index b2a3c45e11cc..1e7e82b195f4 100644 --- a/go.mod +++ b/go.mod @@ -100,7 +100,7 @@ require ( github.com/shirou/gopsutil/v4 v4.25.4 github.com/sirupsen/logrus v1.9.3 github.com/sivchari/containedctx v1.0.3 - github.com/sonatard/noctx v0.1.0 + github.com/sonatard/noctx v0.3.3 github.com/sourcegraph/go-diff v0.7.0 github.com/spf13/cobra v1.9.1 github.com/spf13/pflag v1.0.6 diff --git a/go.sum b/go.sum index 182df4b27f2b..9875fd835bef 100644 --- a/go.sum +++ b/go.sum @@ -530,8 +530,8 @@ github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ= github.com/sivchari/containedctx v1.0.3 h1:x+etemjbsh2fB5ewm5FeLNi5bUjK0V8n0RB+Wwfd0XE= github.com/sivchari/containedctx v1.0.3/go.mod h1:c1RDvCbnJLtH4lLcYD/GqwiBSSf4F5Qk0xld2rBqzJ4= -github.com/sonatard/noctx v0.1.0 h1:JjqOc2WN16ISWAjAk8M5ej0RfExEXtkEyExl2hLW+OM= -github.com/sonatard/noctx v0.1.0/go.mod h1:0RvBxqY8D4j9cTTTWE8ylt2vqj2EPI8fHmrxHdsaZ2c= +github.com/sonatard/noctx v0.3.3 h1:9+wFUxZfjiCdNadFaGH55sa7Y1r6yKZiAsUVmCP+tjw= +github.com/sonatard/noctx v0.3.3/go.mod h1:64XdbzFb18XL4LporKXp8poqZtPKbCrqQ402CV+kJas= github.com/sourcegraph/go-diff v0.7.0 h1:9uLlrd5T46OXs5qpp8L/MTltk0zikUGi0sNNyCpA8G0= github.com/sourcegraph/go-diff v0.7.0/go.mod h1:iBszgVvyxdc8SFZ7gm69go2KDdt3ag071iBaWPF6cjs= github.com/spf13/afero v1.14.0 h1:9tH6MapGnn/j0eb0yIXiLjERO8RB6xIVZRDCX7PtqWA= diff --git a/pkg/golinters/noctx/noctx.go b/pkg/golinters/noctx/noctx.go index b0c5f9b50040..18391d4b5581 100644 --- a/pkg/golinters/noctx/noctx.go +++ b/pkg/golinters/noctx/noctx.go @@ -12,7 +12,7 @@ func New() *goanalysis.Linter { return goanalysis.NewLinter( a.Name, - "Finds sending http request without context.Context", + "Detects function and method with missing usage of context.Context", []*analysis.Analyzer{a}, nil, ).WithLoadMode(goanalysis.LoadModeTypesInfo) diff --git a/pkg/golinters/noctx/testdata/noctx.go b/pkg/golinters/noctx/testdata/noctx.go index 8b077a566206..8a34443e2029 100644 --- a/pkg/golinters/noctx/testdata/noctx.go +++ b/pkg/golinters/noctx/testdata/noctx.go @@ -3,73 +3,58 @@ package testdata import ( "context" + "database/sql" "net/http" ) var newRequestPkg = http.NewRequest -func Noctx() { - const url = "http://example.com" +func _() { + const url = "https://example.com" + cli := &http.Client{} ctx := context.Background() - http.Get(url) // want `net/http\.Get must not be called` - _ = http.Get // OK - f := http.Get // OK - f(url) // want `net/http\.Get must not be called` - - http.Head(url) // want `net/http\.Head must not be called` - http.Post(url, "", nil) // want `net/http\.Post must not be called` - http.PostForm(url, nil) // want `net/http\.PostForm must not be called` - - cli.Get(url) // want `\(\*net/http\.Client\)\.Get must not be called` - _ = cli.Get // OK - m := cli.Get // OK - m(url) // want `\(\*net/http\.Client\)\.Get must not be called` - - cli.Head(url) // want `\(\*net/http\.Client\)\.Head must not be called` - cli.Post(url, "", nil) // want `\(\*net/http\.Client\)\.Post must not be called` - cli.PostForm(url, nil) // want `\(\*net/http\.Client\)\.PostForm must not be called` - req, _ := http.NewRequest(http.MethodPost, url, nil) // want `should rewrite http.NewRequestWithContext or add \(\*Request\).WithContext` + req, _ := http.NewRequest(http.MethodPost, url, nil) // want `net/http\.NewRequest must not be called. use net/http\.NewRequestWithContext` cli.Do(req) req2, _ := http.NewRequestWithContext(ctx, http.MethodPost, url, nil) // OK cli.Do(req2) - req3, _ := http.NewRequest(http.MethodPost, url, nil) // OK + req3, _ := http.NewRequest(http.MethodPost, url, nil) // want `net/http\.NewRequest must not be called. use net/http\.NewRequestWithContext` req3 = req3.WithContext(ctx) cli.Do(req3) f2 := func(req *http.Request, ctx context.Context) *http.Request { return req } - req4, _ := http.NewRequest(http.MethodPost, url, nil) // want `should rewrite http.NewRequestWithContext or add \(\*Request\).WithContext` + req4, _ := http.NewRequest(http.MethodPost, url, nil) // want `net/http\.NewRequest must not be called. use net/http\.NewRequestWithContext` req4 = f2(req4, ctx) - req41, _ := http.NewRequest(http.MethodPost, url, nil) // OK + req41, _ := http.NewRequest(http.MethodPost, url, nil) // want `net/http\.NewRequest must not be called. use net/http\.NewRequestWithContext` req41 = req41.WithContext(ctx) req41 = f2(req41, ctx) newRequest := http.NewRequest - req5, _ := newRequest(http.MethodPost, url, nil) // want `should rewrite http.NewRequestWithContext or add \(\*Request\).WithContext` + req5, _ := newRequest(http.MethodPost, url, nil) // want `net/http\.NewRequest must not be called. use net/http\.NewRequestWithContext` cli.Do(req5) - req51, _ := newRequest(http.MethodPost, url, nil) // OK + req51, _ := newRequest(http.MethodPost, url, nil) // want `net/http\.NewRequest must not be called. use net/http\.NewRequestWithContext` req51 = req51.WithContext(ctx) cli.Do(req51) - req52, _ := newRequestPkg(http.MethodPost, url, nil) // want `should rewrite http.NewRequestWithContext or add \(\*Request\).WithContext` + req52, _ := newRequestPkg(http.MethodPost, url, nil) // TODO: false negative `net/http\.NewRequest must not be called. use net/http\.NewRequestWithContext` cli.Do(req52) type MyRequest = http.Request f3 := func(req *MyRequest, ctx context.Context) *MyRequest { return req } - req6, _ := http.NewRequest(http.MethodPost, url, nil) // want `should rewrite http.NewRequestWithContext or add \(\*Request\).WithContext` + req6, _ := http.NewRequest(http.MethodPost, url, nil) // want `net/http\.NewRequest must not be called. use net/http\.NewRequestWithContext` req6 = f3(req6, ctx) - req61, _ := http.NewRequest(http.MethodPost, url, nil) // OK + req61, _ := http.NewRequest(http.MethodPost, url, nil) // want `net/http\.NewRequest must not be called. use net/http\.NewRequestWithContext` req61 = req61.WithContext(ctx) req61 = f3(req61, ctx) @@ -77,22 +62,22 @@ func Noctx() { f4 := func(req *MyRequest2, ctx context.Context) *MyRequest2 { return req } - req7, _ := http.NewRequest(http.MethodPost, url, nil) // want `should rewrite http.NewRequestWithContext or add \(\*Request\).WithContext` + req7, _ := http.NewRequest(http.MethodPost, url, nil) // want `net/http\.NewRequest must not be called. use net/http\.NewRequestWithContext` req71 := MyRequest2(*req7) f4(&req71, ctx) - req72, _ := http.NewRequest(http.MethodPost, url, nil) // OK + req72, _ := http.NewRequest(http.MethodPost, url, nil) // want `net/http\.NewRequest must not be called. use net/http\.NewRequestWithContext` req72 = req72.WithContext(ctx) req73 := MyRequest2(*req7) f4(&req73, ctx) req8, _ := func() (*http.Request, error) { - return http.NewRequest(http.MethodPost, url, nil) // want `should rewrite http.NewRequestWithContext or add \(\*Request\).WithContext` + return http.NewRequest(http.MethodPost, url, nil) // want `net/http\.NewRequest must not be called. use net/http\.NewRequestWithContext` }() cli.Do(req8) req82, _ := func() (*http.Request, error) { - req82, _ := http.NewRequest(http.MethodPost, url, nil) // OK + req82, _ := http.NewRequest(http.MethodPost, url, nil) // want `net/http\.NewRequest must not be called. use net/http\.NewRequestWithContext` req82 = req82.WithContext(ctx) return req82, nil }() @@ -101,34 +86,99 @@ func Noctx() { f5 := func(req, req2 *http.Request, ctx context.Context) (*http.Request, *http.Request) { return req, req2 } - req9, _ := http.NewRequest(http.MethodPost, url, nil) // want `should rewrite http.NewRequestWithContext or add \(\*Request\).WithContext` + req9, _ := http.NewRequest(http.MethodPost, url, nil) // want `net/http\.NewRequest must not be called. use net/http\.NewRequestWithContext` req9, _ = f5(req9, req9, ctx) - req91, _ := http.NewRequest(http.MethodPost, url, nil) // OK + req91, _ := http.NewRequest(http.MethodPost, url, nil) // want `net/http\.NewRequest must not be called. use net/http\.NewRequestWithContext` req91 = req91.WithContext(ctx) req9, _ = f5(req91, req91, ctx) - req10, _ := http.NewRequest(http.MethodPost, url, nil) // want `should rewrite http.NewRequestWithContext or add \(\*Request\).WithContext` - req11, _ := http.NewRequest(http.MethodPost, url, nil) // want `should rewrite http.NewRequestWithContext or add \(\*Request\).WithContext` + req10, _ := http.NewRequest(http.MethodPost, url, nil) // want `net/http\.NewRequest must not be called. use net/http\.NewRequestWithContext` + req11, _ := http.NewRequest(http.MethodPost, url, nil) // want `net/http\.NewRequest must not be called. use net/http\.NewRequestWithContext` req10, req11 = f5(req10, req11, ctx) - req101, _ := http.NewRequest(http.MethodPost, url, nil) // want `should rewrite http.NewRequestWithContext or add \(\*Request\).WithContext` - req111, _ := http.NewRequest(http.MethodPost, url, nil) // OK + req101, _ := http.NewRequest(http.MethodPost, url, nil) // want `net/http\.NewRequest must not be called. use net/http\.NewRequestWithContext` + req111, _ := http.NewRequest(http.MethodPost, url, nil) // want `net/http\.NewRequest must not be called. use net/http\.NewRequestWithContext` req111 = req111.WithContext(ctx) req101, req111 = f5(req101, req111, ctx) func() (*http.Request, *http.Request) { - req12, _ := http.NewRequest(http.MethodPost, url, nil) // want `should rewrite http.NewRequestWithContext or add \(\*Request\).WithContext` - req13, _ := http.NewRequest(http.MethodPost, url, nil) // want `should rewrite http.NewRequestWithContext or add \(\*Request\).WithContext` + req12, _ := http.NewRequest(http.MethodPost, url, nil) // want `net/http\.NewRequest must not be called. use net/http\.NewRequestWithContext` + req13, _ := http.NewRequest(http.MethodPost, url, nil) // want `net/http\.NewRequest must not be called. use net/http\.NewRequestWithContext` return req12, req13 }() func() (*http.Request, *http.Request) { - req14, _ := http.NewRequest(http.MethodPost, url, nil) // want `should rewrite http.NewRequestWithContext or add \(\*Request\).WithContext` - req15, _ := http.NewRequest(http.MethodPost, url, nil) // OK + req14, _ := http.NewRequest(http.MethodPost, url, nil) // want `net/http\.NewRequest must not be called. use net/http\.NewRequestWithContext` + req15, _ := http.NewRequest(http.MethodPost, url, nil) // want `net/http\.NewRequest must not be called. use net/http\.NewRequestWithContext` req15 = req15.WithContext(ctx) return req14, req15 }() + + req121, _ := http.NewRequest(http.MethodPost, url, nil) // want `net/http\.NewRequest must not be called. use net/http\.NewRequestWithContext` + req121.AddCookie(&http.Cookie{Name: "k", Value: "v"}) + req121 = req121.WithContext(context.WithValue(req121.Context(), struct{}{}, 0)) + cli.Do(req121) +} + +func _() { + const url = "http://example.com" + cli := &http.Client{} + + http.Get(url) // want `net/http\.Get must not be called. use net/http\.NewRequestWithContext and \(\*net/http.Client\)\.Do\(\*http.Request\)` + _ = http.Get // OK + f := http.Get // OK + f(url) // want `net/http\.Get must not be called. use net/http\.NewRequestWithContext and \(\*net/http.Client\)\.Do\(\*http.Request\)` + + http.Head(url) // want `net/http\.Head must not be called. use net/http\.NewRequestWithContext and \(\*net/http.Client\)\.Do\(\*http.Request\)` + http.Post(url, "", nil) // want `net/http\.Post must not be called. use net/http\.NewRequestWithContext and \(\*net/http.Client\)\.Do\(\*http.Request\)` + http.PostForm(url, nil) // want `net/http\.PostForm must not be called. use net/http\.NewRequestWithContext and \(\*net/http.Client\)\.Do\(\*http.Request\)` + + cli.Get(url) // want `\(\*net/http\.Client\)\.Get must not be called. use \(\*net/http.Client\)\.Do\(\*http.Request\)` + _ = cli.Get // OK + m := cli.Get // OK + m(url) // want `\(\*net/http\.Client\)\.Get must not be called. use \(\*net/http.Client\)\.Do\(\*http.Request\)` + + cli.Head(url) // want `\(\*net/http\.Client\)\.Head must not be called. use \(\*net/http.Client\)\.Do\(\*http.Request\)` + cli.Post(url, "", nil) // want `\(\*net/http\.Client\)\.Post must not be called. use \(\*net/http.Client\)\.Do\(\*http.Request\)` + cli.PostForm(url, nil) // want `\(\*net/http\.Client\)\.PostForm must not be called. use \(\*net/http.Client\)\.Do\(\*http.Request\)` } +func _() { + ctx := context.Background() + + db, _ := sql.Open("noctx", "noctx://") + + db.Exec("select * from testdata") // want `\(\*database/sql\.DB\)\.Exec must not be called. use \(\*database/sql\.DB\)\.ExecContext` + db.ExecContext(ctx, "select * from testdata") + + db.Ping() // want `\(\*database/sql\.DB\)\.Ping must not be called. use \(\*database/sql\.DB\)\.PingContext` + db.PingContext(ctx) + + db.Prepare("select * from testdata") // want `\(\*database/sql\.DB\)\.Prepare must not be called. use \(\*database/sql\.DB\)\.PrepareContext` + db.PrepareContext(ctx, "select * from testdata") + + db.Query("select * from testdata") // want `\(\*database/sql\.DB\)\.Query must not be called. use \(\*database/sql\.DB\)\.QueryContext` + db.QueryContext(ctx, "select * from testdata") + + db.QueryRow("select * from testdata") // want `\(\*database/sql\.DB\)\.QueryRow must not be called. use \(\*database/sql\.DB\)\.QueryRowContext` + db.QueryRowContext(ctx, "select * from testdata") + + // transactions + + tx, _ := db.Begin() + tx.Exec("select * from testdata") // want `\(\*database/sql\.Tx\)\.Exec must not be called. use \(\*database/sql\.Tx\)\.ExecContext` + tx.ExecContext(ctx, "select * from testdata") + + tx.Prepare("select * from testdata") // want `\(\*database/sql\.Tx\)\.Prepare must not be called. use \(\*database/sql\.Tx\)\.PrepareContext` + tx.PrepareContext(ctx, "select * from testdata") + + tx.Query("select * from testdata") // want `\(\*database/sql\.Tx\)\.Query must not be called. use \(\*database/sql\.Tx\)\.QueryContext` + tx.QueryContext(ctx, "select * from testdata") + + tx.QueryRow("select * from testdata") // want `\(\*database/sql\.Tx\)\.QueryRow must not be called. use \(\*database/sql\.Tx\)\.QueryRowContext` + tx.QueryRowContext(ctx, "select * from testdata") + + _ = tx.Commit() +} diff --git a/pkg/golinters/noctx/testdata/noctx_cgo.go b/pkg/golinters/noctx/testdata/noctx_cgo.go index 64f5ea6c0d49..63b15477d8c3 100644 --- a/pkg/golinters/noctx/testdata/noctx_cgo.go +++ b/pkg/golinters/noctx/testdata/noctx_cgo.go @@ -13,6 +13,7 @@ import "C" import ( "context" + "database/sql" "net/http" "unsafe" ) @@ -26,67 +27,51 @@ func _() { var newRequestPkg = http.NewRequest func _() { - const url = "http://example.com" + const url = "https://example.com" + cli := &http.Client{} ctx := context.Background() - http.Get(url) // want `net/http\.Get must not be called` - _ = http.Get // OK - f := http.Get // OK - f(url) // want `net/http\.Get must not be called` - - http.Head(url) // want `net/http\.Head must not be called` - http.Post(url, "", nil) // want `net/http\.Post must not be called` - http.PostForm(url, nil) // want `net/http\.PostForm must not be called` - cli.Get(url) // want `\(\*net/http\.Client\)\.Get must not be called` - _ = cli.Get // OK - m := cli.Get // OK - m(url) // want `\(\*net/http\.Client\)\.Get must not be called` - - cli.Head(url) // want `\(\*net/http\.Client\)\.Head must not be called` - cli.Post(url, "", nil) // want `\(\*net/http\.Client\)\.Post must not be called` - cli.PostForm(url, nil) // want `\(\*net/http\.Client\)\.PostForm must not be called` - - req, _ := http.NewRequest(http.MethodPost, url, nil) // want `should rewrite http.NewRequestWithContext or add \(\*Request\).WithContext` + req, _ := http.NewRequest(http.MethodPost, url, nil) // want `net/http\.NewRequest must not be called. use net/http\.NewRequestWithContext` cli.Do(req) req2, _ := http.NewRequestWithContext(ctx, http.MethodPost, url, nil) // OK cli.Do(req2) - req3, _ := http.NewRequest(http.MethodPost, url, nil) // OK + req3, _ := http.NewRequest(http.MethodPost, url, nil) // want `net/http\.NewRequest must not be called. use net/http\.NewRequestWithContext` req3 = req3.WithContext(ctx) cli.Do(req3) f2 := func(req *http.Request, ctx context.Context) *http.Request { return req } - req4, _ := http.NewRequest(http.MethodPost, url, nil) // want `should rewrite http.NewRequestWithContext or add \(\*Request\).WithContext` + req4, _ := http.NewRequest(http.MethodPost, url, nil) // want `net/http\.NewRequest must not be called. use net/http\.NewRequestWithContext` req4 = f2(req4, ctx) - req41, _ := http.NewRequest(http.MethodPost, url, nil) // OK + req41, _ := http.NewRequest(http.MethodPost, url, nil) // want `net/http\.NewRequest must not be called. use net/http\.NewRequestWithContext` req41 = req41.WithContext(ctx) req41 = f2(req41, ctx) newRequest := http.NewRequest - req5, _ := newRequest(http.MethodPost, url, nil) // want `should rewrite http.NewRequestWithContext or add \(\*Request\).WithContext` + req5, _ := newRequest(http.MethodPost, url, nil) // want `net/http\.NewRequest must not be called. use net/http\.NewRequestWithContext` cli.Do(req5) - req51, _ := newRequest(http.MethodPost, url, nil) // OK + req51, _ := newRequest(http.MethodPost, url, nil) // want `net/http\.NewRequest must not be called. use net/http\.NewRequestWithContext` req51 = req51.WithContext(ctx) cli.Do(req51) - req52, _ := newRequestPkg(http.MethodPost, url, nil) // want `should rewrite http.NewRequestWithContext or add \(\*Request\).WithContext` + req52, _ := newRequestPkg(http.MethodPost, url, nil) // TODO: false negative `net/http\.NewRequest must not be called. use net/http\.NewRequestWithContext` cli.Do(req52) type MyRequest = http.Request f3 := func(req *MyRequest, ctx context.Context) *MyRequest { return req } - req6, _ := http.NewRequest(http.MethodPost, url, nil) // want `should rewrite http.NewRequestWithContext or add \(\*Request\).WithContext` + req6, _ := http.NewRequest(http.MethodPost, url, nil) // want `net/http\.NewRequest must not be called. use net/http\.NewRequestWithContext` req6 = f3(req6, ctx) - req61, _ := http.NewRequest(http.MethodPost, url, nil) // OK + req61, _ := http.NewRequest(http.MethodPost, url, nil) // want `net/http\.NewRequest must not be called. use net/http\.NewRequestWithContext` req61 = req61.WithContext(ctx) req61 = f3(req61, ctx) @@ -94,22 +79,22 @@ func _() { f4 := func(req *MyRequest2, ctx context.Context) *MyRequest2 { return req } - req7, _ := http.NewRequest(http.MethodPost, url, nil) // want `should rewrite http.NewRequestWithContext or add \(\*Request\).WithContext` + req7, _ := http.NewRequest(http.MethodPost, url, nil) // want `net/http\.NewRequest must not be called. use net/http\.NewRequestWithContext` req71 := MyRequest2(*req7) f4(&req71, ctx) - req72, _ := http.NewRequest(http.MethodPost, url, nil) // OK + req72, _ := http.NewRequest(http.MethodPost, url, nil) // want `net/http\.NewRequest must not be called. use net/http\.NewRequestWithContext` req72 = req72.WithContext(ctx) req73 := MyRequest2(*req7) f4(&req73, ctx) req8, _ := func() (*http.Request, error) { - return http.NewRequest(http.MethodPost, url, nil) // want `should rewrite http.NewRequestWithContext or add \(\*Request\).WithContext` + return http.NewRequest(http.MethodPost, url, nil) // want `net/http\.NewRequest must not be called. use net/http\.NewRequestWithContext` }() cli.Do(req8) req82, _ := func() (*http.Request, error) { - req82, _ := http.NewRequest(http.MethodPost, url, nil) // OK + req82, _ := http.NewRequest(http.MethodPost, url, nil) // want `net/http\.NewRequest must not be called. use net/http\.NewRequestWithContext` req82 = req82.WithContext(ctx) return req82, nil }() @@ -118,33 +103,99 @@ func _() { f5 := func(req, req2 *http.Request, ctx context.Context) (*http.Request, *http.Request) { return req, req2 } - req9, _ := http.NewRequest(http.MethodPost, url, nil) // want `should rewrite http.NewRequestWithContext or add \(\*Request\).WithContext` + req9, _ := http.NewRequest(http.MethodPost, url, nil) // want `net/http\.NewRequest must not be called. use net/http\.NewRequestWithContext` req9, _ = f5(req9, req9, ctx) - req91, _ := http.NewRequest(http.MethodPost, url, nil) // OK + req91, _ := http.NewRequest(http.MethodPost, url, nil) // want `net/http\.NewRequest must not be called. use net/http\.NewRequestWithContext` req91 = req91.WithContext(ctx) req9, _ = f5(req91, req91, ctx) - req10, _ := http.NewRequest(http.MethodPost, url, nil) // want `should rewrite http.NewRequestWithContext or add \(\*Request\).WithContext` - req11, _ := http.NewRequest(http.MethodPost, url, nil) // want `should rewrite http.NewRequestWithContext or add \(\*Request\).WithContext` + req10, _ := http.NewRequest(http.MethodPost, url, nil) // want `net/http\.NewRequest must not be called. use net/http\.NewRequestWithContext` + req11, _ := http.NewRequest(http.MethodPost, url, nil) // want `net/http\.NewRequest must not be called. use net/http\.NewRequestWithContext` req10, req11 = f5(req10, req11, ctx) - req101, _ := http.NewRequest(http.MethodPost, url, nil) // want `should rewrite http.NewRequestWithContext or add \(\*Request\).WithContext` - req111, _ := http.NewRequest(http.MethodPost, url, nil) // OK + req101, _ := http.NewRequest(http.MethodPost, url, nil) // want `net/http\.NewRequest must not be called. use net/http\.NewRequestWithContext` + req111, _ := http.NewRequest(http.MethodPost, url, nil) // want `net/http\.NewRequest must not be called. use net/http\.NewRequestWithContext` req111 = req111.WithContext(ctx) req101, req111 = f5(req101, req111, ctx) func() (*http.Request, *http.Request) { - req12, _ := http.NewRequest(http.MethodPost, url, nil) // want `should rewrite http.NewRequestWithContext or add \(\*Request\).WithContext` - req13, _ := http.NewRequest(http.MethodPost, url, nil) // want `should rewrite http.NewRequestWithContext or add \(\*Request\).WithContext` + req12, _ := http.NewRequest(http.MethodPost, url, nil) // want `net/http\.NewRequest must not be called. use net/http\.NewRequestWithContext` + req13, _ := http.NewRequest(http.MethodPost, url, nil) // want `net/http\.NewRequest must not be called. use net/http\.NewRequestWithContext` return req12, req13 }() func() (*http.Request, *http.Request) { - req14, _ := http.NewRequest(http.MethodPost, url, nil) // want `should rewrite http.NewRequestWithContext or add \(\*Request\).WithContext` - req15, _ := http.NewRequest(http.MethodPost, url, nil) // OK + req14, _ := http.NewRequest(http.MethodPost, url, nil) // want `net/http\.NewRequest must not be called. use net/http\.NewRequestWithContext` + req15, _ := http.NewRequest(http.MethodPost, url, nil) // want `net/http\.NewRequest must not be called. use net/http\.NewRequestWithContext` req15 = req15.WithContext(ctx) return req14, req15 }() + + req121, _ := http.NewRequest(http.MethodPost, url, nil) // want `net/http\.NewRequest must not be called. use net/http\.NewRequestWithContext` + req121.AddCookie(&http.Cookie{Name: "k", Value: "v"}) + req121 = req121.WithContext(context.WithValue(req121.Context(), struct{}{}, 0)) + cli.Do(req121) +} + +func _() { + const url = "http://example.com" + cli := &http.Client{} + + http.Get(url) // want `net/http\.Get must not be called. use net/http\.NewRequestWithContext and \(\*net/http.Client\)\.Do\(\*http.Request\)` + _ = http.Get // OK + f := http.Get // OK + f(url) // want `net/http\.Get must not be called. use net/http\.NewRequestWithContext and \(\*net/http.Client\)\.Do\(\*http.Request\)` + + http.Head(url) // want `net/http\.Head must not be called. use net/http\.NewRequestWithContext and \(\*net/http.Client\)\.Do\(\*http.Request\)` + http.Post(url, "", nil) // want `net/http\.Post must not be called. use net/http\.NewRequestWithContext and \(\*net/http.Client\)\.Do\(\*http.Request\)` + http.PostForm(url, nil) // want `net/http\.PostForm must not be called. use net/http\.NewRequestWithContext and \(\*net/http.Client\)\.Do\(\*http.Request\)` + + cli.Get(url) // want `\(\*net/http\.Client\)\.Get must not be called. use \(\*net/http.Client\)\.Do\(\*http.Request\)` + _ = cli.Get // OK + m := cli.Get // OK + m(url) // want `\(\*net/http\.Client\)\.Get must not be called. use \(\*net/http.Client\)\.Do\(\*http.Request\)` + + cli.Head(url) // want `\(\*net/http\.Client\)\.Head must not be called. use \(\*net/http.Client\)\.Do\(\*http.Request\)` + cli.Post(url, "", nil) // want `\(\*net/http\.Client\)\.Post must not be called. use \(\*net/http.Client\)\.Do\(\*http.Request\)` + cli.PostForm(url, nil) // want `\(\*net/http\.Client\)\.PostForm must not be called. use \(\*net/http.Client\)\.Do\(\*http.Request\)` +} + +func _() { + ctx := context.Background() + + db, _ := sql.Open("noctx", "noctx://") + + db.Exec("select * from testdata") // want `\(\*database/sql\.DB\)\.Exec must not be called. use \(\*database/sql\.DB\)\.ExecContext` + db.ExecContext(ctx, "select * from testdata") + + db.Ping() // want `\(\*database/sql\.DB\)\.Ping must not be called. use \(\*database/sql\.DB\)\.PingContext` + db.PingContext(ctx) + + db.Prepare("select * from testdata") // want `\(\*database/sql\.DB\)\.Prepare must not be called. use \(\*database/sql\.DB\)\.PrepareContext` + db.PrepareContext(ctx, "select * from testdata") + + db.Query("select * from testdata") // want `\(\*database/sql\.DB\)\.Query must not be called. use \(\*database/sql\.DB\)\.QueryContext` + db.QueryContext(ctx, "select * from testdata") + + db.QueryRow("select * from testdata") // want `\(\*database/sql\.DB\)\.QueryRow must not be called. use \(\*database/sql\.DB\)\.QueryRowContext` + db.QueryRowContext(ctx, "select * from testdata") + + // transactions + + tx, _ := db.Begin() + tx.Exec("select * from testdata") // want `\(\*database/sql\.Tx\)\.Exec must not be called. use \(\*database/sql\.Tx\)\.ExecContext` + tx.ExecContext(ctx, "select * from testdata") + + tx.Prepare("select * from testdata") // want `\(\*database/sql\.Tx\)\.Prepare must not be called. use \(\*database/sql\.Tx\)\.PrepareContext` + tx.PrepareContext(ctx, "select * from testdata") + + tx.Query("select * from testdata") // want `\(\*database/sql\.Tx\)\.Query must not be called. use \(\*database/sql\.Tx\)\.QueryContext` + tx.QueryContext(ctx, "select * from testdata") + + tx.QueryRow("select * from testdata") // want `\(\*database/sql\.Tx\)\.QueryRow must not be called. use \(\*database/sql\.Tx\)\.QueryRowContext` + tx.QueryRowContext(ctx, "select * from testdata") + + _ = tx.Commit() } From 5546285060b42d2e036126d0f10b4d4ee6647e79 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 5 May 2025 22:57:00 +0200 Subject: [PATCH 43/96] build(deps): bump golangci/golangci-lint-action from 7.0.0 to 8.0.0 in the github-actions group (#5780) --- .github/workflows/pr-tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pr-tests.yml b/.github/workflows/pr-tests.yml index 380472037050..5f5606e97835 100644 --- a/.github/workflows/pr-tests.yml +++ b/.github/workflows/pr-tests.yml @@ -41,7 +41,7 @@ jobs: # - 1.18rc1 -> 1.18.0-rc.1 go-version: ${{ env.GO_VERSION }} - name: lint - uses: golangci/golangci-lint-action@v7.0.0 + uses: golangci/golangci-lint-action@v8.0.0 with: version: latest From 9e01be592bef3e264df30aeb4444d1429fc60ba0 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 5 May 2025 22:57:28 +0200 Subject: [PATCH 44/96] build(deps): bump golang.org/x/oauth2 from 0.29.0 to 0.30.0 in /scripts/gen_github_action_config in the scripts group (#5781) --- scripts/gen_github_action_config/go.mod | 2 +- scripts/gen_github_action_config/go.sum | 6 ++---- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/scripts/gen_github_action_config/go.mod b/scripts/gen_github_action_config/go.mod index c76a4de5840a..32b5cca642a1 100644 --- a/scripts/gen_github_action_config/go.mod +++ b/scripts/gen_github_action_config/go.mod @@ -5,7 +5,7 @@ go 1.23.0 require ( github.com/shurcooL/githubv4 v0.0.0-20240429030203-be2daab69064 github.com/stretchr/testify v1.10.0 - golang.org/x/oauth2 v0.29.0 + golang.org/x/oauth2 v0.30.0 ) require ( diff --git a/scripts/gen_github_action_config/go.sum b/scripts/gen_github_action_config/go.sum index b9b970ef73ac..16f1f14cd28c 100644 --- a/scripts/gen_github_action_config/go.sum +++ b/scripts/gen_github_action_config/go.sum @@ -1,7 +1,5 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= -github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/shurcooL/githubv4 v0.0.0-20240429030203-be2daab69064 h1:RCQBSFx5JrsbHltqTtJ+kN3U0Y3a/N/GlVdmRSoxzyE= @@ -10,8 +8,8 @@ github.com/shurcooL/graphql v0.0.0-20230722043721-ed46e5a46466 h1:17JxqqJY66GmZV github.com/shurcooL/graphql v0.0.0-20230722043721-ed46e5a46466/go.mod h1:9dIRpgIY7hVhoqfe0/FcYp0bpInZaT7dc3BYOprrIUE= github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA= github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= -golang.org/x/oauth2 v0.29.0 h1:WdYw2tdTK1S8olAzWHdgeqfy+Mtm9XNhv/xJsY65d98= -golang.org/x/oauth2 v0.29.0/go.mod h1:onh5ek6nERTohokkhCD/y2cV4Do3fxFHFuAejCkRWT8= +golang.org/x/oauth2 v0.30.0 h1:dnDm7JmhM45NNpd8FDDeLhK6FwqbOf4MLCM9zb1BOHI= +golang.org/x/oauth2 v0.30.0/go.mod h1:B++QgG3ZKulg6sRPGD/mqlHQs5rB3Ml9erfeDY7xKlU= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= From ed782d7ccc1f046017ec50028911e1ffbcb42726 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 7 May 2025 08:43:57 +0200 Subject: [PATCH 45/96] build(deps): bump github.com/jjti/go-spancheck from 0.6.4 to 0.6.5 (#5784) --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 1e7e82b195f4..70370e73d9ae 100644 --- a/go.mod +++ b/go.mod @@ -58,7 +58,7 @@ require ( github.com/hashicorp/go-version v1.7.0 github.com/jgautheron/goconst v1.8.1 github.com/jingyugao/rowserrcheck v1.1.1 - github.com/jjti/go-spancheck v0.6.4 + github.com/jjti/go-spancheck v0.6.5 github.com/julz/importas v0.2.0 github.com/karamaru-alpha/copyloopvar v1.2.1 github.com/kisielk/errcheck v1.9.0 diff --git a/go.sum b/go.sum index 9875fd835bef..ed6eb8577de7 100644 --- a/go.sum +++ b/go.sum @@ -333,8 +333,8 @@ github.com/jgautheron/goconst v1.8.1 h1:PPqCYp3K/xlOj5JmIe6O1Mj6r1DbkdbLtR3AJuZo github.com/jgautheron/goconst v1.8.1/go.mod h1:A0oxgBCHy55NQn6sYpO7UdnA9p+h7cPtoOZUmvNIako= github.com/jingyugao/rowserrcheck v1.1.1 h1:zibz55j/MJtLsjP1OF4bSdgXxwL1b+Vn7Tjzq7gFzUs= github.com/jingyugao/rowserrcheck v1.1.1/go.mod h1:4yvlZSDb3IyDTUZJUmpZfm2Hwok+Dtp+nu2qOq+er9c= -github.com/jjti/go-spancheck v0.6.4 h1:Tl7gQpYf4/TMU7AT84MN83/6PutY21Nb9fuQjFTpRRc= -github.com/jjti/go-spancheck v0.6.4/go.mod h1:yAEYdKJ2lRkDA8g7X+oKUHXOWVAXSBJRv04OhF+QUjk= +github.com/jjti/go-spancheck v0.6.5 h1:lmi7pKxa37oKYIMScialXUK6hP3iY5F1gu+mLBPgYB8= +github.com/jjti/go-spancheck v0.6.5/go.mod h1:aEogkeatBrbYsyW6y5TgDfihCulDYciL1B7rG2vSsrU= github.com/jpillora/backoff v1.0.0/go.mod h1:J/6gKK9jxlEcS3zixgDgUAsiuZ7yrSoa/FX5e0EB2j4= github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= github.com/json-iterator/go v1.1.10/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= From f0c85146f8387ca32d2207fde8f87447038e59e8 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 7 May 2025 08:45:03 +0200 Subject: [PATCH 46/96] build(deps): bump golang.org/x/sys from 0.32.0 to 0.33.0 (#5785) --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 70370e73d9ae..7af6dc58f00c 100644 --- a/go.mod +++ b/go.mod @@ -129,7 +129,7 @@ require ( go.augendre.info/fatcontext v0.8.0 go.uber.org/automaxprocs v1.6.0 golang.org/x/mod v0.24.0 - golang.org/x/sys v0.32.0 + golang.org/x/sys v0.33.0 golang.org/x/tools v0.32.0 gopkg.in/yaml.v3 v3.0.1 honnef.co/go/tools v0.6.1 diff --git a/go.sum b/go.sum index ed6eb8577de7..2e633e945d0c 100644 --- a/go.sum +++ b/go.sum @@ -821,8 +821,8 @@ golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.32.0 h1:s77OFDvIQeibCmezSnk/q6iAfkdiQaJi4VzroCFrN20= -golang.org/x/sys v0.32.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k= +golang.org/x/sys v0.33.0 h1:q3i8TbbEz+JRD9ywIRlyRAQbM0qF7hu24q3teo2hbuw= +golang.org/x/sys v0.33.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.2.0/go.mod h1:TVmDHMZPmdnySmBfhjOoOdhjzdE1h4u1VwSiw2l1Nuc= From 4af8bfc6babe74607093cbe4c329f29da463c49e Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 7 May 2025 09:04:06 +0200 Subject: [PATCH 47/96] build(deps): bump golang.org/x/tools from 0.32.0 to 0.33.0 (#5786) Co-authored-by: Fernandez Ludovic --- .golangci.next.reference.yml | 3 +++ go.mod | 4 ++-- go.sum | 12 ++++++------ jsonschema/golangci.next.jsonschema.json | 1 + pkg/golinters/govet/govet.go | 2 ++ 5 files changed, 14 insertions(+), 8 deletions(-) diff --git a/.golangci.next.reference.yml b/.golangci.next.reference.yml index dbcc0377a400..6a33e30e33d7 100644 --- a/.golangci.next.reference.yml +++ b/.golangci.next.reference.yml @@ -1600,6 +1600,8 @@ linters: - findcall # Report assembly that clobbers the frame pointer before saving it. - framepointer + # Check format of addresses passed to net.Dial. + - hostport # Report using Go 1.22 enhanced ServeMux patterns in older Go versions. - httpmux # Check for mistakes using HTTP responses. @@ -1683,6 +1685,7 @@ linters: - fieldalignment - findcall - framepointer + - hostport - httpmux - httpresponse - ifaceassert diff --git a/go.mod b/go.mod index 7af6dc58f00c..7fe86342c3ec 100644 --- a/go.mod +++ b/go.mod @@ -130,7 +130,7 @@ require ( go.uber.org/automaxprocs v1.6.0 golang.org/x/mod v0.24.0 golang.org/x/sys v0.33.0 - golang.org/x/tools v0.32.0 + golang.org/x/tools v0.33.0 gopkg.in/yaml.v3 v3.0.1 honnef.co/go/tools v0.6.1 mvdan.cc/gofumpt v0.8.0 @@ -209,7 +209,7 @@ require ( go.uber.org/zap v1.24.0 // indirect golang.org/x/exp v0.0.0-20240909161429-701f63a606c0 // indirect golang.org/x/exp/typeparams v0.0.0-20250210185358-939b2ce775ac // indirect - golang.org/x/sync v0.13.0 // indirect + golang.org/x/sync v0.14.0 // indirect golang.org/x/text v0.24.0 // indirect google.golang.org/protobuf v1.36.6 // indirect gopkg.in/ini.v1 v1.67.0 // indirect diff --git a/go.sum b/go.sum index 2e633e945d0c..48e83d966edf 100644 --- a/go.sum +++ b/go.sum @@ -741,8 +741,8 @@ golang.org/x/net v0.8.0/go.mod h1:QVkue5JL9kW//ek3r6jTKnTFis1tRmNAW2P1shuFdJc= golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg= golang.org/x/net v0.15.0/go.mod h1:idbUs1IY1+zTqbi8yxTbhexhEEk5ur9LInksu6HrEpk= golang.org/x/net v0.16.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE= -golang.org/x/net v0.39.0 h1:ZCu7HMWDxpXpaiKdhzIfaltL9Lp31x/3fCP11bc6/fY= -golang.org/x/net v0.39.0/go.mod h1:X7NRbYVEA+ewNkCNyJ513WmMdQ3BineSwVtN2zD/d+E= +golang.org/x/net v0.40.0 h1:79Xs7wF06Gbdcg4kdCCIQArK11Z1hr5POQ6+fIYHNuY= +golang.org/x/net v0.40.0/go.mod h1:y0hY0exeL2Pku80/zKK7tpntoX23cqL3Oa6njdgRtds= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= @@ -764,8 +764,8 @@ golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJ golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.3.0/go.mod h1:FU7BRWz2tNW+3quACPkgCx/L+uEAv1htQ0V83Z9Rj+Y= golang.org/x/sync v0.4.0/go.mod h1:FU7BRWz2tNW+3quACPkgCx/L+uEAv1htQ0V83Z9Rj+Y= -golang.org/x/sync v0.13.0 h1:AauUjRAJ9OSnvULf/ARrrVywoJDy0YS2AwQ98I37610= -golang.org/x/sync v0.13.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA= +golang.org/x/sync v0.14.0 h1:woo0S4Yywslg6hp4eUFjTVOyKt0RookbpAHG4c1HmhQ= +golang.org/x/sync v0.14.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA= golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= @@ -904,8 +904,8 @@ golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU= golang.org/x/tools v0.7.0/go.mod h1:4pg6aUX35JBAogB10C9AtvVL+qowtN4pT3CGSQex14s= golang.org/x/tools v0.13.0/go.mod h1:HvlwmtVNQAhOuCjW7xxvovg8wbNq7LwfXh/k7wXUl58= golang.org/x/tools v0.14.0/go.mod h1:uYBEerGOWcJyEORxN+Ek8+TT266gXkNlHdJBwexUsBg= -golang.org/x/tools v0.32.0 h1:Q7N1vhpkQv7ybVzLFtTjvQya2ewbwNDZzUgfXGqtMWU= -golang.org/x/tools v0.32.0/go.mod h1:ZxrU41P/wAbZD8EDa6dDCa6XfpkhJ7HFMjHJXfBDu8s= +golang.org/x/tools v0.33.0 h1:4qz2S3zmRxbGIhDIAgjxvFutSvH5EfnsYrRBj0UI0bc= +golang.org/x/tools v0.33.0/go.mod h1:CIJMaWEY88juyUfo7UbgPqbC8rU2OqfAV1h2Qp0oMYI= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= diff --git a/jsonschema/golangci.next.jsonschema.json b/jsonschema/golangci.next.jsonschema.json index 9af538279cbc..5868d65451b2 100644 --- a/jsonschema/golangci.next.jsonschema.json +++ b/jsonschema/golangci.next.jsonschema.json @@ -539,6 +539,7 @@ "fieldalignment", "findcall", "framepointer", + "hostport", "httpmux", "httpresponse", "ifaceassert", diff --git a/pkg/golinters/govet/govet.go b/pkg/golinters/govet/govet.go index 4f3380841382..e4de5b0f4459 100644 --- a/pkg/golinters/govet/govet.go +++ b/pkg/golinters/govet/govet.go @@ -24,6 +24,7 @@ import ( "golang.org/x/tools/go/analysis/passes/fieldalignment" "golang.org/x/tools/go/analysis/passes/findcall" "golang.org/x/tools/go/analysis/passes/framepointer" + "golang.org/x/tools/go/analysis/passes/hostport" "golang.org/x/tools/go/analysis/passes/httpmux" "golang.org/x/tools/go/analysis/passes/httpresponse" "golang.org/x/tools/go/analysis/passes/ifaceassert" @@ -78,6 +79,7 @@ var ( fieldalignment.Analyzer, findcall.Analyzer, framepointer.Analyzer, + hostport.Analyzer, httpmux.Analyzer, httpresponse.Analyzer, ifaceassert.Analyzer, From e905d8072c5f0a75434d1ddee57bdcdcf52fb00f Mon Sep 17 00:00:00 2001 From: Ludovic Fernandez Date: Wed, 7 May 2025 09:22:29 +0200 Subject: [PATCH 48/96] build(deps): bump github.com/ashanbrown/makezero from 1.2.0 to 2.0.1 (#5782) --- go.mod | 2 +- go.sum | 9 ++------- pkg/golinters/makezero/makezero.go | 2 +- 3 files changed, 4 insertions(+), 9 deletions(-) diff --git a/go.mod b/go.mod index 7fe86342c3ec..5f674f0fc464 100644 --- a/go.mod +++ b/go.mod @@ -21,7 +21,7 @@ require ( github.com/alingse/asasalint v0.0.11 github.com/alingse/nilnesserr v0.2.0 github.com/ashanbrown/forbidigo v1.6.0 - github.com/ashanbrown/makezero v1.2.0 + github.com/ashanbrown/makezero/v2 v2.0.1 github.com/bkielbasa/cyclop v1.2.3 github.com/blizzy78/varnamelen v0.8.0 github.com/bombsimon/wsl/v4 v4.7.0 diff --git a/go.sum b/go.sum index 48e83d966edf..d45301e293e7 100644 --- a/go.sum +++ b/go.sum @@ -80,8 +80,8 @@ github.com/alingse/nilnesserr v0.2.0 h1:raLem5KG7EFVb4UIDAXgrv3N2JIaffeKNtcEXkEW github.com/alingse/nilnesserr v0.2.0/go.mod h1:1xJPrXonEtX7wyTq8Dytns5P2hNzoWymVUIaKm4HNFg= github.com/ashanbrown/forbidigo v1.6.0 h1:D3aewfM37Yb3pxHujIPSpTf6oQk9sc9WZi8gerOIVIY= github.com/ashanbrown/forbidigo v1.6.0/go.mod h1:Y8j9jy9ZYAEHXdu723cUlraTqbzjKF1MUyfOKL+AjcU= -github.com/ashanbrown/makezero v1.2.0 h1:/2Lp1bypdmK9wDIq7uWBlDF1iMUpIIS4A+pF6C9IEUU= -github.com/ashanbrown/makezero v1.2.0/go.mod h1:dxlPhHbDMC6N6xICzFBSK+4njQDdK8euNO0qjQMtGY4= +github.com/ashanbrown/makezero/v2 v2.0.1 h1:r8GtKetWOgoJ4sLyUx97UTwyt2dO7WkGFHizn/Lo8TY= +github.com/ashanbrown/makezero/v2 v2.0.1/go.mod h1:kKU4IMxmYW1M4fiEHMb2vc5SFoPzXvgbMR9gIp5pjSw= github.com/aymanbagabas/go-osc52/v2 v2.0.1 h1:HwpRHbFMcZLEVr42D4p7XBqjyuxQH5SMiErDT4WkJ2k= github.com/aymanbagabas/go-osc52/v2 v2.0.1/go.mod h1:uYgXzlJ7ZpABp8OJ+exZzJJhRNQ2ASbcXHWsFqH8hp8= github.com/benbjohnson/clock v1.1.0 h1:Q92kusRqC1XV2MjkWETPvjJVqKetz1OzxZB7mHJLju8= @@ -696,7 +696,6 @@ golang.org/x/mod v0.6.0-dev.0.20220106191415-9b9b3d81d5e3/go.mod h1:3p9vT2HGsQu2 golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= golang.org/x/mod v0.7.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= -golang.org/x/mod v0.9.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= golang.org/x/mod v0.12.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= golang.org/x/mod v0.13.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= golang.org/x/mod v0.24.0 h1:ZfthKaKaT4NrhGVZHO1/WDTwGES4De8KtWO0SIbNJMU= @@ -737,7 +736,6 @@ golang.org/x/net v0.0.0-20211015210444-4f30a5c0130f/go.mod h1:9nx3DQGgdP8bBQD5qx golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= golang.org/x/net v0.2.0/go.mod h1:KqCZLdyyvdV855qA2rE3GC2aiw5xGR5TEjj8smXukLY= golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= -golang.org/x/net v0.8.0/go.mod h1:QVkue5JL9kW//ek3r6jTKnTFis1tRmNAW2P1shuFdJc= golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg= golang.org/x/net v0.15.0/go.mod h1:idbUs1IY1+zTqbi8yxTbhexhEEk5ur9LInksu6HrEpk= golang.org/x/net v0.16.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE= @@ -827,7 +825,6 @@ golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9sn golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.2.0/go.mod h1:TVmDHMZPmdnySmBfhjOoOdhjzdE1h4u1VwSiw2l1Nuc= golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k= -golang.org/x/term v0.6.0/go.mod h1:m6U89DPEgQRMq3DNkDClhWw02AUbt2daBVO4cn4Hv9U= golang.org/x/term v0.8.0/go.mod h1:xPskH00ivmX89bAKVGSKKtLOWNx2+17Eiy94tnKShWo= golang.org/x/term v0.12.0/go.mod h1:owVbMEjm3cBLCHdkQu9b1opXd4ETQWc3BhuQGKgXgvU= golang.org/x/term v0.13.0/go.mod h1:LTmsnFJwVN6bCy1rVCoS+qHT1HhALEFxKncY3WNNh4U= @@ -840,7 +837,6 @@ golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= -golang.org/x/text v0.8.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= golang.org/x/text v0.24.0 h1:dd5Bzh4yt5KYA8f9CJHCP4FB4D51c2c6JvN37xJJkJ0= @@ -901,7 +897,6 @@ golang.org/x/tools v0.1.10/go.mod h1:Uh6Zz+xoGYZom868N8YTex3t7RhtHDBrE8Gzo9bV56E golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= golang.org/x/tools v0.3.0/go.mod h1:/rWhSS2+zyEVwoJf8YAX6L2f0ntZ7Kn/mGgAWcipA5k= golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU= -golang.org/x/tools v0.7.0/go.mod h1:4pg6aUX35JBAogB10C9AtvVL+qowtN4pT3CGSQex14s= golang.org/x/tools v0.13.0/go.mod h1:HvlwmtVNQAhOuCjW7xxvovg8wbNq7LwfXh/k7wXUl58= golang.org/x/tools v0.14.0/go.mod h1:uYBEerGOWcJyEORxN+Ek8+TT266gXkNlHdJBwexUsBg= golang.org/x/tools v0.33.0 h1:4qz2S3zmRxbGIhDIAgjxvFutSvH5EfnsYrRBj0UI0bc= diff --git a/pkg/golinters/makezero/makezero.go b/pkg/golinters/makezero/makezero.go index 04b4fe93dadf..8b86f120679e 100644 --- a/pkg/golinters/makezero/makezero.go +++ b/pkg/golinters/makezero/makezero.go @@ -3,7 +3,7 @@ package makezero import ( "fmt" - "github.com/ashanbrown/makezero/makezero" + "github.com/ashanbrown/makezero/v2/makezero" "golang.org/x/tools/go/analysis" "github.com/golangci/golangci-lint/v2/pkg/config" From acbcbdbd1583e557c882d618192a5b5ffb773b34 Mon Sep 17 00:00:00 2001 From: Ludovic Fernandez Date: Wed, 7 May 2025 11:06:32 +0200 Subject: [PATCH 49/96] build(deps): bump github.com/ashanbrown/forbidigo from 1.6.0 to 2.1.0 (#5783) --- go.mod | 2 +- go.sum | 11 ++--------- pkg/golinters/forbidigo/forbidigo.go | 2 +- 3 files changed, 4 insertions(+), 11 deletions(-) diff --git a/go.mod b/go.mod index 5f674f0fc464..4dc784cf12b2 100644 --- a/go.mod +++ b/go.mod @@ -20,7 +20,7 @@ require ( github.com/alexkohler/prealloc v1.0.0 github.com/alingse/asasalint v0.0.11 github.com/alingse/nilnesserr v0.2.0 - github.com/ashanbrown/forbidigo v1.6.0 + github.com/ashanbrown/forbidigo/v2 v2.1.0 github.com/ashanbrown/makezero/v2 v2.0.1 github.com/bkielbasa/cyclop v1.2.3 github.com/blizzy78/varnamelen v0.8.0 diff --git a/go.sum b/go.sum index d45301e293e7..3cb33099781e 100644 --- a/go.sum +++ b/go.sum @@ -78,8 +78,8 @@ github.com/alingse/asasalint v0.0.11 h1:SFwnQXJ49Kx/1GghOFz1XGqHYKp21Kq1nHad/0WQ github.com/alingse/asasalint v0.0.11/go.mod h1:nCaoMhw7a9kSJObvQyVzNTPBDbNpdocqrSP7t/cW5+I= github.com/alingse/nilnesserr v0.2.0 h1:raLem5KG7EFVb4UIDAXgrv3N2JIaffeKNtcEXkEWd/w= github.com/alingse/nilnesserr v0.2.0/go.mod h1:1xJPrXonEtX7wyTq8Dytns5P2hNzoWymVUIaKm4HNFg= -github.com/ashanbrown/forbidigo v1.6.0 h1:D3aewfM37Yb3pxHujIPSpTf6oQk9sc9WZi8gerOIVIY= -github.com/ashanbrown/forbidigo v1.6.0/go.mod h1:Y8j9jy9ZYAEHXdu723cUlraTqbzjKF1MUyfOKL+AjcU= +github.com/ashanbrown/forbidigo/v2 v2.1.0 h1:NAxZrWqNUQiDz19FKScQ/xvwzmij6BiOw3S0+QUQ+Hs= +github.com/ashanbrown/forbidigo/v2 v2.1.0/go.mod h1:0zZfdNAuZIL7rSComLGthgc/9/n2FqspBOH90xlCHdA= github.com/ashanbrown/makezero/v2 v2.0.1 h1:r8GtKetWOgoJ4sLyUx97UTwyt2dO7WkGFHizn/Lo8TY= github.com/ashanbrown/makezero/v2 v2.0.1/go.mod h1:kKU4IMxmYW1M4fiEHMb2vc5SFoPzXvgbMR9gIp5pjSw= github.com/aymanbagabas/go-osc52/v2 v2.0.1 h1:HwpRHbFMcZLEVr42D4p7XBqjyuxQH5SMiErDT4WkJ2k= @@ -560,7 +560,6 @@ github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/ github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= -github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= @@ -694,7 +693,6 @@ golang.org/x/mod v0.4.1/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.6.0-dev.0.20220106191415-9b9b3d81d5e3/go.mod h1:3p9vT2HGsQu2K1YbXdKPJLVgG5VJdoTa1poYQBtP1AY= golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= -golang.org/x/mod v0.7.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= golang.org/x/mod v0.12.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= golang.org/x/mod v0.13.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= @@ -734,7 +732,6 @@ golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96b golang.org/x/net v0.0.0-20210525063256-abc453219eb5/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20211015210444-4f30a5c0130f/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= -golang.org/x/net v0.2.0/go.mod h1:KqCZLdyyvdV855qA2rE3GC2aiw5xGR5TEjj8smXukLY= golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg= golang.org/x/net v0.15.0/go.mod h1:idbUs1IY1+zTqbi8yxTbhexhEEk5ur9LInksu6HrEpk= @@ -812,7 +809,6 @@ golang.org/x/sys v0.0.0-20220412211240-33da011f77ad/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= @@ -823,7 +819,6 @@ golang.org/x/sys v0.33.0 h1:q3i8TbbEz+JRD9ywIRlyRAQbM0qF7hu24q3teo2hbuw= golang.org/x/sys v0.33.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= -golang.org/x/term v0.2.0/go.mod h1:TVmDHMZPmdnySmBfhjOoOdhjzdE1h4u1VwSiw2l1Nuc= golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k= golang.org/x/term v0.8.0/go.mod h1:xPskH00ivmX89bAKVGSKKtLOWNx2+17Eiy94tnKShWo= golang.org/x/term v0.12.0/go.mod h1:owVbMEjm3cBLCHdkQu9b1opXd4ETQWc3BhuQGKgXgvU= @@ -835,7 +830,6 @@ golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= -golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= @@ -895,7 +889,6 @@ golang.org/x/tools v0.1.1/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/tools v0.1.10/go.mod h1:Uh6Zz+xoGYZom868N8YTex3t7RhtHDBrE8Gzo9bV56E= golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= -golang.org/x/tools v0.3.0/go.mod h1:/rWhSS2+zyEVwoJf8YAX6L2f0ntZ7Kn/mGgAWcipA5k= golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU= golang.org/x/tools v0.13.0/go.mod h1:HvlwmtVNQAhOuCjW7xxvovg8wbNq7LwfXh/k7wXUl58= golang.org/x/tools v0.14.0/go.mod h1:uYBEerGOWcJyEORxN+Ek8+TT266gXkNlHdJBwexUsBg= diff --git a/pkg/golinters/forbidigo/forbidigo.go b/pkg/golinters/forbidigo/forbidigo.go index 45f9088fa97d..f7c5efd3d8f1 100644 --- a/pkg/golinters/forbidigo/forbidigo.go +++ b/pkg/golinters/forbidigo/forbidigo.go @@ -3,7 +3,7 @@ package forbidigo import ( "fmt" - "github.com/ashanbrown/forbidigo/forbidigo" + "github.com/ashanbrown/forbidigo/v2/forbidigo" "golang.org/x/tools/go/analysis" "gopkg.in/yaml.v3" From fd792aec377b3e473c52e73e8d08b5f0bcdec290 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 8 May 2025 14:42:51 +0200 Subject: [PATCH 50/96] build(deps): bump github.com/securego/gosec/v2 from 2.22.3 to 2.22.4 (#5788) --- go.mod | 6 +++--- go.sum | 24 ++++++++++++------------ 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/go.mod b/go.mod index 4dc784cf12b2..bcb9e58ccf16 100644 --- a/go.mod +++ b/go.mod @@ -96,7 +96,7 @@ require ( github.com/santhosh-tekuri/jsonschema/v6 v6.0.1 github.com/sashamelentyev/interfacebloat v1.1.0 github.com/sashamelentyev/usestdlibvars v1.28.0 - github.com/securego/gosec/v2 v2.22.3 + github.com/securego/gosec/v2 v2.22.4 github.com/shirou/gopsutil/v4 v4.25.4 github.com/sirupsen/logrus v1.9.3 github.com/sivchari/containedctx v1.0.3 @@ -141,7 +141,7 @@ require ( github.com/Masterminds/semver/v3 v3.3.1 // indirect github.com/aymanbagabas/go-osc52/v2 v2.0.1 // indirect github.com/beorn7/perks v1.0.1 // indirect - github.com/ccojocar/zxcvbn-go v1.0.2 // indirect + github.com/ccojocar/zxcvbn-go v1.0.4 // indirect github.com/cespare/xxhash/v2 v2.3.0 // indirect github.com/charmbracelet/colorprofile v0.2.3-0.20250311203215-f60798e515dc // indirect github.com/charmbracelet/x/ansi v0.8.0 // indirect @@ -210,7 +210,7 @@ require ( golang.org/x/exp v0.0.0-20240909161429-701f63a606c0 // indirect golang.org/x/exp/typeparams v0.0.0-20250210185358-939b2ce775ac // indirect golang.org/x/sync v0.14.0 // indirect - golang.org/x/text v0.24.0 // indirect + golang.org/x/text v0.25.0 // indirect google.golang.org/protobuf v1.36.6 // indirect gopkg.in/ini.v1 v1.67.0 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect diff --git a/go.sum b/go.sum index 3cb33099781e..96a2731998e3 100644 --- a/go.sum +++ b/go.sum @@ -106,8 +106,8 @@ github.com/butuzov/mirror v1.3.0 h1:HdWCXzmwlQHdVhwvsfBb2Au0r3HyINry3bDWLYXiKoc= github.com/butuzov/mirror v1.3.0/go.mod h1:AEij0Z8YMALaq4yQj9CPPVYOyJQyiexpQEQgihajRfI= github.com/catenacyber/perfsprint v0.9.1 h1:5LlTp4RwTooQjJCvGEFV6XksZvWE7wCOUvjD2z0vls0= github.com/catenacyber/perfsprint v0.9.1/go.mod h1:q//VWC2fWbcdSLEY1R3l8n0zQCDPdE4IjZwyY1HMunM= -github.com/ccojocar/zxcvbn-go v1.0.2 h1:na/czXU8RrhXO4EZme6eQJLR4PzcGsahsBOAwU6I3Vg= -github.com/ccojocar/zxcvbn-go v1.0.2/go.mod h1:g1qkXtUSvHP8lhHp5GrSmTz6uWALGRMQdw6Qnz/hi60= +github.com/ccojocar/zxcvbn-go v1.0.4 h1:FWnCIRMXPj43ukfX000kvBZvV6raSxakYr1nzyNrUcc= +github.com/ccojocar/zxcvbn-go v1.0.4/go.mod h1:3GxGX+rHmueTUMvm5ium7irpyjmm7ikxYFOSJB21Das= github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/cespare/xxhash/v2 v2.1.2/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= @@ -291,8 +291,8 @@ github.com/google/pprof v0.0.0-20200212024743-f11f1df84d12/go.mod h1:ZgVRPoUq/hf github.com/google/pprof v0.0.0-20200229191704-1ebb73c60ed3/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= github.com/google/pprof v0.0.0-20200430221834-fc25d7d30c6d/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= github.com/google/pprof v0.0.0-20200708004538-1a94d8640e99/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= -github.com/google/pprof v0.0.0-20241210010833-40e02aabc2ad h1:a6HEuzUHeKH6hwfN/ZoQgRgVIWFJljSWa/zetS2WTvg= -github.com/google/pprof v0.0.0-20241210010833-40e02aabc2ad/go.mod h1:vavhavw2zAxS5dIdcRluK6cSGGPlZynqzFM8NdvU144= +github.com/google/pprof v0.0.0-20250403155104-27863c87afa6 h1:BHT72Gu3keYf3ZEu2J0b1vyeLSOYI8bm5wbJM/8yDe8= +github.com/google/pprof v0.0.0-20250403155104-27863c87afa6/go.mod h1:boTsfXsheKC2y+lKOCMpSfarhxDeIzfZG1jqGcPl3cA= github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg= github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk= @@ -435,10 +435,10 @@ github.com/nunnatsa/ginkgolinter v0.19.1 h1:mjwbOlDQxZi9Cal+KfbEJTCz327OLNfwNvoZ github.com/nunnatsa/ginkgolinter v0.19.1/go.mod h1:jkQ3naZDmxaZMXPWaS9rblH+i+GWXQCaS/JFIWcOH2s= github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N7AbDhec= github.com/olekukonko/tablewriter v0.0.5/go.mod h1:hPp6KlRPjbx+hW8ykQs1w3UBbZlj6HuIJcUGPhkA7kY= -github.com/onsi/ginkgo/v2 v2.23.3 h1:edHxnszytJ4lD9D5Jjc4tiDkPBZ3siDeJJkUZJJVkp0= -github.com/onsi/ginkgo/v2 v2.23.3/go.mod h1:zXTP6xIp3U8aVuXN8ENK9IXRaTjFnpVB9mGmaSRvxnM= -github.com/onsi/gomega v1.36.3 h1:hID7cr8t3Wp26+cYnfcjR6HpJ00fdogN6dqZ1t6IylU= -github.com/onsi/gomega v1.36.3/go.mod h1:8D9+Txp43QWKhM24yyOBEdpkzN8FvJyAwecBgsU4KU0= +github.com/onsi/ginkgo/v2 v2.23.4 h1:ktYTpKJAVZnDT4VjxSbiBenUjmlL/5QkBEocaWXiQus= +github.com/onsi/ginkgo/v2 v2.23.4/go.mod h1:Bt66ApGPBFzHyR+JO10Zbt0Gsp4uWxu5mIOTusL46e8= +github.com/onsi/gomega v1.37.0 h1:CdEG8g0S133B4OswTDC/5XPSzE1OeP29QOioj2PID2Y= +github.com/onsi/gomega v1.37.0/go.mod h1:8D9+Txp43QWKhM24yyOBEdpkzN8FvJyAwecBgsU4KU0= github.com/otiai10/copy v1.2.0/go.mod h1:rrF5dJ5F0t/EWSYODDu4j9/vEeYHMkc8jt0zJChqQWw= github.com/otiai10/copy v1.14.0 h1:dCI/t1iTdYGtkvCuBG2BgR6KZa83PTclw4U5n2wAllU= github.com/otiai10/copy v1.14.0/go.mod h1:ECfuL02W+/FkTWZWgQqXPWZgW9oeKCSQ5qVfSc4qc4w= @@ -515,8 +515,8 @@ github.com/sashamelentyev/interfacebloat v1.1.0 h1:xdRdJp0irL086OyW1H/RTZTr1h/tM github.com/sashamelentyev/interfacebloat v1.1.0/go.mod h1:+Y9yU5YdTkrNvoX0xHc84dxiN1iBi9+G8zZIhPVoNjQ= github.com/sashamelentyev/usestdlibvars v1.28.0 h1:jZnudE2zKCtYlGzLVreNp5pmCdOxXUzwsMDBkR21cyQ= github.com/sashamelentyev/usestdlibvars v1.28.0/go.mod h1:9nl0jgOfHKWNFS43Ojw0i7aRoS4j6EBye3YBhmAIRF8= -github.com/securego/gosec/v2 v2.22.3 h1:mRrCNmRF2NgZp4RJ8oJ6yPJ7G4x6OCiAXHd8x4trLRc= -github.com/securego/gosec/v2 v2.22.3/go.mod h1:42M9Xs0v1WseinaB/BmNGO8AVqG8vRfhC2686ACY48k= +github.com/securego/gosec/v2 v2.22.4 h1:21VdNGcKicFSv6rUDBc0cEtEl7lWyCKZxKIm0iwvrIM= +github.com/securego/gosec/v2 v2.22.4/go.mod h1:ww5Yie7KJ3AH8XZQTletkW5zOmIse6FACs/Ys8VR3qE= github.com/sergi/go-diff v1.2.0 h1:XU+rvMAioB0UC3q1MFrIQy4Vo5/4VsRDQQXHsEya6xQ= github.com/sergi/go-diff v1.2.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM= github.com/shirou/gopsutil/v4 v4.25.4 h1:cdtFO363VEOOFrUCjZRh4XVJkb548lyF0q0uTeMqYPw= @@ -833,8 +833,8 @@ golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= -golang.org/x/text v0.24.0 h1:dd5Bzh4yt5KYA8f9CJHCP4FB4D51c2c6JvN37xJJkJ0= -golang.org/x/text v0.24.0/go.mod h1:L8rBsPeo2pSS+xqN0d5u2ikmjtmoJbDBT1b7nHvFCdU= +golang.org/x/text v0.25.0 h1:qVyWApTSYLk/drJRO5mDlNYskwQznZmkpV2c8q9zls4= +golang.org/x/text v0.25.0/go.mod h1:WEdwpYrmk1qmdHvhkSTNPm3app7v4rsT8F2UD6+VHIA= golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= From 5a945fd5546aaa14f315105a651a236736217595 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sun, 11 May 2025 14:11:28 +0200 Subject: [PATCH 51/96] build(deps): bump github.com/manuelarte/funcorder from 0.3.0 to 0.5.0 (#5792) --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index bcb9e58ccf16..3f294565b54e 100644 --- a/go.mod +++ b/go.mod @@ -73,7 +73,7 @@ require ( github.com/ldez/usetesting v0.4.3 github.com/leonklingele/grouper v1.1.2 github.com/macabu/inamedparam v0.2.0 - github.com/manuelarte/funcorder v0.3.0 + github.com/manuelarte/funcorder v0.5.0 github.com/maratori/testableexamples v1.0.0 github.com/maratori/testpackage v1.1.1 github.com/matoous/godox v1.1.0 diff --git a/go.sum b/go.sum index 96a2731998e3..a522b52fb450 100644 --- a/go.sum +++ b/go.sum @@ -389,8 +389,8 @@ github.com/macabu/inamedparam v0.2.0 h1:VyPYpOc10nkhI2qeNUdh3Zket4fcZjEWe35poddB github.com/macabu/inamedparam v0.2.0/go.mod h1:+Pee9/YfGe5LJ62pYXqB89lJ+0k5bsR8Wgz/C0Zlq3U= github.com/magiconair/properties v1.8.6 h1:5ibWZ6iY0NctNGWo87LalDlEZ6R41TqbbDamhfG/Qzo= github.com/magiconair/properties v1.8.6/go.mod h1:y3VJvCyxH9uVvJTWEGAELF3aiYNyPKd5NZ3oSwXrF60= -github.com/manuelarte/funcorder v0.3.0 h1:mV1joNYIjIUnnyZ6wfaC+sCWB6IvG62ay3xuhbklHps= -github.com/manuelarte/funcorder v0.3.0/go.mod h1:wBFktqsi8PyQvNYEUpF5Lt+V/xqgaevfCi4SSpUhyPo= +github.com/manuelarte/funcorder v0.5.0 h1:llMuHXXbg7tD0i/LNw8vGnkDTHFpTnWqKPI85Rknc+8= +github.com/manuelarte/funcorder v0.5.0/go.mod h1:Yt3CiUQthSBMBxjShjdXMexmzpP8YGvGLjrxJNkO2hA= github.com/maratori/testableexamples v1.0.0 h1:dU5alXRrD8WKSjOUnmJZuzdxWOEQ57+7s93SLMxb2vI= github.com/maratori/testableexamples v1.0.0/go.mod h1:4rhjL1n20TUTT4vdh3RDqSizKLyXp7K2u6HgraZCGzE= github.com/maratori/testpackage v1.1.1 h1:S58XVV5AD7HADMmD0fNnziNHqKvSdDuEKdPD1rNTU04= From 3e52be7b0d94868487584e6ce19e72a9bb906507 Mon Sep 17 00:00:00 2001 From: Cooper Benson Date: Sun, 11 May 2025 12:07:41 -0600 Subject: [PATCH 52/96] Add swaggo/swag formatter (#5749) Co-authored-by: Fernandez Ludovic --- .github/dependabot.yml | 1 + .golangci.next.reference.yml | 1 + go.mod | 1 + go.sum | 2 ++ jsonschema/golangci.next.jsonschema.json | 3 ++- pkg/config/linters.go | 2 +- pkg/goformatters/meta_formatter.go | 7 +++++- pkg/goformatters/swaggo/swaggo.go | 23 +++++++++++++++++++ pkg/golinters/swaggo/swaggo.go | 23 +++++++++++++++++++ .../swaggo/swaggo_integration_test.go | 19 +++++++++++++++ .../swaggo/testdata/fix/in/swaggo.go | 18 +++++++++++++++ .../swaggo/testdata/fix/out/swaggo.go | 18 +++++++++++++++ pkg/golinters/swaggo/testdata/swaggo.go | 18 +++++++++++++++ pkg/golinters/swaggo/testdata/swaggo.yml | 5 ++++ pkg/lint/lintersdb/builder_linter.go | 6 +++++ pkg/result/processors/fixer.go | 3 ++- .../processors/max_per_file_from_linter.go | 3 ++- 17 files changed, 148 insertions(+), 5 deletions(-) create mode 100644 pkg/goformatters/swaggo/swaggo.go create mode 100644 pkg/golinters/swaggo/swaggo.go create mode 100644 pkg/golinters/swaggo/swaggo_integration_test.go create mode 100644 pkg/golinters/swaggo/testdata/fix/in/swaggo.go create mode 100644 pkg/golinters/swaggo/testdata/fix/out/swaggo.go create mode 100644 pkg/golinters/swaggo/testdata/swaggo.go create mode 100644 pkg/golinters/swaggo/testdata/swaggo.yml diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 32b46fe168b1..ea714629b2d0 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -10,6 +10,7 @@ updates: # Ignore forked linters because of their versioning issues. - dependency-name: "github.com/golangci/dupl" - dependency-name: "github.com/golangci/gofmt" + - dependency-name: "github.com/golangci/swaggoswag" - dependency-name: "github.com/golangci/unconvert" - package-ecosystem: github-actions directory: "/" diff --git a/.golangci.next.reference.yml b/.golangci.next.reference.yml index 6a33e30e33d7..7f6798f02abd 100644 --- a/.golangci.next.reference.yml +++ b/.golangci.next.reference.yml @@ -3975,6 +3975,7 @@ formatters: - gofumpt - goimports - golines + - swaggo # Formatters settings. settings: diff --git a/go.mod b/go.mod index 3f294565b54e..3ae5aac563ca 100644 --- a/go.mod +++ b/go.mod @@ -51,6 +51,7 @@ require ( github.com/golangci/misspell v0.6.0 github.com/golangci/plugin-module-register v0.1.1 github.com/golangci/revgrep v0.8.0 + github.com/golangci/swaggoswag v0.0.0-20250504205917-77f2aca3143e github.com/golangci/unconvert v0.0.0-20250410112200-a129a6e6413e github.com/gordonklaus/ineffassign v0.1.0 github.com/gostaticanalysis/forcetypeassert v0.2.0 diff --git a/go.sum b/go.sum index a522b52fb450..414fb890e851 100644 --- a/go.sum +++ b/go.sum @@ -263,6 +263,8 @@ github.com/golangci/plugin-module-register v0.1.1 h1:TCmesur25LnyJkpsVrupv1Cdzo+ github.com/golangci/plugin-module-register v0.1.1/go.mod h1:TTpqoB6KkwOJMV8u7+NyXMrkwwESJLOkfl9TxR1DGFc= github.com/golangci/revgrep v0.8.0 h1:EZBctwbVd0aMeRnNUsFogoyayvKHyxlV3CdUA46FX2s= github.com/golangci/revgrep v0.8.0/go.mod h1:U4R/s9dlXZsg8uJmaR1GrloUr14D7qDl8gi2iPXJH8k= +github.com/golangci/swaggoswag v0.0.0-20250504205917-77f2aca3143e h1:ai0EfmVYE2bRA5htgAG9r7s3tHsfjIhN98WshBTJ9jM= +github.com/golangci/swaggoswag v0.0.0-20250504205917-77f2aca3143e/go.mod h1:Vrn4B5oR9qRwM+f54koyeH3yzphlecwERs0el27Fr/s= github.com/golangci/unconvert v0.0.0-20250410112200-a129a6e6413e h1:gD6P7NEo7Eqtt0ssnqSJNNndxe69DOQ24A5h7+i3KpM= github.com/golangci/unconvert v0.0.0-20250410112200-a129a6e6413e/go.mod h1:h+wZwLjUTJnm/P2rwlbJdRPZXOzaT36/FwnPnY2inzc= github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= diff --git a/jsonschema/golangci.next.jsonschema.json b/jsonschema/golangci.next.jsonschema.json index 5868d65451b2..5aeaf040c2ff 100644 --- a/jsonschema/golangci.next.jsonschema.json +++ b/jsonschema/golangci.next.jsonschema.json @@ -837,7 +837,8 @@ "gofmt", "gofumpt", "goimports", - "golines" + "golines", + "swaggo" ] }, "settings": { diff --git a/pkg/config/linters.go b/pkg/config/linters.go index 590d9448a197..2669f2e64778 100644 --- a/pkg/config/linters.go +++ b/pkg/config/linters.go @@ -49,5 +49,5 @@ func (l *Linters) validateNoFormatters() error { } func getAllFormatterNames() []string { - return []string{"gci", "gofmt", "gofumpt", "goimports", "golines"} + return []string{"gci", "gofmt", "gofumpt", "goimports", "golines", "swaggo"} } diff --git a/pkg/goformatters/meta_formatter.go b/pkg/goformatters/meta_formatter.go index 718caaa96003..dbedcd4cba19 100644 --- a/pkg/goformatters/meta_formatter.go +++ b/pkg/goformatters/meta_formatter.go @@ -12,6 +12,7 @@ import ( "github.com/golangci/golangci-lint/v2/pkg/goformatters/gofumpt" "github.com/golangci/golangci-lint/v2/pkg/goformatters/goimports" "github.com/golangci/golangci-lint/v2/pkg/goformatters/golines" + "github.com/golangci/golangci-lint/v2/pkg/goformatters/swaggo" "github.com/golangci/golangci-lint/v2/pkg/logutils" ) @@ -41,6 +42,10 @@ func NewMetaFormatter(log logutils.Log, cfg *config.Formatters, runCfg *config.R m.formatters = append(m.formatters, goimports.New(&cfg.Settings.GoImports)) } + if slices.Contains(cfg.Enable, swaggo.Name) { + m.formatters = append(m.formatters, swaggo.New()) + } + // gci is a last because the only goal of gci is to handle imports. if slices.Contains(cfg.Enable, gci.Name) { formatter, err := gci.New(&cfg.Settings.Gci) @@ -86,5 +91,5 @@ func (m *MetaFormatter) Format(filename string, src []byte) []byte { } func IsFormatter(name string) bool { - return slices.Contains([]string{gofmt.Name, gofumpt.Name, goimports.Name, gci.Name, golines.Name}, name) + return slices.Contains([]string{gofmt.Name, gofumpt.Name, goimports.Name, gci.Name, golines.Name, swaggo.Name}, name) } diff --git a/pkg/goformatters/swaggo/swaggo.go b/pkg/goformatters/swaggo/swaggo.go new file mode 100644 index 000000000000..2479fb35baba --- /dev/null +++ b/pkg/goformatters/swaggo/swaggo.go @@ -0,0 +1,23 @@ +package swaggo + +import "github.com/golangci/swaggoswag" + +const Name = "swaggo" + +type Formatter struct { + formatter *swaggoswag.Formatter +} + +func New() *Formatter { + return &Formatter{ + formatter: swaggoswag.NewFormatter(), + } +} + +func (*Formatter) Name() string { + return Name +} + +func (f *Formatter) Format(path string, src []byte) ([]byte, error) { + return f.formatter.Format(path, src) +} diff --git a/pkg/golinters/swaggo/swaggo.go b/pkg/golinters/swaggo/swaggo.go new file mode 100644 index 000000000000..8c4eec8e448d --- /dev/null +++ b/pkg/golinters/swaggo/swaggo.go @@ -0,0 +1,23 @@ +package swaggo + +import ( + "golang.org/x/tools/go/analysis" + + "github.com/golangci/golangci-lint/v2/pkg/goanalysis" + "github.com/golangci/golangci-lint/v2/pkg/goformatters" + "github.com/golangci/golangci-lint/v2/pkg/goformatters/swaggo" + "github.com/golangci/golangci-lint/v2/pkg/golinters/internal" +) + +const linterName = "swaggo" + +func New() *goanalysis.Linter { + a := goformatters.NewAnalyzer( + internal.LinterLogger.Child(linterName), + "Check if swaggo comments are formatted", + swaggo.New(), + ) + + return goanalysis.NewLinter(a.Name, a.Doc, []*analysis.Analyzer{a}, nil). + WithLoadMode(goanalysis.LoadModeSyntax) +} diff --git a/pkg/golinters/swaggo/swaggo_integration_test.go b/pkg/golinters/swaggo/swaggo_integration_test.go new file mode 100644 index 000000000000..23fd3f1ff788 --- /dev/null +++ b/pkg/golinters/swaggo/swaggo_integration_test.go @@ -0,0 +1,19 @@ +package swaggo + +import ( + "testing" + + "github.com/golangci/golangci-lint/v2/test/testshared/integration" +) + +func TestFromTestdata(t *testing.T) { + integration.RunTestdata(t) +} + +func TestFix(t *testing.T) { + integration.RunFix(t) +} + +func TestFixPathPrefix(t *testing.T) { + integration.RunFixPathPrefix(t) +} diff --git a/pkg/golinters/swaggo/testdata/fix/in/swaggo.go b/pkg/golinters/swaggo/testdata/fix/in/swaggo.go new file mode 100644 index 000000000000..33c814b2805b --- /dev/null +++ b/pkg/golinters/swaggo/testdata/fix/in/swaggo.go @@ -0,0 +1,18 @@ +//golangcitest:config_path testdata/swaggo.yml +//golangcitest:expected_exitcode 0 +package api + +import "net/http" + +// @Summary Add a new pet to the store +// @Description get string by ID +// @ID get-string-by-int +// @Accept json +// @Produce json +// @Param some_id path int true "Some ID" Format(int64) +// @Param some_id body web.Pet true "Some ID" +// @Success 200 {string} string "ok" +// @Failure 400 {object} web.APIError "We need ID!!" +// @Failure 404 {object} web.APIError "Can not find ID" +// @Router /testapi/get-string-by-int/{some_id} [get] +func GetStringByInt(w http.ResponseWriter, r *http.Request) {} diff --git a/pkg/golinters/swaggo/testdata/fix/out/swaggo.go b/pkg/golinters/swaggo/testdata/fix/out/swaggo.go new file mode 100644 index 000000000000..8c4d2a2cdd40 --- /dev/null +++ b/pkg/golinters/swaggo/testdata/fix/out/swaggo.go @@ -0,0 +1,18 @@ +//golangcitest:config_path testdata/swaggo.yml +//golangcitest:expected_exitcode 0 +package api + +import "net/http" + +// @Summary Add a new pet to the store +// @Description get string by ID +// @ID get-string-by-int +// @Accept json +// @Produce json +// @Param some_id path int true "Some ID" Format(int64) +// @Param some_id body web.Pet true "Some ID" +// @Success 200 {string} string "ok" +// @Failure 400 {object} web.APIError "We need ID!!" +// @Failure 404 {object} web.APIError "Can not find ID" +// @Router /testapi/get-string-by-int/{some_id} [get] +func GetStringByInt(w http.ResponseWriter, r *http.Request) {} diff --git a/pkg/golinters/swaggo/testdata/swaggo.go b/pkg/golinters/swaggo/testdata/swaggo.go new file mode 100644 index 000000000000..db6b7da9dcfc --- /dev/null +++ b/pkg/golinters/swaggo/testdata/swaggo.go @@ -0,0 +1,18 @@ +//golangcitest:config_path testdata/swaggo.yml +package api + +import "net/http" + +// want +1 "File is not properly formatted" +// @Summary Add a new pet to the store +// @Description get string by ID +// @ID get-string-by-int +// @Accept json +// @Produce json +// @Param some_id path int true "Some ID" Format(int64) +// @Param some_id body web.Pet true "Some ID" +// @Success 200 {string} string "ok" +// @Failure 400 {object} web.APIError "We need ID!!" +// @Failure 404 {object} web.APIError "Can not find ID" +// @Router /testapi/get-string-by-int/{some_id} [get] +func GetStringByInt(w http.ResponseWriter, r *http.Request) {} diff --git a/pkg/golinters/swaggo/testdata/swaggo.yml b/pkg/golinters/swaggo/testdata/swaggo.yml new file mode 100644 index 000000000000..458e2fca7eeb --- /dev/null +++ b/pkg/golinters/swaggo/testdata/swaggo.yml @@ -0,0 +1,5 @@ +version: "2" + +formatters: + enable: + - swaggo diff --git a/pkg/lint/lintersdb/builder_linter.go b/pkg/lint/lintersdb/builder_linter.go index 5ac3e5ba2fb0..93ff1d35a5ff 100644 --- a/pkg/lint/lintersdb/builder_linter.go +++ b/pkg/lint/lintersdb/builder_linter.go @@ -94,6 +94,7 @@ import ( "github.com/golangci/golangci-lint/v2/pkg/golinters/spancheck" "github.com/golangci/golangci-lint/v2/pkg/golinters/sqlclosecheck" "github.com/golangci/golangci-lint/v2/pkg/golinters/staticcheck" + "github.com/golangci/golangci-lint/v2/pkg/golinters/swaggo" "github.com/golangci/golangci-lint/v2/pkg/golinters/tagalign" "github.com/golangci/golangci-lint/v2/pkg/golinters/tagliatelle" "github.com/golangci/golangci-lint/v2/pkg/golinters/testableexamples" @@ -581,6 +582,11 @@ func (LinterBuilder) Build(cfg *config.Config) ([]*linter.Config, error) { WithAutoFix(). WithURL("https://staticcheck.dev/"), + linter.NewConfig(swaggo.New()). + WithSince("v2.2.0"). + WithAutoFix(). + WithURL("https://github.com/swaggo/swaggo"), + linter.NewConfig(tagalign.New(&cfg.Linters.Settings.TagAlign)). WithSince("v1.53.0"). WithAutoFix(). diff --git a/pkg/result/processors/fixer.go b/pkg/result/processors/fixer.go index 14dd3454eab6..d2beaa0ebafe 100644 --- a/pkg/result/processors/fixer.go +++ b/pkg/result/processors/fixer.go @@ -22,6 +22,7 @@ import ( "github.com/golangci/golangci-lint/v2/pkg/goformatters/gofumpt" "github.com/golangci/golangci-lint/v2/pkg/goformatters/goimports" "github.com/golangci/golangci-lint/v2/pkg/goformatters/golines" + "github.com/golangci/golangci-lint/v2/pkg/goformatters/swaggo" "github.com/golangci/golangci-lint/v2/pkg/logutils" "github.com/golangci/golangci-lint/v2/pkg/result" "github.com/golangci/golangci-lint/v2/pkg/timeutils" @@ -79,7 +80,7 @@ func (p Fixer) process(issues []result.Issue) ([]result.Issue, error) { // filenames / linters / edits editsByLinter := make(map[string]map[string][]diff.Edit) - formatters := []string{gofumpt.Name, goimports.Name, gofmt.Name, gci.Name, golines.Name} + formatters := []string{gofumpt.Name, goimports.Name, gofmt.Name, gci.Name, golines.Name, swaggo.Name} var notFixableIssues []result.Issue diff --git a/pkg/result/processors/max_per_file_from_linter.go b/pkg/result/processors/max_per_file_from_linter.go index fdb6bb0278da..2608c22e22ab 100644 --- a/pkg/result/processors/max_per_file_from_linter.go +++ b/pkg/result/processors/max_per_file_from_linter.go @@ -7,6 +7,7 @@ import ( "github.com/golangci/golangci-lint/v2/pkg/goformatters/gofumpt" "github.com/golangci/golangci-lint/v2/pkg/goformatters/goimports" "github.com/golangci/golangci-lint/v2/pkg/goformatters/golines" + "github.com/golangci/golangci-lint/v2/pkg/goformatters/swaggo" "github.com/golangci/golangci-lint/v2/pkg/result" ) @@ -24,7 +25,7 @@ func NewMaxPerFileFromLinter(cfg *config.Config) *MaxPerFileFromLinter { if !cfg.Issues.NeedFix { // if we don't fix we do this limiting to not annoy user; // otherwise we need to fix all issues in the file at once - for _, f := range []string{gofmt.Name, gofumpt.Name, goimports.Name, gci.Name, golines.Name} { + for _, f := range []string{gofmt.Name, gofumpt.Name, goimports.Name, gci.Name, golines.Name, swaggo.Name} { maxPerFileFromLinterConfig[f] = 1 } } From b24761d3fc9a4414fafe5abb079e13620b90d5cb Mon Sep 17 00:00:00 2001 From: Gabriel Augendre Date: Sun, 11 May 2025 20:10:19 +0200 Subject: [PATCH 53/96] feat: add arangolint linter (#5718) Co-authored-by: Fernandez Ludovic --- .github/dependabot.yml | 1 + .golangci.next.reference.yml | 2 + go.mod | 1 + go.sum | 2 + jsonschema/golangci.next.jsonschema.json | 1 + pkg/golinters/arangolint/arangolint.go | 19 +++++++ .../arangolint/arangolint_integration_test.go | 11 ++++ .../arangolint/testdata/arangolint.go | 35 +++++++++++++ .../arangolint/testdata/arangolint_cgo.go | 52 +++++++++++++++++++ pkg/golinters/arangolint/testdata/go.mod | 19 +++++++ pkg/golinters/arangolint/testdata/go.sum | 46 ++++++++++++++++ pkg/lint/lintersdb/builder_linter.go | 6 +++ 12 files changed, 195 insertions(+) create mode 100644 pkg/golinters/arangolint/arangolint.go create mode 100644 pkg/golinters/arangolint/arangolint_integration_test.go create mode 100644 pkg/golinters/arangolint/testdata/arangolint.go create mode 100644 pkg/golinters/arangolint/testdata/arangolint_cgo.go create mode 100644 pkg/golinters/arangolint/testdata/go.mod create mode 100644 pkg/golinters/arangolint/testdata/go.sum diff --git a/.github/dependabot.yml b/.github/dependabot.yml index ea714629b2d0..1e4618407dd5 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -38,6 +38,7 @@ updates: - "*" # Group all updates into a single larger pull request. - package-ecosystem: gomod directories: + - pkg/golinters/arangolint/testdata/ - pkg/golinters/ginkgolinter/testdata/ - pkg/golinters/loggercheck/testdata/ - pkg/golinters/protogetter/testdata/ diff --git a/.golangci.next.reference.yml b/.golangci.next.reference.yml index 7f6798f02abd..f53ddc68fde9 100644 --- a/.golangci.next.reference.yml +++ b/.golangci.next.reference.yml @@ -17,6 +17,7 @@ linters: # Enable specific linter. # https://golangci-lint.run/usage/linters/#enabled-by-default enable: + - arangolint - asasalint - asciicheck - bidichk @@ -125,6 +126,7 @@ linters: # Disable specific linter. # https://golangci-lint.run/usage/linters/#disabled-by-default disable: + - arangolint - asasalint - asciicheck - bidichk diff --git a/go.mod b/go.mod index 3ae5aac563ca..3a5195744126 100644 --- a/go.mod +++ b/go.mod @@ -127,6 +127,7 @@ require ( gitlab.com/bosi/decorder v0.4.2 go-simpler.org/musttag v0.13.1 go-simpler.org/sloglint v0.11.0 + go.augendre.info/arangolint v0.2.0 go.augendre.info/fatcontext v0.8.0 go.uber.org/automaxprocs v1.6.0 golang.org/x/mod v0.24.0 diff --git a/go.sum b/go.sum index 414fb890e851..5aec366fb13e 100644 --- a/go.sum +++ b/go.sum @@ -629,6 +629,8 @@ go-simpler.org/musttag v0.13.1 h1:lw2sJyu7S1X8lc8zWUAdH42y+afdcCnHhWpnkWvd6vU= go-simpler.org/musttag v0.13.1/go.mod h1:8r450ehpMLQgvpb6sg+hV5Ur47eH6olp/3yEanfG97k= go-simpler.org/sloglint v0.11.0 h1:JlR1X4jkbeaffiyjLtymeqmGDKBDO1ikC6rjiuFAOco= go-simpler.org/sloglint v0.11.0/go.mod h1:CFDO8R1i77dlciGfPEPvYke2ZMx4eyGiEIWkyeW2Pvw= +go.augendre.info/arangolint v0.2.0 h1:2NP/XudpPmfBhQKX4rMk+zDYIj//qbt4hfZmSSTcpj8= +go.augendre.info/arangolint v0.2.0/go.mod h1:Vx4KSJwu48tkE+8uxuf0cbBnAPgnt8O1KWiT7bljq7w= go.augendre.info/fatcontext v0.8.0 h1:2dfk6CQbDGeu1YocF59Za5Pia7ULeAM6friJ3LP7lmk= go.augendre.info/fatcontext v0.8.0/go.mod h1:oVJfMgwngMsHO+KB2MdgzcO+RvtNdiCEOlWvSFtax/s= go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU= diff --git a/jsonschema/golangci.next.jsonschema.json b/jsonschema/golangci.next.jsonschema.json index 5aeaf040c2ff..78960fabeaf1 100644 --- a/jsonschema/golangci.next.jsonschema.json +++ b/jsonschema/golangci.next.jsonschema.json @@ -718,6 +718,7 @@ "anyOf": [ { "enum": [ + "arangolint", "asasalint", "asciicheck", "bidichk", diff --git a/pkg/golinters/arangolint/arangolint.go b/pkg/golinters/arangolint/arangolint.go new file mode 100644 index 000000000000..7a46d93d02a9 --- /dev/null +++ b/pkg/golinters/arangolint/arangolint.go @@ -0,0 +1,19 @@ +package arangolint + +import ( + "go.augendre.info/arangolint/pkg/analyzer" + "golang.org/x/tools/go/analysis" + + "github.com/golangci/golangci-lint/v2/pkg/goanalysis" +) + +func New() *goanalysis.Linter { + a := analyzer.NewAnalyzer() + + return goanalysis.NewLinter( + a.Name, + a.Doc, + []*analysis.Analyzer{a}, + nil, + ).WithLoadMode(goanalysis.LoadModeTypesInfo) +} diff --git a/pkg/golinters/arangolint/arangolint_integration_test.go b/pkg/golinters/arangolint/arangolint_integration_test.go new file mode 100644 index 000000000000..db0f1aef0923 --- /dev/null +++ b/pkg/golinters/arangolint/arangolint_integration_test.go @@ -0,0 +1,11 @@ +package arangolint + +import ( + "testing" + + "github.com/golangci/golangci-lint/v2/test/testshared/integration" +) + +func TestFromTestdata(t *testing.T) { + integration.RunTestdata(t) +} diff --git a/pkg/golinters/arangolint/testdata/arangolint.go b/pkg/golinters/arangolint/testdata/arangolint.go new file mode 100644 index 000000000000..1cc3f28a87c2 --- /dev/null +++ b/pkg/golinters/arangolint/testdata/arangolint.go @@ -0,0 +1,35 @@ +//golangcitest:args -Earangolint +package arangolint + +import ( + "context" + + "github.com/arangodb/go-driver/v2/arangodb" +) + +func _() { + ctx := context.Background() + arangoClient := arangodb.NewClient(nil) + db, _ := arangoClient.GetDatabase(ctx, "name", nil) + + // direct nil + db.BeginTransaction(ctx, arangodb.TransactionCollections{}, nil) // want "missing AllowImplicit option" + trx, _ := db.BeginTransaction(ctx, arangodb.TransactionCollections{}, nil) // want "missing AllowImplicit option" + _ = trx + + // direct missing + db.BeginTransaction(ctx, arangodb.TransactionCollections{}, &arangodb.BeginTransactionOptions{LockTimeout: 0}) // want "missing AllowImplicit option" + trx, _ = db.BeginTransaction(ctx, arangodb.TransactionCollections{}, &arangodb.BeginTransactionOptions{LockTimeout: 0}) // want "missing AllowImplicit option" + + // direct false + db.BeginTransaction(ctx, arangodb.TransactionCollections{}, &arangodb.BeginTransactionOptions{AllowImplicit: false}) + trx, _ = db.BeginTransaction(ctx, arangodb.TransactionCollections{}, &arangodb.BeginTransactionOptions{AllowImplicit: false}) + + // direct true + db.BeginTransaction(ctx, arangodb.TransactionCollections{}, &arangodb.BeginTransactionOptions{AllowImplicit: true}) + trx, _ = db.BeginTransaction(ctx, arangodb.TransactionCollections{}, &arangodb.BeginTransactionOptions{AllowImplicit: true}) + + // direct with other fields + db.BeginTransaction(ctx, arangodb.TransactionCollections{}, &arangodb.BeginTransactionOptions{AllowImplicit: true, LockTimeout: 0}) + trx, _ = db.BeginTransaction(ctx, arangodb.TransactionCollections{}, &arangodb.BeginTransactionOptions{AllowImplicit: true, LockTimeout: 0}) +} diff --git a/pkg/golinters/arangolint/testdata/arangolint_cgo.go b/pkg/golinters/arangolint/testdata/arangolint_cgo.go new file mode 100644 index 000000000000..3bc9bc7fefb8 --- /dev/null +++ b/pkg/golinters/arangolint/testdata/arangolint_cgo.go @@ -0,0 +1,52 @@ +//golangcitest:args -Earangolint +package arangolint + +/* + #include + #include + + void myprint(char* s) { + printf("%d\n", s); + } +*/ +import "C" + +import ( + "context" + "unsafe" + + "github.com/arangodb/go-driver/v2/arangodb" +) + +func _() { + cs := C.CString("Hello from stdio\n") + C.myprint(cs) + C.free(unsafe.Pointer(cs)) +} + +func _() { + ctx := context.Background() + arangoClient := arangodb.NewClient(nil) + db, _ := arangoClient.GetDatabase(ctx, "name", nil) + + // direct nil + db.BeginTransaction(ctx, arangodb.TransactionCollections{}, nil) // want "missing AllowImplicit option" + trx, _ := db.BeginTransaction(ctx, arangodb.TransactionCollections{}, nil) // want "missing AllowImplicit option" + _ = trx + + // direct missing + db.BeginTransaction(ctx, arangodb.TransactionCollections{}, &arangodb.BeginTransactionOptions{LockTimeout: 0}) // want "missing AllowImplicit option" + trx, _ = db.BeginTransaction(ctx, arangodb.TransactionCollections{}, &arangodb.BeginTransactionOptions{LockTimeout: 0}) // want "missing AllowImplicit option" + + // direct false + db.BeginTransaction(ctx, arangodb.TransactionCollections{}, &arangodb.BeginTransactionOptions{AllowImplicit: false}) + trx, _ = db.BeginTransaction(ctx, arangodb.TransactionCollections{}, &arangodb.BeginTransactionOptions{AllowImplicit: false}) + + // direct true + db.BeginTransaction(ctx, arangodb.TransactionCollections{}, &arangodb.BeginTransactionOptions{AllowImplicit: true}) + trx, _ = db.BeginTransaction(ctx, arangodb.TransactionCollections{}, &arangodb.BeginTransactionOptions{AllowImplicit: true}) + + // direct with other fields + db.BeginTransaction(ctx, arangodb.TransactionCollections{}, &arangodb.BeginTransactionOptions{AllowImplicit: true, LockTimeout: 0}) + trx, _ = db.BeginTransaction(ctx, arangodb.TransactionCollections{}, &arangodb.BeginTransactionOptions{AllowImplicit: true, LockTimeout: 0}) +} diff --git a/pkg/golinters/arangolint/testdata/go.mod b/pkg/golinters/arangolint/testdata/go.mod new file mode 100644 index 000000000000..c9d56c70228d --- /dev/null +++ b/pkg/golinters/arangolint/testdata/go.mod @@ -0,0 +1,19 @@ +module arangolint + +go 1.23.0 + +require github.com/arangodb/go-driver/v2 v2.1.3 + +require ( + github.com/arangodb/go-velocypack v0.0.0-20200318135517-5af53c29c67e // indirect + github.com/dchest/siphash v1.2.3 // indirect + github.com/google/uuid v1.6.0 // indirect + github.com/kkdai/maglev v0.2.0 // indirect + github.com/mattn/go-colorable v0.1.13 // indirect + github.com/mattn/go-isatty v0.0.20 // indirect + github.com/pkg/errors v0.9.1 // indirect + github.com/rs/zerolog v1.33.0 // indirect + golang.org/x/net v0.33.0 // indirect + golang.org/x/sys v0.28.0 // indirect + golang.org/x/text v0.21.0 // indirect +) diff --git a/pkg/golinters/arangolint/testdata/go.sum b/pkg/golinters/arangolint/testdata/go.sum new file mode 100644 index 000000000000..9f27a49c38c8 --- /dev/null +++ b/pkg/golinters/arangolint/testdata/go.sum @@ -0,0 +1,46 @@ +github.com/arangodb/go-driver/v2 v2.1.3 h1:PpLSe8E2RalFuqTGi2yfHDe3ltOomfFCIToB66p1lr8= +github.com/arangodb/go-driver/v2 v2.1.3/go.mod h1:aoDzrsO7PQEFat3Q9pp4zfv6W+WotA7GcCeJQJfX+tc= +github.com/arangodb/go-velocypack v0.0.0-20200318135517-5af53c29c67e h1:Xg+hGrY2LcQBbxd0ZFdbGSyRKTYMZCfBbw/pMJFOk1g= +github.com/arangodb/go-velocypack v0.0.0-20200318135517-5af53c29c67e/go.mod h1:mq7Shfa/CaixoDxiyAAc5jZ6CVBAyPaNQCGS7mkj4Ho= +github.com/coreos/go-systemd/v22 v22.5.0/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc= +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/dchest/siphash v1.2.2/go.mod h1:q+IRvb2gOSrUnYoPqHiyHXS0FOBBOdl6tONBlVnOnt4= +github.com/dchest/siphash v1.2.3 h1:QXwFc8cFOR2dSa/gE6o/HokBMWtLUaNDVd+22aKHeEA= +github.com/dchest/siphash v1.2.3/go.mod h1:0NvQU092bT0ipiFN++/rXm69QG9tVxLAlQHIXMPAkHc= +github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= +github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= +github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/kkdai/maglev v0.2.0 h1:w6DCW0kAA6fstZqXkrBrlgIC3jeIRXkjOYea/m6EK/Y= +github.com/kkdai/maglev v0.2.0/go.mod h1:d+mt8Lmt3uqi9aRb/BnPjzD0fy+ETs1vVXiGRnqHVZ4= +github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA= +github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg= +github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= +github.com/mattn/go-isatty v0.0.19/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= +github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= +github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= +github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= +github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/rs/xid v1.5.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg= +github.com/rs/zerolog v1.33.0 h1:1cU2KZkvPxNyfgEmhHAz/1A9Bz+llsdYzklWFzgp0r8= +github.com/rs/zerolog v1.33.0/go.mod h1:/7mN4D5sKwJLZQ2b/znpjC3/GQWY/xaDXUM0kKWRHss= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= +github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= +github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= +golang.org/x/net v0.33.0 h1:74SYHlV8BIgHIFC/LrYkOGIwL19eTYXQ5wc6TBuO36I= +golang.org/x/net v0.33.0/go.mod h1:HXLR5J+9DxmrqMwG9qjGCxZ+zKXxBru04zlTvWlWuN4= +golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.28.0 h1:Fksou7UEQUWlKvIdsqzJmUmCX3cZuD2+P3XyyzwMhlA= +golang.org/x/sys v0.28.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/text v0.21.0 h1:zyQAAkrwaneQ066sspRyJaG9VNi/YJ1NfzcGB3hZ/qo= +golang.org/x/text v0.21.0/go.mod h1:4IBbMaMmOPCJ8SecivzSH54+73PCFmPWxNTLm+vZkEQ= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/pkg/lint/lintersdb/builder_linter.go b/pkg/lint/lintersdb/builder_linter.go index 93ff1d35a5ff..c975549cf6ba 100644 --- a/pkg/lint/lintersdb/builder_linter.go +++ b/pkg/lint/lintersdb/builder_linter.go @@ -3,6 +3,7 @@ package lintersdb import ( "github.com/golangci/golangci-lint/v2/pkg/config" "github.com/golangci/golangci-lint/v2/pkg/golinters" + "github.com/golangci/golangci-lint/v2/pkg/golinters/arangolint" "github.com/golangci/golangci-lint/v2/pkg/golinters/asasalint" "github.com/golangci/golangci-lint/v2/pkg/golinters/asciicheck" "github.com/golangci/golangci-lint/v2/pkg/golinters/bidichk" @@ -136,6 +137,11 @@ func (LinterBuilder) Build(cfg *config.Config) ([]*linter.Config, error) { // The linters are sorted in the alphabetical order (case-insensitive). // When a new linter is added the version in `WithSince(...)` must be the next minor version of golangci-lint. return []*linter.Config{ + linter.NewConfig(arangolint.New()). + WithSince("v2.2.0"). + WithLoadForGoAnalysis(). + WithURL("https://github.com/Crocmagnon/arangolint"), + linter.NewConfig(asasalint.New(&cfg.Linters.Settings.Asasalint)). WithSince("v1.47.0"). WithLoadForGoAnalysis(). From c61f43fdbcf4cff709b84dba0823fa13589b23dd Mon Sep 17 00:00:00 2001 From: Manuel Doncel Martos Date: Tue, 13 May 2025 10:29:41 +0200 Subject: [PATCH 54/96] feat: add embeddedstructfieldcheck linter (#5761) Co-authored-by: Fernandez Ludovic --- .golangci.next.reference.yml | 2 + go.mod | 1 + go.sum | 2 + jsonschema/golangci.next.jsonschema.json | 1 + .../embeddedstructfieldcheck.go | 19 +++++++++ ...beddedstructfieldcheck_integration_test.go | 19 +++++++++ .../embeddedstructfieldcheck_comments.go | 27 +++++++++++++ .../embeddedstructfieldcheck_simple.go | 39 +++++++++++++++++++ .../embeddedstructfieldcheck_special_cases.go | 11 ++++++ .../testdata/fix/in/comments.go | 39 +++++++++++++++++++ .../testdata/fix/in/simple.go | 23 +++++++++++ .../testdata/fix/out/comments.go | 39 +++++++++++++++++++ .../testdata/fix/out/simple.go | 25 ++++++++++++ pkg/lint/lintersdb/builder_linter.go | 5 +++ 14 files changed, 252 insertions(+) create mode 100644 pkg/golinters/embeddedstructfieldcheck/embeddedstructfieldcheck.go create mode 100644 pkg/golinters/embeddedstructfieldcheck/embeddedstructfieldcheck_integration_test.go create mode 100644 pkg/golinters/embeddedstructfieldcheck/testdata/embeddedstructfieldcheck_comments.go create mode 100644 pkg/golinters/embeddedstructfieldcheck/testdata/embeddedstructfieldcheck_simple.go create mode 100644 pkg/golinters/embeddedstructfieldcheck/testdata/embeddedstructfieldcheck_special_cases.go create mode 100644 pkg/golinters/embeddedstructfieldcheck/testdata/fix/in/comments.go create mode 100644 pkg/golinters/embeddedstructfieldcheck/testdata/fix/in/simple.go create mode 100644 pkg/golinters/embeddedstructfieldcheck/testdata/fix/out/comments.go create mode 100644 pkg/golinters/embeddedstructfieldcheck/testdata/fix/out/simple.go diff --git a/.golangci.next.reference.yml b/.golangci.next.reference.yml index f53ddc68fde9..ff015539fabb 100644 --- a/.golangci.next.reference.yml +++ b/.golangci.next.reference.yml @@ -33,6 +33,7 @@ linters: - dupl - dupword - durationcheck + - embeddedstructfieldcheck - err113 - errcheck - errchkjson @@ -142,6 +143,7 @@ linters: - dupl - dupword - durationcheck + - embeddedstructfieldcheck - err113 - errcheck - errchkjson diff --git a/go.mod b/go.mod index 3a5195744126..ca6b23a4880b 100644 --- a/go.mod +++ b/go.mod @@ -74,6 +74,7 @@ require ( github.com/ldez/usetesting v0.4.3 github.com/leonklingele/grouper v1.1.2 github.com/macabu/inamedparam v0.2.0 + github.com/manuelarte/embeddedstructfieldcheck v0.2.1 github.com/manuelarte/funcorder v0.5.0 github.com/maratori/testableexamples v1.0.0 github.com/maratori/testpackage v1.1.1 diff --git a/go.sum b/go.sum index 5aec366fb13e..6c6f2bf9639b 100644 --- a/go.sum +++ b/go.sum @@ -391,6 +391,8 @@ github.com/macabu/inamedparam v0.2.0 h1:VyPYpOc10nkhI2qeNUdh3Zket4fcZjEWe35poddB github.com/macabu/inamedparam v0.2.0/go.mod h1:+Pee9/YfGe5LJ62pYXqB89lJ+0k5bsR8Wgz/C0Zlq3U= github.com/magiconair/properties v1.8.6 h1:5ibWZ6iY0NctNGWo87LalDlEZ6R41TqbbDamhfG/Qzo= github.com/magiconair/properties v1.8.6/go.mod h1:y3VJvCyxH9uVvJTWEGAELF3aiYNyPKd5NZ3oSwXrF60= +github.com/manuelarte/embeddedstructfieldcheck v0.2.1 h1:oKexdVGs8Jy31IzOD/EMKfZmgogFhAaDbHb1o0qmA1Q= +github.com/manuelarte/embeddedstructfieldcheck v0.2.1/go.mod h1:LSo/IQpPfx1dXMcX4ibZCYA7Yy6ayZHIaOGM70+1Wy8= github.com/manuelarte/funcorder v0.5.0 h1:llMuHXXbg7tD0i/LNw8vGnkDTHFpTnWqKPI85Rknc+8= github.com/manuelarte/funcorder v0.5.0/go.mod h1:Yt3CiUQthSBMBxjShjdXMexmzpP8YGvGLjrxJNkO2hA= github.com/maratori/testableexamples v1.0.0 h1:dU5alXRrD8WKSjOUnmJZuzdxWOEQ57+7s93SLMxb2vI= diff --git a/jsonschema/golangci.next.jsonschema.json b/jsonschema/golangci.next.jsonschema.json index 78960fabeaf1..9da8ac328072 100644 --- a/jsonschema/golangci.next.jsonschema.json +++ b/jsonschema/golangci.next.jsonschema.json @@ -734,6 +734,7 @@ "dupl", "dupword", "durationcheck", + "embeddedstructfieldcheck", "errcheck", "errchkjson", "errname", diff --git a/pkg/golinters/embeddedstructfieldcheck/embeddedstructfieldcheck.go b/pkg/golinters/embeddedstructfieldcheck/embeddedstructfieldcheck.go new file mode 100644 index 000000000000..781bcf5d201e --- /dev/null +++ b/pkg/golinters/embeddedstructfieldcheck/embeddedstructfieldcheck.go @@ -0,0 +1,19 @@ +package embeddedstructfieldcheck + +import ( + "github.com/manuelarte/embeddedstructfieldcheck/analyzer" + "golang.org/x/tools/go/analysis" + + "github.com/golangci/golangci-lint/v2/pkg/goanalysis" +) + +func New() *goanalysis.Linter { + a := analyzer.NewAnalyzer() + + return goanalysis.NewLinter( + a.Name, + a.Doc, + []*analysis.Analyzer{a}, + nil, + ).WithLoadMode(goanalysis.LoadModeSyntax) +} diff --git a/pkg/golinters/embeddedstructfieldcheck/embeddedstructfieldcheck_integration_test.go b/pkg/golinters/embeddedstructfieldcheck/embeddedstructfieldcheck_integration_test.go new file mode 100644 index 000000000000..ba4258467733 --- /dev/null +++ b/pkg/golinters/embeddedstructfieldcheck/embeddedstructfieldcheck_integration_test.go @@ -0,0 +1,19 @@ +package embeddedstructfieldcheck + +import ( + "testing" + + "github.com/golangci/golangci-lint/v2/test/testshared/integration" +) + +func TestFromTestdata(t *testing.T) { + integration.RunTestdata(t) +} + +func TestFix(t *testing.T) { + integration.RunFix(t) +} + +func TestFixPathPrefix(t *testing.T) { + integration.RunFixPathPrefix(t) +} diff --git a/pkg/golinters/embeddedstructfieldcheck/testdata/embeddedstructfieldcheck_comments.go b/pkg/golinters/embeddedstructfieldcheck/testdata/embeddedstructfieldcheck_comments.go new file mode 100644 index 000000000000..12a6a4fa1ddf --- /dev/null +++ b/pkg/golinters/embeddedstructfieldcheck/testdata/embeddedstructfieldcheck_comments.go @@ -0,0 +1,27 @@ +//golangcitest:args -Eembeddedstructfieldcheck +package simple + +import "time" + +type ValidStructWithSingleLineComments struct { + // time.Time Single line comment + time.Time + + // version Single line comment + version int +} + +type StructWithSingleLineComments struct { + // time.Time Single line comment + time.Time // want `there must be an empty line separating embedded fields from regular fields` + // version Single line comment + version int +} + +type StructWithMultiLineComments struct { + // time.Time Single line comment + time.Time // want `there must be an empty line separating embedded fields from regular fields` + // version Single line comment + // very long comment + version int +} diff --git a/pkg/golinters/embeddedstructfieldcheck/testdata/embeddedstructfieldcheck_simple.go b/pkg/golinters/embeddedstructfieldcheck/testdata/embeddedstructfieldcheck_simple.go new file mode 100644 index 000000000000..47b155e5f52a --- /dev/null +++ b/pkg/golinters/embeddedstructfieldcheck/testdata/embeddedstructfieldcheck_simple.go @@ -0,0 +1,39 @@ +//golangcitest:args -Eembeddedstructfieldcheck +package simple + +import ( + "context" + "time" +) + +type ValidStruct struct { + time.Time + + version int +} + +type NoSpaceStruct struct { + time.Time // want `there must be an empty line separating embedded fields from regular fields` + version int +} + +type NotSortedStruct struct { + version int + + time.Time // want `embedded fields should be listed before regular fields` +} + +type MixedEmbeddedAndNotEmbedded struct { + context.Context + + name string + + time.Time // want `embedded fields should be listed before regular fields` + + age int +} + +type EmbeddedWithPointers struct { + *time.Time // want `there must be an empty line separating embedded fields from regular fields` + version int +} diff --git a/pkg/golinters/embeddedstructfieldcheck/testdata/embeddedstructfieldcheck_special_cases.go b/pkg/golinters/embeddedstructfieldcheck/testdata/embeddedstructfieldcheck_special_cases.go new file mode 100644 index 000000000000..95b5356b5824 --- /dev/null +++ b/pkg/golinters/embeddedstructfieldcheck/testdata/embeddedstructfieldcheck_special_cases.go @@ -0,0 +1,11 @@ +//golangcitest:args -Eembeddedstructfieldcheck +package simple + +import "time" + +func myFunction() { + type myType struct { + version int + time.Time // want `embedded fields should be listed before regular fields` + } +} diff --git a/pkg/golinters/embeddedstructfieldcheck/testdata/fix/in/comments.go b/pkg/golinters/embeddedstructfieldcheck/testdata/fix/in/comments.go new file mode 100644 index 000000000000..5cd45dc171b7 --- /dev/null +++ b/pkg/golinters/embeddedstructfieldcheck/testdata/fix/in/comments.go @@ -0,0 +1,39 @@ +//golangcitest:args -Eembeddedstructfieldcheck +//golangcitest:expected_exitcode 0 +package testdata + +import "time" + +type ValidStructWithSingleLineComments struct { + // time.Time Single line comment + time.Time + + // version Single line comment + version int +} + +type StructWithSingleLineComments struct { + // time.Time Single line comment + time.Time // want `there must be an empty line separating embedded fields from regular fields` + + // version Single line comment + version int +} + +type StructWithMultiLineComments struct { + // time.Time Single line comment + time.Time // want `there must be an empty line separating embedded fields from regular fields` + + // version Single line comment + // very long comment + version int +} + +type A struct { + // comment + ValidStructWithSingleLineComments + // C is foo + StructWithSingleLineComments // want `there must be an empty line separating embedded fields from regular fields` + + D string +} diff --git a/pkg/golinters/embeddedstructfieldcheck/testdata/fix/in/simple.go b/pkg/golinters/embeddedstructfieldcheck/testdata/fix/in/simple.go new file mode 100644 index 000000000000..578ddc0d170e --- /dev/null +++ b/pkg/golinters/embeddedstructfieldcheck/testdata/fix/in/simple.go @@ -0,0 +1,23 @@ +//golangcitest:args -Eembeddedstructfieldcheck +//golangcitest:expected_exitcode 0 +package testdata + +import ( + "time" +) + +type ValidStruct struct { + time.Time + + version int +} + +type NoSpaceStruct struct { + time.Time // want `there must be an empty line separating embedded fields from regular fields` + version int +} + +type EmbeddedWithPointers struct { + *time.Time // want `there must be an empty line separating embedded fields from regular fields` + version int +} diff --git a/pkg/golinters/embeddedstructfieldcheck/testdata/fix/out/comments.go b/pkg/golinters/embeddedstructfieldcheck/testdata/fix/out/comments.go new file mode 100644 index 000000000000..5cd45dc171b7 --- /dev/null +++ b/pkg/golinters/embeddedstructfieldcheck/testdata/fix/out/comments.go @@ -0,0 +1,39 @@ +//golangcitest:args -Eembeddedstructfieldcheck +//golangcitest:expected_exitcode 0 +package testdata + +import "time" + +type ValidStructWithSingleLineComments struct { + // time.Time Single line comment + time.Time + + // version Single line comment + version int +} + +type StructWithSingleLineComments struct { + // time.Time Single line comment + time.Time // want `there must be an empty line separating embedded fields from regular fields` + + // version Single line comment + version int +} + +type StructWithMultiLineComments struct { + // time.Time Single line comment + time.Time // want `there must be an empty line separating embedded fields from regular fields` + + // version Single line comment + // very long comment + version int +} + +type A struct { + // comment + ValidStructWithSingleLineComments + // C is foo + StructWithSingleLineComments // want `there must be an empty line separating embedded fields from regular fields` + + D string +} diff --git a/pkg/golinters/embeddedstructfieldcheck/testdata/fix/out/simple.go b/pkg/golinters/embeddedstructfieldcheck/testdata/fix/out/simple.go new file mode 100644 index 000000000000..a35f19ff4a15 --- /dev/null +++ b/pkg/golinters/embeddedstructfieldcheck/testdata/fix/out/simple.go @@ -0,0 +1,25 @@ +//golangcitest:args -Eembeddedstructfieldcheck +//golangcitest:expected_exitcode 0 +package testdata + +import ( + "time" +) + +type ValidStruct struct { + time.Time + + version int +} + +type NoSpaceStruct struct { + time.Time // want `there must be an empty line separating embedded fields from regular fields` + + version int +} + +type EmbeddedWithPointers struct { + *time.Time // want `there must be an empty line separating embedded fields from regular fields` + + version int +} diff --git a/pkg/lint/lintersdb/builder_linter.go b/pkg/lint/lintersdb/builder_linter.go index c975549cf6ba..37f18bdc9eae 100644 --- a/pkg/lint/lintersdb/builder_linter.go +++ b/pkg/lint/lintersdb/builder_linter.go @@ -19,6 +19,7 @@ import ( "github.com/golangci/golangci-lint/v2/pkg/golinters/dupl" "github.com/golangci/golangci-lint/v2/pkg/golinters/dupword" "github.com/golangci/golangci-lint/v2/pkg/golinters/durationcheck" + "github.com/golangci/golangci-lint/v2/pkg/golinters/embeddedstructfieldcheck" "github.com/golangci/golangci-lint/v2/pkg/golinters/err113" "github.com/golangci/golangci-lint/v2/pkg/golinters/errcheck" "github.com/golangci/golangci-lint/v2/pkg/golinters/errchkjson" @@ -212,6 +213,10 @@ func (LinterBuilder) Build(cfg *config.Config) ([]*linter.Config, error) { WithLoadForGoAnalysis(). WithURL("https://github.com/charithe/durationcheck"), + linter.NewConfig(embeddedstructfieldcheck.New()). + WithSince("v2.2.0"). + WithURL("https://github.com/manuelarte/embeddedstructfieldcheck"), + linter.NewConfig(errcheck.New(&cfg.Linters.Settings.Errcheck)). WithGroups(config.GroupStandard). WithSince("v1.0.0"). From 8c225c34db818afc0b424a41d69b7896fe0baf32 Mon Sep 17 00:00:00 2001 From: Ludovic Fernandez Date: Tue, 13 May 2025 17:34:00 +0200 Subject: [PATCH 55/96] fix: exclusions path-expect (#5798) --- pkg/result/processors/exclusion_paths.go | 2 +- pkg/result/processors/exclusion_paths_test.go | 41 ++++++++++++++----- 2 files changed, 32 insertions(+), 11 deletions(-) diff --git a/pkg/result/processors/exclusion_paths.go b/pkg/result/processors/exclusion_paths.go index 104c33eefa5b..90c5f522f8bd 100644 --- a/pkg/result/processors/exclusion_paths.go +++ b/pkg/result/processors/exclusion_paths.go @@ -114,5 +114,5 @@ func (p *ExclusionPaths) shouldPassIssue(issue *result.Issue) bool { matched = true } - return !matched + return matched } diff --git a/pkg/result/processors/exclusion_paths_test.go b/pkg/result/processors/exclusion_paths_test.go index 44e17d207d38..deac410ab366 100644 --- a/pkg/result/processors/exclusion_paths_test.go +++ b/pkg/result/processors/exclusion_paths_test.go @@ -128,9 +128,9 @@ func TestExclusionPaths_Process(t *testing.T) { {RelativePath: filepath.FromSlash("base/d/file.go")}, }, expected: []result.Issue{ - {RelativePath: filepath.FromSlash("base/a/file.go")}, - {RelativePath: filepath.FromSlash("base/b/file.go")}, - {RelativePath: filepath.FromSlash("base/d/file.go")}, + {RelativePath: filepath.FromSlash("base/c/file.go")}, + {RelativePath: filepath.FromSlash("base/c/a/file.go")}, + {RelativePath: filepath.FromSlash("base/c/b/file.go")}, }, }, { @@ -151,9 +151,9 @@ func TestExclusionPaths_Process(t *testing.T) { {RelativePath: filepath.FromSlash("base/d/file.go")}, }, expected: []result.Issue{ - {RelativePath: filepath.FromSlash("base/a/file.go")}, - {RelativePath: filepath.FromSlash("base/b/file.go")}, - {RelativePath: filepath.FromSlash("base/d/file.go")}, + {RelativePath: filepath.FromSlash("base/c/file.go")}, + {RelativePath: filepath.FromSlash("base/c/a/file.go")}, + {RelativePath: filepath.FromSlash("base/c/b/file.go")}, }, }, { @@ -174,13 +174,14 @@ func TestExclusionPaths_Process(t *testing.T) { {RelativePath: filepath.FromSlash("base/e/file.go")}, }, expected: []result.Issue{ - {RelativePath: filepath.FromSlash("base/a/file.go")}, - {RelativePath: filepath.FromSlash("base/b/file.go")}, - {RelativePath: filepath.FromSlash("base/d/file.go")}, + {RelativePath: filepath.FromSlash("base/c/file.go")}, + {RelativePath: filepath.FromSlash("base/c/a/file.go")}, + {RelativePath: filepath.FromSlash("base/c/b/file.go")}, + {RelativePath: filepath.FromSlash("base/e/file.go")}, }, }, { - desc: "pathsExcept and paths", + desc: "pathsExcept and paths (disjoint)", cfg: &config.LinterExclusions{ Paths: []string{"^base/b/"}, PathsExcept: []string{`^base/c/.*$`}, @@ -194,9 +195,29 @@ func TestExclusionPaths_Process(t *testing.T) { {RelativePath: filepath.FromSlash("base/d/file.go")}, }, expected: []result.Issue{ + {RelativePath: filepath.FromSlash("base/c/file.go")}, + {RelativePath: filepath.FromSlash("base/c/a/file.go")}, + {RelativePath: filepath.FromSlash("base/c/b/file.go")}, + }, + }, + { + desc: "pathsExcept and paths (intersection)", + cfg: &config.LinterExclusions{ + Paths: []string{"^base/c/a/"}, + PathsExcept: []string{`^base/c/.*$`}, + }, + issues: []result.Issue{ {RelativePath: filepath.FromSlash("base/a/file.go")}, + {RelativePath: filepath.FromSlash("base/b/file.go")}, + {RelativePath: filepath.FromSlash("base/c/file.go")}, + {RelativePath: filepath.FromSlash("base/c/a/file.go")}, + {RelativePath: filepath.FromSlash("base/c/b/file.go")}, {RelativePath: filepath.FromSlash("base/d/file.go")}, }, + expected: []result.Issue{ + {RelativePath: filepath.FromSlash("base/c/file.go")}, + {RelativePath: filepath.FromSlash("base/c/b/file.go")}, + }, }, } From aec176a6a2827c993b59f601fc42c44bcaeda61e Mon Sep 17 00:00:00 2001 From: Ludovic Fernandez Date: Tue, 13 May 2025 22:40:48 +0200 Subject: [PATCH 56/96] dev: simplify linter constructors (#5796) --- pkg/goanalysis/linter.go | 27 ++++-- pkg/golinters/arangolint/arangolint.go | 12 +-- pkg/golinters/asasalint/asasalint.go | 12 +-- pkg/golinters/asciicheck/asciicheck.go | 12 +-- pkg/golinters/bidichk/bidichk.go | 16 ++-- pkg/golinters/bodyclose/bodyclose.go | 12 +-- .../canonicalheader/canonicalheader.go | 12 +-- pkg/golinters/containedctx/containedctx.go | 12 +-- pkg/golinters/contextcheck/contextcheck.go | 15 ++-- pkg/golinters/copyloopvar/copyloopvar.go | 20 ++--- pkg/golinters/cyclop/cyclop.go | 26 ++---- pkg/golinters/decorder/decorder.go | 13 +-- pkg/golinters/depguard/depguard.go | 25 +++--- pkg/golinters/dogsled/dogsled.go | 27 +++--- pkg/golinters/dupl/dupl.go | 52 +++++------ pkg/golinters/dupword/dupword.go | 17 ++-- pkg/golinters/durationcheck/durationcheck.go | 12 +-- .../embeddedstructfieldcheck.go | 12 +-- pkg/golinters/err113/err113.go | 13 +-- pkg/golinters/errcheck/errcheck.go | 47 +++++----- pkg/golinters/errchkjson/errchkjson.go | 19 ++-- pkg/golinters/errname/errname.go | 12 +-- pkg/golinters/errorlint/errorlint.go | 19 ++-- pkg/golinters/exhaustive/exhaustive.go | 38 ++++---- pkg/golinters/exhaustruct/exhaustruct.go | 15 ++-- pkg/golinters/exptostd/exptostd.go | 12 +-- pkg/golinters/fatcontext/fatcontext.go | 17 ++-- pkg/golinters/forbidigo/forbidigo.go | 35 ++++---- .../forcetypeassert/forcetypeassert.go | 13 +-- pkg/golinters/funcorder/funcorder.go | 17 ++-- pkg/golinters/funlen/funlen.go | 12 +-- pkg/golinters/gci/gci.go | 23 ++--- pkg/golinters/ginkgolinter/ginkgolinter.go | 13 +-- .../gocheckcompilerdirectives.go | 12 +-- .../gochecknoglobals/gochecknoglobals.go | 13 +-- .../gochecknoinits/gochecknoinits.go | 23 ++--- .../gochecksumtype/gochecksumtype.go | 50 +++++------ pkg/golinters/gocognit/gocognit.go | 42 ++++----- pkg/golinters/goconst/goconst.go | 50 +++++------ pkg/golinters/gocritic/gocritic.go | 32 +++---- pkg/golinters/gocyclo/gocyclo.go | 42 ++++----- pkg/golinters/godot/godot.go | 35 +++----- pkg/golinters/godox/godox.go | 25 ++---- pkg/golinters/gofmt/gofmt.go | 25 ++---- pkg/golinters/gofumpt/gofumpt.go | 25 ++---- pkg/golinters/goheader/goheader.go | 33 +++---- pkg/golinters/goimports/goimports.go | 25 ++---- pkg/golinters/golines/golines.go | 25 ++---- .../gomoddirectives/gomoddirectives.go | 57 ++++++------ pkg/golinters/gomodguard/gomodguard.go | 69 +++++++-------- .../goprintffuncname/goprintffuncname.go | 12 +-- pkg/golinters/gosec/gosec.go | 41 +++++---- pkg/golinters/gosmopolitan/gosmopolitan.go | 16 ++-- pkg/golinters/grouper/grouper.go | 18 ++-- pkg/golinters/importas/importas.go | 87 +++++++++---------- pkg/golinters/inamedparam/inamedparam.go | 21 ++--- pkg/golinters/ineffassign/ineffassign.go | 13 +-- .../interfacebloat/interfacebloat.go | 20 ++--- pkg/golinters/intrange/intrange.go | 12 +-- pkg/golinters/ireturn/ireturn.go | 16 ++-- pkg/golinters/lll/lll.go | 35 +++----- pkg/golinters/loggercheck/loggercheck.go | 11 +-- pkg/golinters/maintidx/maintidx.go | 21 ++--- pkg/golinters/makezero/makezero.go | 35 +++----- pkg/golinters/mirror/mirror.go | 19 ++-- pkg/golinters/misspell/misspell.go | 33 +++---- pkg/golinters/mnd/mnd.go | 20 ++--- pkg/golinters/musttag/musttag.go | 5 +- pkg/golinters/nakedret/nakedret.go | 12 +-- pkg/golinters/nestif/nestif.go | 29 +++---- pkg/golinters/nilerr/nilerr.go | 13 +-- pkg/golinters/nilnesserr/nilnesserr.go | 12 +-- pkg/golinters/nilnil/nilnil.go | 19 ++-- pkg/golinters/nlreturn/nlreturn.go | 18 ++-- pkg/golinters/noctx/noctx.go | 13 +-- pkg/golinters/nolintlint/nolintlint.go | 50 +++++------ .../nonamedreturns/nonamedreturns.go | 20 ++--- .../nosprintfhostport/nosprintfhostport.go | 12 +-- pkg/golinters/paralleltest/paralleltest.go | 21 ++--- pkg/golinters/perfsprint/perfsprint.go | 37 ++++---- pkg/golinters/prealloc/prealloc.go | 29 +++---- pkg/golinters/predeclared/predeclared.go | 16 ++-- pkg/golinters/promlinter/promlinter.go | 42 ++++----- pkg/golinters/protogetter/protogetter.go | 13 +-- pkg/golinters/reassign/reassign.go | 20 ++--- pkg/golinters/recvcheck/recvcheck.go | 12 +-- pkg/golinters/revive/revive.go | 55 ++++++------ pkg/golinters/rowserrcheck/rowserrcheck.go | 14 ++- pkg/golinters/sloglint/sloglint.go | 6 +- pkg/golinters/spancheck/spancheck.go | 5 +- pkg/golinters/sqlclosecheck/sqlclosecheck.go | 12 +-- pkg/golinters/swaggo/swaggo.go | 19 ++-- pkg/golinters/tagalign/tagalign.go | 12 +-- pkg/golinters/tagliatelle/tagliatelle.go | 12 +-- .../testableexamples/testableexamples.go | 12 +-- pkg/golinters/testifylint/testifylint.go | 28 +++--- pkg/golinters/testpackage/testpackage.go | 16 ++-- pkg/golinters/thelper/thelper.go | 19 ++-- pkg/golinters/tparallel/tparallel.go | 11 +-- pkg/golinters/typecheck.go | 21 ++--- pkg/golinters/unconvert/unconvert.go | 42 ++++----- pkg/golinters/unparam/unparam.go | 37 ++++---- pkg/golinters/usestdlibvars/usestdlibvars.go | 16 ++-- pkg/golinters/usetesting/usetesting.go | 16 ++-- pkg/golinters/varnamelen/varnamelen.go | 18 ++-- pkg/golinters/wastedassign/wastedassign.go | 13 +-- pkg/golinters/whitespace/whitespace.go | 12 +-- pkg/golinters/wrapcheck/wrapcheck.go | 12 +-- pkg/golinters/wsl/wsl.go | 13 +-- pkg/golinters/zerologlint/zerologlint.go | 12 +-- 110 files changed, 970 insertions(+), 1508 deletions(-) diff --git a/pkg/goanalysis/linter.go b/pkg/goanalysis/linter.go index 80ccfe456408..53f5b7bae455 100644 --- a/pkg/goanalysis/linter.go +++ b/pkg/goanalysis/linter.go @@ -13,11 +13,6 @@ import ( "github.com/golangci/golangci-lint/v2/pkg/result" ) -const ( - TheOnlyAnalyzerName = "the_only_name" - TheOnlyanalyzerDoc = "the_only_doc" -) - type LoadMode int func (loadMode LoadMode) String() string { @@ -55,6 +50,10 @@ func NewLinter(name, desc string, analyzers []*analysis.Analyzer, cfg map[string return &Linter{name: name, desc: desc, analyzers: analyzers, cfg: cfg} } +func NewLinterFromAnalyzer(analyzer *analysis.Analyzer) *Linter { + return NewLinter(analyzer.Name, analyzer.Doc, []*analysis.Analyzer{analyzer}, nil) +} + func (lnt *Linter) Run(_ context.Context, lintCtx *linter.Context) ([]result.Issue, error) { if err := lnt.preRun(lintCtx); err != nil { return nil, err @@ -71,6 +70,24 @@ func (lnt *Linter) LoadMode() LoadMode { return lnt.loadMode } +func (lnt *Linter) WithDesc(desc string) *Linter { + lnt.desc = desc + + return lnt +} + +func (lnt *Linter) WithConfig(cfg map[string]any) *Linter { + if len(cfg) == 0 { + return lnt + } + + lnt.cfg = map[string]map[string]any{ + lnt.name: cfg, + } + + return lnt +} + func (lnt *Linter) WithLoadMode(loadMode LoadMode) *Linter { lnt.loadMode = loadMode return lnt diff --git a/pkg/golinters/arangolint/arangolint.go b/pkg/golinters/arangolint/arangolint.go index 7a46d93d02a9..1598d532a879 100644 --- a/pkg/golinters/arangolint/arangolint.go +++ b/pkg/golinters/arangolint/arangolint.go @@ -2,18 +2,12 @@ package arangolint import ( "go.augendre.info/arangolint/pkg/analyzer" - "golang.org/x/tools/go/analysis" "github.com/golangci/golangci-lint/v2/pkg/goanalysis" ) func New() *goanalysis.Linter { - a := analyzer.NewAnalyzer() - - return goanalysis.NewLinter( - a.Name, - a.Doc, - []*analysis.Analyzer{a}, - nil, - ).WithLoadMode(goanalysis.LoadModeTypesInfo) + return goanalysis. + NewLinterFromAnalyzer(analyzer.NewAnalyzer()). + WithLoadMode(goanalysis.LoadModeTypesInfo) } diff --git a/pkg/golinters/asasalint/asasalint.go b/pkg/golinters/asasalint/asasalint.go index 5f33428c2224..0261e109d8aa 100644 --- a/pkg/golinters/asasalint/asasalint.go +++ b/pkg/golinters/asasalint/asasalint.go @@ -2,7 +2,6 @@ package asasalint import ( "github.com/alingse/asasalint" - "golang.org/x/tools/go/analysis" "github.com/golangci/golangci-lint/v2/pkg/config" "github.com/golangci/golangci-lint/v2/pkg/goanalysis" @@ -19,15 +18,12 @@ func New(settings *config.AsasalintSettings) *goanalysis.Linter { cfg.IgnoreTest = false } - a, err := asasalint.NewAnalyzer(cfg) + analyzer, err := asasalint.NewAnalyzer(cfg) if err != nil { internal.LinterLogger.Fatalf("asasalint: create analyzer: %v", err) } - return goanalysis.NewLinter( - a.Name, - a.Doc, - []*analysis.Analyzer{a}, - nil, - ).WithLoadMode(goanalysis.LoadModeTypesInfo) + return goanalysis. + NewLinterFromAnalyzer(analyzer). + WithLoadMode(goanalysis.LoadModeTypesInfo) } diff --git a/pkg/golinters/asciicheck/asciicheck.go b/pkg/golinters/asciicheck/asciicheck.go index b5cdaa80bbeb..4872770365c6 100644 --- a/pkg/golinters/asciicheck/asciicheck.go +++ b/pkg/golinters/asciicheck/asciicheck.go @@ -2,18 +2,12 @@ package asciicheck import ( "github.com/tdakkota/asciicheck" - "golang.org/x/tools/go/analysis" "github.com/golangci/golangci-lint/v2/pkg/goanalysis" ) func New() *goanalysis.Linter { - a := asciicheck.NewAnalyzer() - - return goanalysis.NewLinter( - a.Name, - a.Doc, - []*analysis.Analyzer{a}, - nil, - ).WithLoadMode(goanalysis.LoadModeSyntax) + return goanalysis. + NewLinterFromAnalyzer(asciicheck.NewAnalyzer()). + WithLoadMode(goanalysis.LoadModeSyntax) } diff --git a/pkg/golinters/bidichk/bidichk.go b/pkg/golinters/bidichk/bidichk.go index 2d2a8d664fa4..c35daafbfb77 100644 --- a/pkg/golinters/bidichk/bidichk.go +++ b/pkg/golinters/bidichk/bidichk.go @@ -4,16 +4,14 @@ import ( "strings" "github.com/breml/bidichk/pkg/bidichk" - "golang.org/x/tools/go/analysis" "github.com/golangci/golangci-lint/v2/pkg/config" "github.com/golangci/golangci-lint/v2/pkg/goanalysis" ) func New(settings *config.BiDiChkSettings) *goanalysis.Linter { - a := bidichk.NewAnalyzer() + var cfg map[string]any - cfg := map[string]map[string]any{} if settings != nil { var opts []string @@ -45,15 +43,13 @@ func New(settings *config.BiDiChkSettings) *goanalysis.Linter { opts = append(opts, "POP-DIRECTIONAL-ISOLATE") } - cfg[a.Name] = map[string]any{ + cfg = map[string]any{ "disallowed-runes": strings.Join(opts, ","), } } - return goanalysis.NewLinter( - a.Name, - "Checks for dangerous unicode character sequences", - []*analysis.Analyzer{a}, - cfg, - ).WithLoadMode(goanalysis.LoadModeSyntax) + return goanalysis. + NewLinterFromAnalyzer(bidichk.NewAnalyzer()). + WithConfig(cfg). + WithLoadMode(goanalysis.LoadModeSyntax) } diff --git a/pkg/golinters/bodyclose/bodyclose.go b/pkg/golinters/bodyclose/bodyclose.go index 0c86fbe76513..f68c4d0a9e6a 100644 --- a/pkg/golinters/bodyclose/bodyclose.go +++ b/pkg/golinters/bodyclose/bodyclose.go @@ -2,18 +2,12 @@ package bodyclose import ( "github.com/timakin/bodyclose/passes/bodyclose" - "golang.org/x/tools/go/analysis" "github.com/golangci/golangci-lint/v2/pkg/goanalysis" ) func New() *goanalysis.Linter { - a := bodyclose.Analyzer - - return goanalysis.NewLinter( - a.Name, - a.Doc, - []*analysis.Analyzer{a}, - nil, - ).WithLoadMode(goanalysis.LoadModeTypesInfo) + return goanalysis. + NewLinterFromAnalyzer(bodyclose.Analyzer). + WithLoadMode(goanalysis.LoadModeTypesInfo) } diff --git a/pkg/golinters/canonicalheader/canonicalheader.go b/pkg/golinters/canonicalheader/canonicalheader.go index bda1dfbd20d3..24e95f143e9d 100644 --- a/pkg/golinters/canonicalheader/canonicalheader.go +++ b/pkg/golinters/canonicalheader/canonicalheader.go @@ -2,18 +2,12 @@ package canonicalheader import ( "github.com/lasiar/canonicalheader" - "golang.org/x/tools/go/analysis" "github.com/golangci/golangci-lint/v2/pkg/goanalysis" ) func New() *goanalysis.Linter { - a := canonicalheader.Analyzer - - return goanalysis.NewLinter( - a.Name, - a.Doc, - []*analysis.Analyzer{a}, - nil, - ).WithLoadMode(goanalysis.LoadModeTypesInfo) + return goanalysis. + NewLinterFromAnalyzer(canonicalheader.Analyzer). + WithLoadMode(goanalysis.LoadModeTypesInfo) } diff --git a/pkg/golinters/containedctx/containedctx.go b/pkg/golinters/containedctx/containedctx.go index 6bdb08350dd7..6d17b8e46fcf 100644 --- a/pkg/golinters/containedctx/containedctx.go +++ b/pkg/golinters/containedctx/containedctx.go @@ -2,18 +2,12 @@ package containedctx import ( "github.com/sivchari/containedctx" - "golang.org/x/tools/go/analysis" "github.com/golangci/golangci-lint/v2/pkg/goanalysis" ) func New() *goanalysis.Linter { - a := containedctx.Analyzer - - return goanalysis.NewLinter( - a.Name, - a.Doc, - []*analysis.Analyzer{a}, - nil, - ).WithLoadMode(goanalysis.LoadModeTypesInfo) + return goanalysis. + NewLinterFromAnalyzer(containedctx.Analyzer). + WithLoadMode(goanalysis.LoadModeTypesInfo) } diff --git a/pkg/golinters/contextcheck/contextcheck.go b/pkg/golinters/contextcheck/contextcheck.go index 9d01fb7a2038..88c71d2d3eb2 100644 --- a/pkg/golinters/contextcheck/contextcheck.go +++ b/pkg/golinters/contextcheck/contextcheck.go @@ -2,7 +2,6 @@ package contextcheck import ( "github.com/kkHAIKE/contextcheck" - "golang.org/x/tools/go/analysis" "github.com/golangci/golangci-lint/v2/pkg/goanalysis" "github.com/golangci/golangci-lint/v2/pkg/lint/linter" @@ -11,12 +10,10 @@ import ( func New() *goanalysis.Linter { analyzer := contextcheck.NewAnalyzer(contextcheck.Configuration{}) - return goanalysis.NewLinter( - analyzer.Name, - analyzer.Doc, - []*analysis.Analyzer{analyzer}, - nil, - ).WithContextSetter(func(lintCtx *linter.Context) { - analyzer.Run = contextcheck.NewRun(lintCtx.Packages, false) - }).WithLoadMode(goanalysis.LoadModeTypesInfo) + return goanalysis. + NewLinterFromAnalyzer(analyzer). + WithContextSetter(func(lintCtx *linter.Context) { + analyzer.Run = contextcheck.NewRun(lintCtx.Packages, false) + }). + WithLoadMode(goanalysis.LoadModeTypesInfo) } diff --git a/pkg/golinters/copyloopvar/copyloopvar.go b/pkg/golinters/copyloopvar/copyloopvar.go index f6ca96f99567..9dc81de58af2 100644 --- a/pkg/golinters/copyloopvar/copyloopvar.go +++ b/pkg/golinters/copyloopvar/copyloopvar.go @@ -2,28 +2,22 @@ package copyloopvar import ( "github.com/karamaru-alpha/copyloopvar" - "golang.org/x/tools/go/analysis" "github.com/golangci/golangci-lint/v2/pkg/config" "github.com/golangci/golangci-lint/v2/pkg/goanalysis" ) func New(settings *config.CopyLoopVarSettings) *goanalysis.Linter { - a := copyloopvar.NewAnalyzer() + var cfg map[string]any - var cfg map[string]map[string]any if settings != nil { - cfg = map[string]map[string]any{ - a.Name: { - "check-alias": settings.CheckAlias, - }, + cfg = map[string]any{ + "check-alias": settings.CheckAlias, } } - return goanalysis.NewLinter( - a.Name, - a.Doc, - []*analysis.Analyzer{a}, - cfg, - ).WithLoadMode(goanalysis.LoadModeSyntax) + return goanalysis. + NewLinterFromAnalyzer(copyloopvar.NewAnalyzer()). + WithConfig(cfg). + WithLoadMode(goanalysis.LoadModeSyntax) } diff --git a/pkg/golinters/cyclop/cyclop.go b/pkg/golinters/cyclop/cyclop.go index 41db272cd4e3..0a0e2dbc635b 100644 --- a/pkg/golinters/cyclop/cyclop.go +++ b/pkg/golinters/cyclop/cyclop.go @@ -2,37 +2,29 @@ package cyclop import ( "github.com/bkielbasa/cyclop/pkg/analyzer" - "golang.org/x/tools/go/analysis" "github.com/golangci/golangci-lint/v2/pkg/config" "github.com/golangci/golangci-lint/v2/pkg/goanalysis" ) func New(settings *config.CyclopSettings) *goanalysis.Linter { - a := analyzer.NewAnalyzer() + cfg := map[string]any{} - var cfg map[string]map[string]any if settings != nil { - d := map[string]any{ - // Should be managed with `linters.exclusions.rules`. - "skipTests": false, - } + // Should be managed with `linters.exclusions.rules`. + cfg["skipTests"] = false if settings.MaxComplexity != 0 { - d["maxComplexity"] = settings.MaxComplexity + cfg["maxComplexity"] = settings.MaxComplexity } if settings.PackageAverage != 0 { - d["packageAverage"] = settings.PackageAverage + cfg["packageAverage"] = settings.PackageAverage } - - cfg = map[string]map[string]any{a.Name: d} } - return goanalysis.NewLinter( - a.Name, - a.Doc, - []*analysis.Analyzer{a}, - cfg, - ).WithLoadMode(goanalysis.LoadModeSyntax) + return goanalysis. + NewLinterFromAnalyzer(analyzer.NewAnalyzer()). + WithConfig(cfg). + WithLoadMode(goanalysis.LoadModeSyntax) } diff --git a/pkg/golinters/decorder/decorder.go b/pkg/golinters/decorder/decorder.go index 03a7853c27e2..a67bdfade155 100644 --- a/pkg/golinters/decorder/decorder.go +++ b/pkg/golinters/decorder/decorder.go @@ -4,15 +4,12 @@ import ( "strings" "gitlab.com/bosi/decorder" - "golang.org/x/tools/go/analysis" "github.com/golangci/golangci-lint/v2/pkg/config" "github.com/golangci/golangci-lint/v2/pkg/goanalysis" ) func New(settings *config.DecorderSettings) *goanalysis.Linter { - a := decorder.Analyzer - // disable all rules/checks by default cfg := map[string]any{ "ignore-underscore-vars": false, @@ -35,10 +32,8 @@ func New(settings *config.DecorderSettings) *goanalysis.Linter { cfg["disable-init-func-first-check"] = settings.DisableInitFuncFirstCheck } - return goanalysis.NewLinter( - a.Name, - a.Doc, - []*analysis.Analyzer{a}, - map[string]map[string]any{a.Name: cfg}, - ).WithLoadMode(goanalysis.LoadModeSyntax) + return goanalysis. + NewLinterFromAnalyzer(decorder.Analyzer). + WithConfig(cfg). + WithLoadMode(goanalysis.LoadModeSyntax) } diff --git a/pkg/golinters/depguard/depguard.go b/pkg/golinters/depguard/depguard.go index c1f66b0c81cc..cc01f4f47ab5 100644 --- a/pkg/golinters/depguard/depguard.go +++ b/pkg/golinters/depguard/depguard.go @@ -4,7 +4,6 @@ import ( "strings" "github.com/OpenPeeDeeP/depguard/v2" - "golang.org/x/tools/go/analysis" "github.com/golangci/golangci-lint/v2/pkg/config" "github.com/golangci/golangci-lint/v2/pkg/goanalysis" @@ -41,17 +40,15 @@ func New(settings *config.DepGuardSettings, replacer *strings.Replacer) *goanaly } } - a := depguard.NewUncompiledAnalyzer(&conf) - - return goanalysis.NewLinter( - a.Analyzer.Name, - a.Analyzer.Doc, - []*analysis.Analyzer{a.Analyzer}, - nil, - ).WithContextSetter(func(lintCtx *linter.Context) { - err := a.Compile() - if err != nil { - lintCtx.Log.Errorf("create analyzer: %v", err) - } - }).WithLoadMode(goanalysis.LoadModeSyntax) + analyzer := depguard.NewUncompiledAnalyzer(&conf) + + return goanalysis. + NewLinterFromAnalyzer(analyzer.Analyzer). + WithContextSetter(func(lintCtx *linter.Context) { + err := analyzer.Compile() + if err != nil { + lintCtx.Log.Errorf("create analyzer: %v", err) + } + }). + WithLoadMode(goanalysis.LoadModeSyntax) } diff --git a/pkg/golinters/dogsled/dogsled.go b/pkg/golinters/dogsled/dogsled.go index 23d48ba57274..c5e872182cc7 100644 --- a/pkg/golinters/dogsled/dogsled.go +++ b/pkg/golinters/dogsled/dogsled.go @@ -11,24 +11,17 @@ import ( "github.com/golangci/golangci-lint/v2/pkg/goanalysis" ) -const linterName = "dogsled" - func New(settings *config.DogsledSettings) *goanalysis.Linter { - analyzer := &analysis.Analyzer{ - Name: linterName, - Doc: goanalysis.TheOnlyanalyzerDoc, - Run: func(pass *analysis.Pass) (any, error) { - return run(pass, settings.MaxBlankIdentifiers) - }, - Requires: []*analysis.Analyzer{inspect.Analyzer}, - } - - return goanalysis.NewLinter( - linterName, - "Checks assignments with too many blank identifiers (e.g. x, _, _, _, := f())", - []*analysis.Analyzer{analyzer}, - nil, - ).WithLoadMode(goanalysis.LoadModeSyntax) + return goanalysis. + NewLinterFromAnalyzer(&analysis.Analyzer{ + Name: "dogsled", + Doc: "Checks assignments with too many blank identifiers (e.g. x, _, _, _, := f())", + Run: func(pass *analysis.Pass) (any, error) { + return run(pass, settings.MaxBlankIdentifiers) + }, + Requires: []*analysis.Analyzer{inspect.Analyzer}, + }). + WithLoadMode(goanalysis.LoadModeSyntax) } func run(pass *analysis.Pass, maxBlanks int) (any, error) { diff --git a/pkg/golinters/dupl/dupl.go b/pkg/golinters/dupl/dupl.go index 993bfd6f2326..654c795ff696 100644 --- a/pkg/golinters/dupl/dupl.go +++ b/pkg/golinters/dupl/dupl.go @@ -22,35 +22,31 @@ func New(settings *config.DuplSettings) *goanalysis.Linter { var mu sync.Mutex var resIssues []goanalysis.Issue - analyzer := &analysis.Analyzer{ - Name: linterName, - Doc: goanalysis.TheOnlyanalyzerDoc, - Run: func(pass *analysis.Pass) (any, error) { - issues, err := runDupl(pass, settings) - if err != nil { - return nil, err - } - - if len(issues) == 0 { - return nil, nil - } - - mu.Lock() - resIssues = append(resIssues, issues...) - mu.Unlock() - - return nil, nil - }, - } + return goanalysis. + NewLinterFromAnalyzer(&analysis.Analyzer{ + Name: linterName, + Doc: "Detects duplicate fragments of code.", + Run: func(pass *analysis.Pass) (any, error) { + issues, err := runDupl(pass, settings) + if err != nil { + return nil, err + } + + if len(issues) == 0 { + return nil, nil + } + + mu.Lock() + resIssues = append(resIssues, issues...) + mu.Unlock() - return goanalysis.NewLinter( - linterName, - "Detects duplicate fragments of code.", - []*analysis.Analyzer{analyzer}, - nil, - ).WithIssuesReporter(func(*linter.Context) []goanalysis.Issue { - return resIssues - }).WithLoadMode(goanalysis.LoadModeSyntax) + return nil, nil + }, + }). + WithIssuesReporter(func(*linter.Context) []goanalysis.Issue { + return resIssues + }). + WithLoadMode(goanalysis.LoadModeSyntax) } func runDupl(pass *analysis.Pass, settings *config.DuplSettings) ([]goanalysis.Issue, error) { diff --git a/pkg/golinters/dupword/dupword.go b/pkg/golinters/dupword/dupword.go index 62851475f608..7b989bc22a8f 100644 --- a/pkg/golinters/dupword/dupword.go +++ b/pkg/golinters/dupword/dupword.go @@ -4,27 +4,24 @@ import ( "strings" "github.com/Abirdcfly/dupword" - "golang.org/x/tools/go/analysis" "github.com/golangci/golangci-lint/v2/pkg/config" "github.com/golangci/golangci-lint/v2/pkg/goanalysis" ) func New(settings *config.DupWordSettings) *goanalysis.Linter { - a := dupword.NewAnalyzer() + var cfg map[string]any - cfg := map[string]map[string]any{} if settings != nil { - cfg[a.Name] = map[string]any{ + cfg = map[string]any{ "keyword": strings.Join(settings.Keywords, ","), "ignore": strings.Join(settings.Ignore, ","), } } - return goanalysis.NewLinter( - a.Name, - "checks for duplicate words in the source code", - []*analysis.Analyzer{a}, - cfg, - ).WithLoadMode(goanalysis.LoadModeSyntax) + return goanalysis. + NewLinterFromAnalyzer(dupword.NewAnalyzer()). + WithDesc("Checks for duplicate words in the source code"). + WithConfig(cfg). + WithLoadMode(goanalysis.LoadModeSyntax) } diff --git a/pkg/golinters/durationcheck/durationcheck.go b/pkg/golinters/durationcheck/durationcheck.go index d3e74231f5b3..b6723fa12574 100644 --- a/pkg/golinters/durationcheck/durationcheck.go +++ b/pkg/golinters/durationcheck/durationcheck.go @@ -2,18 +2,12 @@ package durationcheck import ( "github.com/charithe/durationcheck" - "golang.org/x/tools/go/analysis" "github.com/golangci/golangci-lint/v2/pkg/goanalysis" ) func New() *goanalysis.Linter { - a := durationcheck.Analyzer - - return goanalysis.NewLinter( - a.Name, - a.Doc, - []*analysis.Analyzer{a}, - nil, - ).WithLoadMode(goanalysis.LoadModeTypesInfo) + return goanalysis. + NewLinterFromAnalyzer(durationcheck.Analyzer). + WithLoadMode(goanalysis.LoadModeTypesInfo) } diff --git a/pkg/golinters/embeddedstructfieldcheck/embeddedstructfieldcheck.go b/pkg/golinters/embeddedstructfieldcheck/embeddedstructfieldcheck.go index 781bcf5d201e..0932ac4fed66 100644 --- a/pkg/golinters/embeddedstructfieldcheck/embeddedstructfieldcheck.go +++ b/pkg/golinters/embeddedstructfieldcheck/embeddedstructfieldcheck.go @@ -2,18 +2,12 @@ package embeddedstructfieldcheck import ( "github.com/manuelarte/embeddedstructfieldcheck/analyzer" - "golang.org/x/tools/go/analysis" "github.com/golangci/golangci-lint/v2/pkg/goanalysis" ) func New() *goanalysis.Linter { - a := analyzer.NewAnalyzer() - - return goanalysis.NewLinter( - a.Name, - a.Doc, - []*analysis.Analyzer{a}, - nil, - ).WithLoadMode(goanalysis.LoadModeSyntax) + return goanalysis. + NewLinterFromAnalyzer(analyzer.NewAnalyzer()). + WithLoadMode(goanalysis.LoadModeSyntax) } diff --git a/pkg/golinters/err113/err113.go b/pkg/golinters/err113/err113.go index 78ef99d6a1a9..d3b3a4c1cca7 100644 --- a/pkg/golinters/err113/err113.go +++ b/pkg/golinters/err113/err113.go @@ -2,18 +2,13 @@ package err113 import ( "github.com/Djarvur/go-err113" - "golang.org/x/tools/go/analysis" "github.com/golangci/golangci-lint/v2/pkg/goanalysis" ) func New() *goanalysis.Linter { - a := err113.NewAnalyzer() - - return goanalysis.NewLinter( - a.Name, - "Go linter to check the errors handling expressions", - []*analysis.Analyzer{a}, - nil, - ).WithLoadMode(goanalysis.LoadModeTypesInfo) + return goanalysis. + NewLinterFromAnalyzer(err113.NewAnalyzer()). + WithDesc("Check errors handling expressions"). + WithLoadMode(goanalysis.LoadModeTypesInfo) } diff --git a/pkg/golinters/errcheck/errcheck.go b/pkg/golinters/errcheck/errcheck.go index 56d00c350b4f..c3c813d4f828 100644 --- a/pkg/golinters/errcheck/errcheck.go +++ b/pkg/golinters/errcheck/errcheck.go @@ -25,36 +25,35 @@ func New(settings *config.ErrcheckSettings) *goanalysis.Linter { analyzer := &analysis.Analyzer{ Name: linterName, - Doc: goanalysis.TheOnlyanalyzerDoc, - Run: goanalysis.DummyRun, + Doc: "errcheck is a program for checking for unchecked errors in Go code. " + + "These unchecked errors can be critical bugs in some cases", + Run: goanalysis.DummyRun, } - return goanalysis.NewLinter( - linterName, - "errcheck is a program for checking for unchecked errors in Go code. "+ - "These unchecked errors can be critical bugs in some cases", - []*analysis.Analyzer{analyzer}, - nil, - ).WithContextSetter(func(lintCtx *linter.Context) { - checker := getChecker(settings) - checker.Tags = lintCtx.Cfg.Run.BuildTags + return goanalysis. + NewLinterFromAnalyzer(analyzer). + WithContextSetter(func(lintCtx *linter.Context) { + checker := getChecker(settings) + checker.Tags = lintCtx.Cfg.Run.BuildTags - analyzer.Run = func(pass *analysis.Pass) (any, error) { - issues := runErrCheck(lintCtx, pass, checker) + analyzer.Run = func(pass *analysis.Pass) (any, error) { + issues := runErrCheck(lintCtx, pass, checker) - if len(issues) == 0 { - return nil, nil - } + if len(issues) == 0 { + return nil, nil + } - mu.Lock() - resIssues = append(resIssues, issues...) - mu.Unlock() + mu.Lock() + resIssues = append(resIssues, issues...) + mu.Unlock() - return nil, nil - } - }).WithIssuesReporter(func(*linter.Context) []goanalysis.Issue { - return resIssues - }).WithLoadMode(goanalysis.LoadModeTypesInfo) + return nil, nil + } + }). + WithIssuesReporter(func(*linter.Context) []goanalysis.Issue { + return resIssues + }). + WithLoadMode(goanalysis.LoadModeTypesInfo) } func runErrCheck(lintCtx *linter.Context, pass *analysis.Pass, checker *errcheck.Checker) []goanalysis.Issue { diff --git a/pkg/golinters/errchkjson/errchkjson.go b/pkg/golinters/errchkjson/errchkjson.go index a705406e49f5..02510ab49901 100644 --- a/pkg/golinters/errchkjson/errchkjson.go +++ b/pkg/golinters/errchkjson/errchkjson.go @@ -2,30 +2,25 @@ package errchkjson import ( "github.com/breml/errchkjson" - "golang.org/x/tools/go/analysis" "github.com/golangci/golangci-lint/v2/pkg/config" "github.com/golangci/golangci-lint/v2/pkg/goanalysis" ) func New(settings *config.ErrChkJSONSettings) *goanalysis.Linter { - a := errchkjson.NewAnalyzer() - - cfg := map[string]map[string]any{} - cfg[a.Name] = map[string]any{ + cfg := map[string]any{ "omit-safe": true, } + if settings != nil { - cfg[a.Name] = map[string]any{ + cfg = map[string]any{ "omit-safe": !settings.CheckErrorFreeEncoding, "report-no-exported": settings.ReportNoExported, } } - return goanalysis.NewLinter( - a.Name, - a.Doc, - []*analysis.Analyzer{a}, - cfg, - ).WithLoadMode(goanalysis.LoadModeTypesInfo) + return goanalysis. + NewLinterFromAnalyzer(errchkjson.NewAnalyzer()). + WithConfig(cfg). + WithLoadMode(goanalysis.LoadModeTypesInfo) } diff --git a/pkg/golinters/errname/errname.go b/pkg/golinters/errname/errname.go index 36d6f12356fd..a66f3211f4e9 100644 --- a/pkg/golinters/errname/errname.go +++ b/pkg/golinters/errname/errname.go @@ -2,18 +2,12 @@ package errname import ( "github.com/Antonboom/errname/pkg/analyzer" - "golang.org/x/tools/go/analysis" "github.com/golangci/golangci-lint/v2/pkg/goanalysis" ) func New() *goanalysis.Linter { - a := analyzer.New() - - return goanalysis.NewLinter( - a.Name, - a.Doc, - []*analysis.Analyzer{a}, - nil, - ).WithLoadMode(goanalysis.LoadModeTypesInfo) + return goanalysis. + NewLinterFromAnalyzer(analyzer.New()). + WithLoadMode(goanalysis.LoadModeTypesInfo) } diff --git a/pkg/golinters/errorlint/errorlint.go b/pkg/golinters/errorlint/errorlint.go index 7560bc0af90b..f32217796920 100644 --- a/pkg/golinters/errorlint/errorlint.go +++ b/pkg/golinters/errorlint/errorlint.go @@ -2,7 +2,6 @@ package errorlint import ( "github.com/polyfloyd/go-errorlint/errorlint" - "golang.org/x/tools/go/analysis" "github.com/golangci/golangci-lint/v2/pkg/config" "github.com/golangci/golangci-lint/v2/pkg/goanalysis" @@ -23,12 +22,10 @@ func New(settings *config.ErrorLintSettings) *goanalysis.Linter { } } - a := errorlint.NewAnalyzer(opts...) - - cfg := map[string]map[string]any{} + var cfg map[string]any if settings != nil { - cfg[a.Name] = map[string]any{ + cfg = map[string]any{ "errorf": settings.Errorf, "errorf-multi": settings.ErrorfMulti, "asserts": settings.Asserts, @@ -36,13 +33,11 @@ func New(settings *config.ErrorLintSettings) *goanalysis.Linter { } } - return goanalysis.NewLinter( - a.Name, - "errorlint is a linter for that can be used to find code "+ - "that will cause problems with the error wrapping scheme introduced in Go 1.13.", - []*analysis.Analyzer{a}, - cfg, - ).WithLoadMode(goanalysis.LoadModeTypesInfo) + return goanalysis. + NewLinterFromAnalyzer(errorlint.NewAnalyzer(opts...)). + WithDesc("Find code that can cause problems with the error wrapping scheme introduced in Go 1.13."). + WithConfig(cfg). + WithLoadMode(goanalysis.LoadModeTypesInfo) } func toAllowPairs(data []config.ErrorLintAllowPair) []errorlint.AllowPair { diff --git a/pkg/golinters/exhaustive/exhaustive.go b/pkg/golinters/exhaustive/exhaustive.go index be77e54a4bc6..ec240739d69e 100644 --- a/pkg/golinters/exhaustive/exhaustive.go +++ b/pkg/golinters/exhaustive/exhaustive.go @@ -2,37 +2,31 @@ package exhaustive import ( "github.com/nishanths/exhaustive" - "golang.org/x/tools/go/analysis" "github.com/golangci/golangci-lint/v2/pkg/config" "github.com/golangci/golangci-lint/v2/pkg/goanalysis" ) func New(settings *config.ExhaustiveSettings) *goanalysis.Linter { - a := exhaustive.Analyzer + var cfg map[string]any - var cfg map[string]map[string]any if settings != nil { - cfg = map[string]map[string]any{ - a.Name: { - exhaustive.CheckFlag: settings.Check, - exhaustive.DefaultSignifiesExhaustiveFlag: settings.DefaultSignifiesExhaustive, - exhaustive.IgnoreEnumMembersFlag: settings.IgnoreEnumMembers, - exhaustive.IgnoreEnumTypesFlag: settings.IgnoreEnumTypes, - exhaustive.PackageScopeOnlyFlag: settings.PackageScopeOnly, - exhaustive.ExplicitExhaustiveMapFlag: settings.ExplicitExhaustiveMap, - exhaustive.ExplicitExhaustiveSwitchFlag: settings.ExplicitExhaustiveSwitch, - exhaustive.DefaultCaseRequiredFlag: settings.DefaultCaseRequired, - // Should be managed with `linters.exclusions.generated`. - exhaustive.CheckGeneratedFlag: true, - }, + cfg = map[string]any{ + exhaustive.CheckFlag: settings.Check, + exhaustive.DefaultSignifiesExhaustiveFlag: settings.DefaultSignifiesExhaustive, + exhaustive.IgnoreEnumMembersFlag: settings.IgnoreEnumMembers, + exhaustive.IgnoreEnumTypesFlag: settings.IgnoreEnumTypes, + exhaustive.PackageScopeOnlyFlag: settings.PackageScopeOnly, + exhaustive.ExplicitExhaustiveMapFlag: settings.ExplicitExhaustiveMap, + exhaustive.ExplicitExhaustiveSwitchFlag: settings.ExplicitExhaustiveSwitch, + exhaustive.DefaultCaseRequiredFlag: settings.DefaultCaseRequired, + // Should be managed with `linters.exclusions.generated`. + exhaustive.CheckGeneratedFlag: true, } } - return goanalysis.NewLinter( - a.Name, - a.Doc, - []*analysis.Analyzer{a}, - cfg, - ).WithLoadMode(goanalysis.LoadModeTypesInfo) + return goanalysis. + NewLinterFromAnalyzer(exhaustive.Analyzer). + WithConfig(cfg). + WithLoadMode(goanalysis.LoadModeTypesInfo) } diff --git a/pkg/golinters/exhaustruct/exhaustruct.go b/pkg/golinters/exhaustruct/exhaustruct.go index 9b742129969d..290878e1c404 100644 --- a/pkg/golinters/exhaustruct/exhaustruct.go +++ b/pkg/golinters/exhaustruct/exhaustruct.go @@ -1,8 +1,7 @@ package exhaustruct import ( - "github.com/GaijinEntertainment/go-exhaustruct/v3/analyzer" - "golang.org/x/tools/go/analysis" + exhaustruct "github.com/GaijinEntertainment/go-exhaustruct/v3/analyzer" "github.com/golangci/golangci-lint/v2/pkg/config" "github.com/golangci/golangci-lint/v2/pkg/goanalysis" @@ -11,20 +10,18 @@ import ( func New(settings *config.ExhaustructSettings) *goanalysis.Linter { var include, exclude []string + if settings != nil { include = settings.Include exclude = settings.Exclude } - a, err := analyzer.NewAnalyzer(include, exclude) + analyzer, err := exhaustruct.NewAnalyzer(include, exclude) if err != nil { internal.LinterLogger.Fatalf("exhaustruct configuration: %v", err) } - return goanalysis.NewLinter( - a.Name, - a.Doc, - []*analysis.Analyzer{a}, - nil, - ).WithLoadMode(goanalysis.LoadModeTypesInfo) + return goanalysis. + NewLinterFromAnalyzer(analyzer). + WithLoadMode(goanalysis.LoadModeTypesInfo) } diff --git a/pkg/golinters/exptostd/exptostd.go b/pkg/golinters/exptostd/exptostd.go index 731a4a0ccad7..dbd78dce91cb 100644 --- a/pkg/golinters/exptostd/exptostd.go +++ b/pkg/golinters/exptostd/exptostd.go @@ -2,18 +2,12 @@ package exptostd import ( "github.com/ldez/exptostd" - "golang.org/x/tools/go/analysis" "github.com/golangci/golangci-lint/v2/pkg/goanalysis" ) func New() *goanalysis.Linter { - a := exptostd.NewAnalyzer() - - return goanalysis.NewLinter( - a.Name, - a.Doc, - []*analysis.Analyzer{a}, - nil, - ).WithLoadMode(goanalysis.LoadModeTypesInfo) + return goanalysis. + NewLinterFromAnalyzer(exptostd.NewAnalyzer()). + WithLoadMode(goanalysis.LoadModeTypesInfo) } diff --git a/pkg/golinters/fatcontext/fatcontext.go b/pkg/golinters/fatcontext/fatcontext.go index e0506259bee9..58933c660588 100644 --- a/pkg/golinters/fatcontext/fatcontext.go +++ b/pkg/golinters/fatcontext/fatcontext.go @@ -2,27 +2,22 @@ package fatcontext import ( "go.augendre.info/fatcontext/pkg/analyzer" - "golang.org/x/tools/go/analysis" "github.com/golangci/golangci-lint/v2/pkg/config" "github.com/golangci/golangci-lint/v2/pkg/goanalysis" ) func New(settings *config.FatcontextSettings) *goanalysis.Linter { - a := analyzer.NewAnalyzer() - - cfg := map[string]map[string]any{} + var cfg map[string]any if settings != nil { - cfg[a.Name] = map[string]any{ + cfg = map[string]any{ analyzer.FlagCheckStructPointers: settings.CheckStructPointers, } } - return goanalysis.NewLinter( - a.Name, - a.Doc, - []*analysis.Analyzer{a}, - cfg, - ).WithLoadMode(goanalysis.LoadModeTypesInfo) + return goanalysis. + NewLinterFromAnalyzer(analyzer.NewAnalyzer()). + WithConfig(cfg). + WithLoadMode(goanalysis.LoadModeTypesInfo) } diff --git a/pkg/golinters/forbidigo/forbidigo.go b/pkg/golinters/forbidigo/forbidigo.go index f7c5efd3d8f1..796faf3a6ef0 100644 --- a/pkg/golinters/forbidigo/forbidigo.go +++ b/pkg/golinters/forbidigo/forbidigo.go @@ -15,28 +15,23 @@ import ( const linterName = "forbidigo" func New(settings *config.ForbidigoSettings) *goanalysis.Linter { - analyzer := &analysis.Analyzer{ - Name: linterName, - Doc: goanalysis.TheOnlyanalyzerDoc, - Run: func(pass *analysis.Pass) (any, error) { - err := runForbidigo(pass, settings) - if err != nil { - return nil, err - } - - return nil, nil - }, - } - // Without AnalyzeTypes, LoadModeSyntax is enough. // But we cannot make this depend on the settings and have to mirror the mode chosen in GetAllSupportedLinterConfigs, - // therefore we have to use LoadModeTypesInfo in all cases. - return goanalysis.NewLinter( - linterName, - "Forbids identifiers", - []*analysis.Analyzer{analyzer}, - nil, - ).WithLoadMode(goanalysis.LoadModeTypesInfo) + // therefore, we have to use LoadModeTypesInfo in all cases. + return goanalysis. + NewLinterFromAnalyzer(&analysis.Analyzer{ + Name: linterName, + Doc: "Forbids identifiers", + Run: func(pass *analysis.Pass) (any, error) { + err := runForbidigo(pass, settings) + if err != nil { + return nil, err + } + + return nil, nil + }, + }). + WithLoadMode(goanalysis.LoadModeTypesInfo) } func runForbidigo(pass *analysis.Pass, settings *config.ForbidigoSettings) error { diff --git a/pkg/golinters/forcetypeassert/forcetypeassert.go b/pkg/golinters/forcetypeassert/forcetypeassert.go index e82355380c25..19a0e3450b37 100644 --- a/pkg/golinters/forcetypeassert/forcetypeassert.go +++ b/pkg/golinters/forcetypeassert/forcetypeassert.go @@ -2,18 +2,13 @@ package forcetypeassert import ( "github.com/gostaticanalysis/forcetypeassert" - "golang.org/x/tools/go/analysis" "github.com/golangci/golangci-lint/v2/pkg/goanalysis" ) func New() *goanalysis.Linter { - a := forcetypeassert.Analyzer - - return goanalysis.NewLinter( - a.Name, - "finds forced type assertions", - []*analysis.Analyzer{a}, - nil, - ).WithLoadMode(goanalysis.LoadModeTypesInfo) + return goanalysis. + NewLinterFromAnalyzer(forcetypeassert.Analyzer). + WithDesc("Find forced type assertions"). + WithLoadMode(goanalysis.LoadModeTypesInfo) } diff --git a/pkg/golinters/funcorder/funcorder.go b/pkg/golinters/funcorder/funcorder.go index 605304f26203..06400753ebdb 100644 --- a/pkg/golinters/funcorder/funcorder.go +++ b/pkg/golinters/funcorder/funcorder.go @@ -2,29 +2,24 @@ package funcorder import ( "github.com/manuelarte/funcorder/analyzer" - "golang.org/x/tools/go/analysis" "github.com/golangci/golangci-lint/v2/pkg/config" "github.com/golangci/golangci-lint/v2/pkg/goanalysis" ) func New(settings *config.FuncOrderSettings) *goanalysis.Linter { - a := analyzer.NewAnalyzer() - - cfg := map[string]map[string]any{} + var cfg map[string]any if settings != nil { - cfg[a.Name] = map[string]any{ + cfg = map[string]any{ analyzer.ConstructorCheckName: settings.Constructor, analyzer.StructMethodCheckName: settings.StructMethod, analyzer.AlphabeticalCheckName: settings.Alphabetical, } } - return goanalysis.NewLinter( - a.Name, - a.Doc, - []*analysis.Analyzer{a}, - cfg, - ).WithLoadMode(goanalysis.LoadModeSyntax) + return goanalysis. + NewLinterFromAnalyzer(analyzer.NewAnalyzer()). + WithConfig(cfg). + WithLoadMode(goanalysis.LoadModeSyntax) } diff --git a/pkg/golinters/funlen/funlen.go b/pkg/golinters/funlen/funlen.go index 541d4fd36041..6e0f93b51303 100644 --- a/pkg/golinters/funlen/funlen.go +++ b/pkg/golinters/funlen/funlen.go @@ -2,7 +2,6 @@ package funlen import ( "github.com/ultraware/funlen" - "golang.org/x/tools/go/analysis" "github.com/golangci/golangci-lint/v2/pkg/config" "github.com/golangci/golangci-lint/v2/pkg/goanalysis" @@ -22,12 +21,7 @@ func New(settings *config.FunlenSettings) *goanalysis.Linter { cfg.ignoreComments = settings.IgnoreComments } - a := funlen.NewAnalyzer(cfg.lineLimit, cfg.stmtLimit, cfg.ignoreComments) - - return goanalysis.NewLinter( - a.Name, - a.Doc, - []*analysis.Analyzer{a}, - nil, - ).WithLoadMode(goanalysis.LoadModeSyntax) + return goanalysis. + NewLinterFromAnalyzer(funlen.NewAnalyzer(cfg.lineLimit, cfg.stmtLimit, cfg.ignoreComments)). + WithLoadMode(goanalysis.LoadModeSyntax) } diff --git a/pkg/golinters/gci/gci.go b/pkg/golinters/gci/gci.go index 627a4e6849f2..4357a3b15fc1 100644 --- a/pkg/golinters/gci/gci.go +++ b/pkg/golinters/gci/gci.go @@ -1,8 +1,6 @@ package gci import ( - "golang.org/x/tools/go/analysis" - "github.com/golangci/golangci-lint/v2/pkg/config" "github.com/golangci/golangci-lint/v2/pkg/goanalysis" "github.com/golangci/golangci-lint/v2/pkg/goformatters" @@ -18,16 +16,13 @@ func New(settings *config.GciSettings) *goanalysis.Linter { internal.LinterLogger.Fatalf("%s: create analyzer: %v", linterName, err) } - a := goformatters.NewAnalyzer( - internal.LinterLogger.Child(linterName), - "Checks if code and import statements are formatted, with additional rules.", - formatter, - ) - - return goanalysis.NewLinter( - a.Name, - a.Doc, - []*analysis.Analyzer{a}, - nil, - ).WithLoadMode(goanalysis.LoadModeSyntax) + return goanalysis. + NewLinterFromAnalyzer( + goformatters.NewAnalyzer( + internal.LinterLogger.Child(linterName), + "Check if code and import statements are formatted, with additional rules.", + formatter, + ), + ). + WithLoadMode(goanalysis.LoadModeSyntax) } diff --git a/pkg/golinters/ginkgolinter/ginkgolinter.go b/pkg/golinters/ginkgolinter/ginkgolinter.go index f4521cdaf81f..519e968e5d8b 100644 --- a/pkg/golinters/ginkgolinter/ginkgolinter.go +++ b/pkg/golinters/ginkgolinter/ginkgolinter.go @@ -3,7 +3,6 @@ package ginkgolinter import ( "github.com/nunnatsa/ginkgolinter" "github.com/nunnatsa/ginkgolinter/types" - "golang.org/x/tools/go/analysis" "github.com/golangci/golangci-lint/v2/pkg/config" "github.com/golangci/golangci-lint/v2/pkg/goanalysis" @@ -29,12 +28,8 @@ func New(settings *config.GinkgoLinterSettings) *goanalysis.Linter { } } - a := ginkgolinter.NewAnalyzerWithConfig(cfg) - - return goanalysis.NewLinter( - a.Name, - "enforces standards of using ginkgo and gomega", - []*analysis.Analyzer{a}, - nil, - ).WithLoadMode(goanalysis.LoadModeTypesInfo) + return goanalysis. + NewLinterFromAnalyzer(ginkgolinter.NewAnalyzerWithConfig(cfg)). + WithDesc("enforces standards of using ginkgo and gomega"). + WithLoadMode(goanalysis.LoadModeTypesInfo) } diff --git a/pkg/golinters/gocheckcompilerdirectives/gocheckcompilerdirectives.go b/pkg/golinters/gocheckcompilerdirectives/gocheckcompilerdirectives.go index 97534848d802..71f4be8c41db 100644 --- a/pkg/golinters/gocheckcompilerdirectives/gocheckcompilerdirectives.go +++ b/pkg/golinters/gocheckcompilerdirectives/gocheckcompilerdirectives.go @@ -2,18 +2,12 @@ package gocheckcompilerdirectives import ( "4d63.com/gocheckcompilerdirectives/checkcompilerdirectives" - "golang.org/x/tools/go/analysis" "github.com/golangci/golangci-lint/v2/pkg/goanalysis" ) func New() *goanalysis.Linter { - a := checkcompilerdirectives.Analyzer() - - return goanalysis.NewLinter( - a.Name, - a.Doc, - []*analysis.Analyzer{a}, - nil, - ).WithLoadMode(goanalysis.LoadModeSyntax) + return goanalysis. + NewLinterFromAnalyzer(checkcompilerdirectives.Analyzer()). + WithLoadMode(goanalysis.LoadModeSyntax) } diff --git a/pkg/golinters/gochecknoglobals/gochecknoglobals.go b/pkg/golinters/gochecknoglobals/gochecknoglobals.go index 8d850a2de59f..2fd3f3c3bee1 100644 --- a/pkg/golinters/gochecknoglobals/gochecknoglobals.go +++ b/pkg/golinters/gochecknoglobals/gochecknoglobals.go @@ -2,18 +2,13 @@ package gochecknoglobals import ( "4d63.com/gochecknoglobals/checknoglobals" - "golang.org/x/tools/go/analysis" "github.com/golangci/golangci-lint/v2/pkg/goanalysis" ) func New() *goanalysis.Linter { - a := checknoglobals.Analyzer() - - return goanalysis.NewLinter( - a.Name, - "Check that no global variables exist.", - []*analysis.Analyzer{a}, - nil, - ).WithLoadMode(goanalysis.LoadModeTypesInfo) + return goanalysis. + NewLinterFromAnalyzer(checknoglobals.Analyzer()). + WithDesc("Check that no global variables exist."). + WithLoadMode(goanalysis.LoadModeTypesInfo) } diff --git a/pkg/golinters/gochecknoinits/gochecknoinits.go b/pkg/golinters/gochecknoinits/gochecknoinits.go index b5fa6f0d4117..c027aa8ab928 100644 --- a/pkg/golinters/gochecknoinits/gochecknoinits.go +++ b/pkg/golinters/gochecknoinits/gochecknoinits.go @@ -11,22 +11,15 @@ import ( "github.com/golangci/golangci-lint/v2/pkg/golinters/internal" ) -const linterName = "gochecknoinits" - func New() *goanalysis.Linter { - analyzer := &analysis.Analyzer{ - Name: linterName, - Doc: goanalysis.TheOnlyanalyzerDoc, - Run: run, - Requires: []*analysis.Analyzer{inspect.Analyzer}, - } - - return goanalysis.NewLinter( - linterName, - "Checks that no init functions are present in Go code", - []*analysis.Analyzer{analyzer}, - nil, - ).WithLoadMode(goanalysis.LoadModeSyntax) + return goanalysis. + NewLinterFromAnalyzer(&analysis.Analyzer{ + Name: "gochecknoinits", + Doc: "Checks that no init functions are present in Go code", + Run: run, + Requires: []*analysis.Analyzer{inspect.Analyzer}, + }). + WithLoadMode(goanalysis.LoadModeSyntax) } func run(pass *analysis.Pass) (any, error) { diff --git a/pkg/golinters/gochecksumtype/gochecksumtype.go b/pkg/golinters/gochecksumtype/gochecksumtype.go index 78cbd574d20b..85be045dfa8a 100644 --- a/pkg/golinters/gochecksumtype/gochecksumtype.go +++ b/pkg/golinters/gochecksumtype/gochecksumtype.go @@ -20,35 +20,31 @@ func New(settings *config.GoChecksumTypeSettings) *goanalysis.Linter { var mu sync.Mutex var resIssues []goanalysis.Issue - analyzer := &analysis.Analyzer{ - Name: linterName, - Doc: goanalysis.TheOnlyanalyzerDoc, - Run: func(pass *analysis.Pass) (any, error) { - issues, err := runGoCheckSumType(pass, settings) - if err != nil { - return nil, err - } + return goanalysis. + NewLinterFromAnalyzer(&analysis.Analyzer{ + Name: linterName, + Doc: `Run exhaustiveness checks on Go "sum types"`, + Run: func(pass *analysis.Pass) (any, error) { + issues, err := runGoCheckSumType(pass, settings) + if err != nil { + return nil, err + } + + if len(issues) == 0 { + return nil, nil + } + + mu.Lock() + resIssues = append(resIssues, issues...) + mu.Unlock() - if len(issues) == 0 { return nil, nil - } - - mu.Lock() - resIssues = append(resIssues, issues...) - mu.Unlock() - - return nil, nil - }, - } - - return goanalysis.NewLinter( - linterName, - `Run exhaustiveness checks on Go "sum types"`, - []*analysis.Analyzer{analyzer}, - nil, - ).WithIssuesReporter(func(_ *linter.Context) []goanalysis.Issue { - return resIssues - }).WithLoadMode(goanalysis.LoadModeTypesInfo) + }, + }). + WithIssuesReporter(func(_ *linter.Context) []goanalysis.Issue { + return resIssues + }). + WithLoadMode(goanalysis.LoadModeTypesInfo) } func runGoCheckSumType(pass *analysis.Pass, settings *config.GoChecksumTypeSettings) ([]goanalysis.Issue, error) { diff --git a/pkg/golinters/gocognit/gocognit.go b/pkg/golinters/gocognit/gocognit.go index 689a70a12383..e60bcfb17080 100644 --- a/pkg/golinters/gocognit/gocognit.go +++ b/pkg/golinters/gocognit/gocognit.go @@ -21,32 +21,28 @@ func New(settings *config.GocognitSettings) *goanalysis.Linter { var mu sync.Mutex var resIssues []goanalysis.Issue - analyzer := &analysis.Analyzer{ - Name: goanalysis.TheOnlyAnalyzerName, - Doc: goanalysis.TheOnlyanalyzerDoc, - Run: func(pass *analysis.Pass) (any, error) { - issues := runGocognit(pass, settings) + return goanalysis. + NewLinterFromAnalyzer(&analysis.Analyzer{ + Name: linterName, + Doc: "Computes and checks the cognitive complexity of functions", + Run: func(pass *analysis.Pass) (any, error) { + issues := runGocognit(pass, settings) - if len(issues) == 0 { - return nil, nil - } - - mu.Lock() - resIssues = append(resIssues, issues...) - mu.Unlock() + if len(issues) == 0 { + return nil, nil + } - return nil, nil - }, - } + mu.Lock() + resIssues = append(resIssues, issues...) + mu.Unlock() - return goanalysis.NewLinter( - linterName, - "Computes and checks the cognitive complexity of functions", - []*analysis.Analyzer{analyzer}, - nil, - ).WithIssuesReporter(func(*linter.Context) []goanalysis.Issue { - return resIssues - }).WithLoadMode(goanalysis.LoadModeSyntax) + return nil, nil + }, + }). + WithIssuesReporter(func(*linter.Context) []goanalysis.Issue { + return resIssues + }). + WithLoadMode(goanalysis.LoadModeSyntax) } func runGocognit(pass *analysis.Pass, settings *config.GocognitSettings) []goanalysis.Issue { diff --git a/pkg/golinters/goconst/goconst.go b/pkg/golinters/goconst/goconst.go index f3af64625243..f32a4c6575e2 100644 --- a/pkg/golinters/goconst/goconst.go +++ b/pkg/golinters/goconst/goconst.go @@ -20,35 +20,31 @@ func New(settings *config.GoConstSettings) *goanalysis.Linter { var mu sync.Mutex var resIssues []goanalysis.Issue - analyzer := &analysis.Analyzer{ - Name: linterName, - Doc: goanalysis.TheOnlyanalyzerDoc, - Run: func(pass *analysis.Pass) (any, error) { - issues, err := runGoconst(pass, settings) - if err != nil { - return nil, err - } + return goanalysis. + NewLinterFromAnalyzer(&analysis.Analyzer{ + Name: linterName, + Doc: "Finds repeated strings that could be replaced by a constant", + Run: func(pass *analysis.Pass) (any, error) { + issues, err := runGoconst(pass, settings) + if err != nil { + return nil, err + } + + if len(issues) == 0 { + return nil, nil + } + + mu.Lock() + resIssues = append(resIssues, issues...) + mu.Unlock() - if len(issues) == 0 { return nil, nil - } - - mu.Lock() - resIssues = append(resIssues, issues...) - mu.Unlock() - - return nil, nil - }, - } - - return goanalysis.NewLinter( - linterName, - "Finds repeated strings that could be replaced by a constant", - []*analysis.Analyzer{analyzer}, - nil, - ).WithIssuesReporter(func(*linter.Context) []goanalysis.Issue { - return resIssues - }).WithLoadMode(goanalysis.LoadModeTypesInfo) + }, + }). + WithIssuesReporter(func(*linter.Context) []goanalysis.Issue { + return resIssues + }). + WithLoadMode(goanalysis.LoadModeTypesInfo) } func runGoconst(pass *analysis.Pass, settings *config.GoConstSettings) ([]goanalysis.Issue, error) { diff --git a/pkg/golinters/gocritic/gocritic.go b/pkg/golinters/gocritic/gocritic.go index 486303dab0c6..cd7337590cfd 100644 --- a/pkg/golinters/gocritic/gocritic.go +++ b/pkg/golinters/gocritic/gocritic.go @@ -33,27 +33,21 @@ func New(settings *config.GoCriticSettings, replacer *strings.Replacer) *goanaly sizes: types.SizesFor("gc", runtime.GOARCH), } - analyzer := &analysis.Analyzer{ - Name: linterName, - Doc: goanalysis.TheOnlyanalyzerDoc, - Run: func(pass *analysis.Pass) (any, error) { - err := wrapper.run(pass) - if err != nil { - return nil, err - } - - return nil, nil - }, - } - - return goanalysis.NewLinter( - linterName, - `Provides diagnostics that check for bugs, performance and style issues. + return goanalysis. + NewLinterFromAnalyzer(&analysis.Analyzer{ + Name: linterName, + Doc: `Provides diagnostics that check for bugs, performance and style issues. Extensible without recompilation through dynamic rules. Dynamic rules are written declaratively with AST patterns, filters, report message and optional suggestion.`, - []*analysis.Analyzer{analyzer}, - nil, - ). + Run: func(pass *analysis.Pass) (any, error) { + err := wrapper.run(pass) + if err != nil { + return nil, err + } + + return nil, nil + }, + }). WithContextSetter(func(context *linter.Context) { wrapper.init(context.Log, settings, replacer) }). diff --git a/pkg/golinters/gocyclo/gocyclo.go b/pkg/golinters/gocyclo/gocyclo.go index 05691695d2aa..514194709385 100644 --- a/pkg/golinters/gocyclo/gocyclo.go +++ b/pkg/golinters/gocyclo/gocyclo.go @@ -20,32 +20,28 @@ func New(settings *config.GoCycloSettings) *goanalysis.Linter { var mu sync.Mutex var resIssues []goanalysis.Issue - analyzer := &analysis.Analyzer{ - Name: linterName, - Doc: goanalysis.TheOnlyanalyzerDoc, - Run: func(pass *analysis.Pass) (any, error) { - issues := runGoCyclo(pass, settings) + return goanalysis. + NewLinterFromAnalyzer(&analysis.Analyzer{ + Name: linterName, + Doc: "Computes and checks the cyclomatic complexity of functions", + Run: func(pass *analysis.Pass) (any, error) { + issues := runGoCyclo(pass, settings) - if len(issues) == 0 { - return nil, nil - } - - mu.Lock() - resIssues = append(resIssues, issues...) - mu.Unlock() + if len(issues) == 0 { + return nil, nil + } - return nil, nil - }, - } + mu.Lock() + resIssues = append(resIssues, issues...) + mu.Unlock() - return goanalysis.NewLinter( - linterName, - "Computes and checks the cyclomatic complexity of functions", - []*analysis.Analyzer{analyzer}, - nil, - ).WithIssuesReporter(func(*linter.Context) []goanalysis.Issue { - return resIssues - }).WithLoadMode(goanalysis.LoadModeSyntax) + return nil, nil + }, + }). + WithIssuesReporter(func(*linter.Context) []goanalysis.Issue { + return resIssues + }). + WithLoadMode(goanalysis.LoadModeSyntax) } func runGoCyclo(pass *analysis.Pass, settings *config.GoCycloSettings) []goanalysis.Issue { diff --git a/pkg/golinters/godot/godot.go b/pkg/golinters/godot/godot.go index 04e86211de33..e83495128e4c 100644 --- a/pkg/golinters/godot/godot.go +++ b/pkg/golinters/godot/godot.go @@ -10,8 +10,6 @@ import ( "github.com/golangci/golangci-lint/v2/pkg/goanalysis" ) -const linterName = "godot" - func New(settings *config.GodotSettings) *goanalysis.Linter { var dotSettings godot.Settings @@ -26,25 +24,20 @@ func New(settings *config.GodotSettings) *goanalysis.Linter { dotSettings.Scope = cmp.Or(dotSettings.Scope, godot.DeclScope) - analyzer := &analysis.Analyzer{ - Name: linterName, - Doc: goanalysis.TheOnlyanalyzerDoc, - Run: func(pass *analysis.Pass) (any, error) { - err := runGodot(pass, dotSettings) - if err != nil { - return nil, err - } - - return nil, nil - }, - } - - return goanalysis.NewLinter( - linterName, - "Check if comments end in a period", - []*analysis.Analyzer{analyzer}, - nil, - ).WithLoadMode(goanalysis.LoadModeSyntax) + return goanalysis. + NewLinterFromAnalyzer(&analysis.Analyzer{ + Name: "godot", + Doc: "Check if comments end in a period", + Run: func(pass *analysis.Pass) (any, error) { + err := runGodot(pass, dotSettings) + if err != nil { + return nil, err + } + + return nil, nil + }, + }). + WithLoadMode(goanalysis.LoadModeSyntax) } func runGodot(pass *analysis.Pass, settings godot.Settings) error { diff --git a/pkg/golinters/godox/godox.go b/pkg/golinters/godox/godox.go index e734c691b3da..8ab144e754a1 100644 --- a/pkg/golinters/godox/godox.go +++ b/pkg/golinters/godox/godox.go @@ -11,23 +11,16 @@ import ( "github.com/golangci/golangci-lint/v2/pkg/goanalysis" ) -const linterName = "godox" - func New(settings *config.GodoxSettings) *goanalysis.Linter { - analyzer := &analysis.Analyzer{ - Name: linterName, - Doc: goanalysis.TheOnlyanalyzerDoc, - Run: func(pass *analysis.Pass) (any, error) { - return run(pass, settings), nil - }, - } - - return goanalysis.NewLinter( - linterName, - "Detects usage of FIXME, TODO and other keywords inside comments", - []*analysis.Analyzer{analyzer}, - nil, - ).WithLoadMode(goanalysis.LoadModeSyntax) + return goanalysis. + NewLinterFromAnalyzer(&analysis.Analyzer{ + Name: "godox", + Doc: "Detects usage of FIXME, TODO and other keywords inside comments", + Run: func(pass *analysis.Pass) (any, error) { + return run(pass, settings), nil + }, + }). + WithLoadMode(goanalysis.LoadModeSyntax) } func run(pass *analysis.Pass, settings *config.GodoxSettings) error { diff --git a/pkg/golinters/gofmt/gofmt.go b/pkg/golinters/gofmt/gofmt.go index 63b690018ecd..04de51efc0f1 100644 --- a/pkg/golinters/gofmt/gofmt.go +++ b/pkg/golinters/gofmt/gofmt.go @@ -1,8 +1,6 @@ package gofmt import ( - "golang.org/x/tools/go/analysis" - "github.com/golangci/golangci-lint/v2/pkg/config" "github.com/golangci/golangci-lint/v2/pkg/goanalysis" "github.com/golangci/golangci-lint/v2/pkg/goformatters" @@ -10,19 +8,14 @@ import ( "github.com/golangci/golangci-lint/v2/pkg/golinters/internal" ) -const linterName = "gofmt" - func New(settings *config.GoFmtSettings) *goanalysis.Linter { - a := goformatters.NewAnalyzer( - internal.LinterLogger.Child(linterName), - "Checks if the code is formatted according to 'gofmt' command.", - gofmtbase.New(settings), - ) - - return goanalysis.NewLinter( - a.Name, - a.Doc, - []*analysis.Analyzer{a}, - nil, - ).WithLoadMode(goanalysis.LoadModeSyntax) + return goanalysis. + NewLinterFromAnalyzer( + goformatters.NewAnalyzer( + internal.LinterLogger.Child(gofmtbase.Name), + "Check if the code is formatted according to 'gofmt' command.", + gofmtbase.New(settings), + ), + ). + WithLoadMode(goanalysis.LoadModeSyntax) } diff --git a/pkg/golinters/gofumpt/gofumpt.go b/pkg/golinters/gofumpt/gofumpt.go index d799be7a39fd..1ee7c833a321 100644 --- a/pkg/golinters/gofumpt/gofumpt.go +++ b/pkg/golinters/gofumpt/gofumpt.go @@ -1,8 +1,6 @@ package gofumpt import ( - "golang.org/x/tools/go/analysis" - "github.com/golangci/golangci-lint/v2/pkg/config" "github.com/golangci/golangci-lint/v2/pkg/goanalysis" "github.com/golangci/golangci-lint/v2/pkg/goformatters" @@ -10,19 +8,14 @@ import ( "github.com/golangci/golangci-lint/v2/pkg/golinters/internal" ) -const linterName = "gofumpt" - func New(settings *config.GoFumptSettings) *goanalysis.Linter { - a := goformatters.NewAnalyzer( - internal.LinterLogger.Child(linterName), - "Checks if code and import statements are formatted, with additional rules.", - gofumptbase.New(settings, settings.LangVersion), - ) - - return goanalysis.NewLinter( - a.Name, - a.Doc, - []*analysis.Analyzer{a}, - nil, - ).WithLoadMode(goanalysis.LoadModeSyntax) + return goanalysis. + NewLinterFromAnalyzer( + goformatters.NewAnalyzer( + internal.LinterLogger.Child(gofumptbase.Name), + "Check if code and import statements are formatted, with additional rules.", + gofumptbase.New(settings, settings.LangVersion), + ), + ). + WithLoadMode(goanalysis.LoadModeSyntax) } diff --git a/pkg/golinters/goheader/goheader.go b/pkg/golinters/goheader/goheader.go index e03d3277d2c7..0634dbd4288f 100644 --- a/pkg/golinters/goheader/goheader.go +++ b/pkg/golinters/goheader/goheader.go @@ -23,25 +23,20 @@ func New(settings *config.GoHeaderSettings, replacer *strings.Replacer) *goanaly } } - analyzer := &analysis.Analyzer{ - Name: linterName, - Doc: goanalysis.TheOnlyanalyzerDoc, - Run: func(pass *analysis.Pass) (any, error) { - err := runGoHeader(pass, conf) - if err != nil { - return nil, err - } - - return nil, nil - }, - } - - return goanalysis.NewLinter( - linterName, - "Checks if file header matches to pattern", - []*analysis.Analyzer{analyzer}, - nil, - ).WithLoadMode(goanalysis.LoadModeSyntax) + return goanalysis. + NewLinterFromAnalyzer(&analysis.Analyzer{ + Name: linterName, + Doc: "Check if file header matches to pattern", + Run: func(pass *analysis.Pass) (any, error) { + err := runGoHeader(pass, conf) + if err != nil { + return nil, err + } + + return nil, nil + }, + }). + WithLoadMode(goanalysis.LoadModeSyntax) } func runGoHeader(pass *analysis.Pass, conf *goheader.Configuration) error { diff --git a/pkg/golinters/goimports/goimports.go b/pkg/golinters/goimports/goimports.go index 3aa8cde56a94..b3b9b5800b8d 100644 --- a/pkg/golinters/goimports/goimports.go +++ b/pkg/golinters/goimports/goimports.go @@ -1,8 +1,6 @@ package goimports import ( - "golang.org/x/tools/go/analysis" - "github.com/golangci/golangci-lint/v2/pkg/config" "github.com/golangci/golangci-lint/v2/pkg/goanalysis" "github.com/golangci/golangci-lint/v2/pkg/goformatters" @@ -10,19 +8,14 @@ import ( "github.com/golangci/golangci-lint/v2/pkg/golinters/internal" ) -const linterName = "goimports" - func New(settings *config.GoImportsSettings) *goanalysis.Linter { - a := goformatters.NewAnalyzer( - internal.LinterLogger.Child(linterName), - "Checks if the code and import statements are formatted according to the 'goimports' command.", - goimportsbase.New(settings), - ) - - return goanalysis.NewLinter( - a.Name, - a.Doc, - []*analysis.Analyzer{a}, - nil, - ).WithLoadMode(goanalysis.LoadModeSyntax) + return goanalysis. + NewLinterFromAnalyzer( + goformatters.NewAnalyzer( + internal.LinterLogger.Child(goimportsbase.Name), + "Checks if the code and import statements are formatted according to the 'goimports' command.", + goimportsbase.New(settings), + ), + ). + WithLoadMode(goanalysis.LoadModeSyntax) } diff --git a/pkg/golinters/golines/golines.go b/pkg/golinters/golines/golines.go index 0b3acc53bb40..0a32971dee1d 100644 --- a/pkg/golinters/golines/golines.go +++ b/pkg/golinters/golines/golines.go @@ -1,8 +1,6 @@ package golines import ( - "golang.org/x/tools/go/analysis" - "github.com/golangci/golangci-lint/v2/pkg/config" "github.com/golangci/golangci-lint/v2/pkg/goanalysis" "github.com/golangci/golangci-lint/v2/pkg/goformatters" @@ -10,19 +8,14 @@ import ( "github.com/golangci/golangci-lint/v2/pkg/golinters/internal" ) -const linterName = "golines" - func New(settings *config.GoLinesSettings) *goanalysis.Linter { - a := goformatters.NewAnalyzer( - internal.LinterLogger.Child(linterName), - "Checks if code is formatted, and fixes long lines", - golinesbase.New(settings), - ) - - return goanalysis.NewLinter( - a.Name, - a.Doc, - []*analysis.Analyzer{a}, - nil, - ).WithLoadMode(goanalysis.LoadModeSyntax) + return goanalysis. + NewLinterFromAnalyzer( + goformatters.NewAnalyzer( + internal.LinterLogger.Child(golinesbase.Name), + "Checks if code is formatted, and fixes long lines", + golinesbase.New(settings), + ), + ). + WithLoadMode(goanalysis.LoadModeSyntax) } diff --git a/pkg/golinters/gomoddirectives/gomoddirectives.go b/pkg/golinters/gomoddirectives/gomoddirectives.go index 86f94e2560ea..e11313a62b9c 100644 --- a/pkg/golinters/gomoddirectives/gomoddirectives.go +++ b/pkg/golinters/gomoddirectives/gomoddirectives.go @@ -50,38 +50,37 @@ func New(settings *config.GoModDirectivesSettings) *goanalysis.Linter { } analyzer := &analysis.Analyzer{ - Name: goanalysis.TheOnlyAnalyzerName, - Doc: goanalysis.TheOnlyanalyzerDoc, + Name: linterName, + Doc: "Manage the use of 'replace', 'retract', and 'excludes' directives in go.mod.", Run: goanalysis.DummyRun, } - return goanalysis.NewLinter( - linterName, - "Manage the use of 'replace', 'retract', and 'excludes' directives in go.mod.", - []*analysis.Analyzer{analyzer}, - nil, - ).WithContextSetter(func(lintCtx *linter.Context) { - analyzer.Run = func(pass *analysis.Pass) (any, error) { - once.Do(func() { - results, err := gomoddirectives.AnalyzePass(pass, opts) - if err != nil { - lintCtx.Log.Warnf("running %s failed: %s: "+ - "if you are not using go modules it is suggested to disable this linter", linterName, err) - return - } + return goanalysis. + NewLinterFromAnalyzer(analyzer). + WithContextSetter(func(lintCtx *linter.Context) { + analyzer.Run = func(pass *analysis.Pass) (any, error) { + once.Do(func() { + results, err := gomoddirectives.AnalyzePass(pass, opts) + if err != nil { + lintCtx.Log.Warnf("running %s failed: %s: "+ + "if you are not using go modules it is suggested to disable this linter", linterName, err) + return + } - for _, p := range results { - issues = append(issues, goanalysis.NewIssue(&result.Issue{ - FromLinter: linterName, - Pos: p.Start, - Text: p.Reason, - }, pass)) - } - }) + for _, p := range results { + issues = append(issues, goanalysis.NewIssue(&result.Issue{ + FromLinter: linterName, + Pos: p.Start, + Text: p.Reason, + }, pass)) + } + }) - return nil, nil - } - }).WithIssuesReporter(func(*linter.Context) []goanalysis.Issue { - return issues - }).WithLoadMode(goanalysis.LoadModeSyntax) + return nil, nil + } + }). + WithIssuesReporter(func(*linter.Context) []goanalysis.Issue { + return issues + }). + WithLoadMode(goanalysis.LoadModeSyntax) } diff --git a/pkg/golinters/gomodguard/gomodguard.go b/pkg/golinters/gomodguard/gomodguard.go index e38a6c9b90e4..502610341342 100644 --- a/pkg/golinters/gomodguard/gomodguard.go +++ b/pkg/golinters/gomodguard/gomodguard.go @@ -13,12 +13,7 @@ import ( "github.com/golangci/golangci-lint/v2/pkg/result" ) -const ( - name = "gomodguard" - desc = "Allow and block list linter for direct Go module dependencies. " + - "This is different from depguard where there are different block " + - "types for example version constraints and module recommendations." -) +const linterName = "gomodguard" func New(settings *config.GoModGuardSettings) *goanalysis.Linter { var issues []goanalysis.Issue @@ -54,41 +49,41 @@ func New(settings *config.GoModGuardSettings) *goanalysis.Linter { } analyzer := &analysis.Analyzer{ - Name: goanalysis.TheOnlyAnalyzerName, - Doc: goanalysis.TheOnlyanalyzerDoc, - Run: goanalysis.DummyRun, + Name: linterName, + Doc: "Allow and blocklist linter for direct Go module dependencies. " + + "This is different from depguard where there are different block " + + "types for example version constraints and module recommendations.", + Run: goanalysis.DummyRun, } - return goanalysis.NewLinter( - name, - desc, - []*analysis.Analyzer{analyzer}, - nil, - ).WithContextSetter(func(lintCtx *linter.Context) { - processor, err := gomodguard.NewProcessor(processorCfg) - if err != nil { - lintCtx.Log.Warnf("running gomodguard failed: %s: if you are not using go modules "+ - "it is suggested to disable this linter", err) - return - } + return goanalysis.NewLinterFromAnalyzer(analyzer). + WithContextSetter(func(lintCtx *linter.Context) { + processor, err := gomodguard.NewProcessor(processorCfg) + if err != nil { + lintCtx.Log.Warnf("running gomodguard failed: %s: if you are not using go modules "+ + "it is suggested to disable this linter", err) + return + } - analyzer.Run = func(pass *analysis.Pass) (any, error) { - gomodguardIssues := processor.ProcessFiles(internal.GetGoFileNames(pass)) + analyzer.Run = func(pass *analysis.Pass) (any, error) { + gomodguardIssues := processor.ProcessFiles(internal.GetGoFileNames(pass)) - mu.Lock() - defer mu.Unlock() + mu.Lock() + defer mu.Unlock() - for _, gomodguardIssue := range gomodguardIssues { - issues = append(issues, goanalysis.NewIssue(&result.Issue{ - FromLinter: name, - Pos: gomodguardIssue.Position, - Text: gomodguardIssue.Reason, - }, pass)) - } + for _, gomodguardIssue := range gomodguardIssues { + issues = append(issues, goanalysis.NewIssue(&result.Issue{ + FromLinter: linterName, + Pos: gomodguardIssue.Position, + Text: gomodguardIssue.Reason, + }, pass)) + } - return nil, nil - } - }).WithIssuesReporter(func(*linter.Context) []goanalysis.Issue { - return issues - }).WithLoadMode(goanalysis.LoadModeSyntax) + return nil, nil + } + }). + WithIssuesReporter(func(*linter.Context) []goanalysis.Issue { + return issues + }). + WithLoadMode(goanalysis.LoadModeSyntax) } diff --git a/pkg/golinters/goprintffuncname/goprintffuncname.go b/pkg/golinters/goprintffuncname/goprintffuncname.go index b1436347806c..a56dce8e05df 100644 --- a/pkg/golinters/goprintffuncname/goprintffuncname.go +++ b/pkg/golinters/goprintffuncname/goprintffuncname.go @@ -2,18 +2,12 @@ package goprintffuncname import ( "github.com/golangci/go-printf-func-name/pkg/analyzer" - "golang.org/x/tools/go/analysis" "github.com/golangci/golangci-lint/v2/pkg/goanalysis" ) func New() *goanalysis.Linter { - a := analyzer.Analyzer - - return goanalysis.NewLinter( - a.Name, - a.Doc, - []*analysis.Analyzer{a}, - nil, - ).WithLoadMode(goanalysis.LoadModeSyntax) + return goanalysis. + NewLinterFromAnalyzer(analyzer.Analyzer). + WithLoadMode(goanalysis.LoadModeSyntax) } diff --git a/pkg/golinters/gosec/gosec.go b/pkg/golinters/gosec/gosec.go index 95b445e87038..e38de1ee20e5 100644 --- a/pkg/golinters/gosec/gosec.go +++ b/pkg/golinters/gosec/gosec.go @@ -50,34 +50,33 @@ func New(settings *config.GoSecSettings) *goanalysis.Linter { analyzer := &analysis.Analyzer{ Name: linterName, - Doc: goanalysis.TheOnlyanalyzerDoc, + Doc: "Inspects source code for security problems", Run: goanalysis.DummyRun, } - return goanalysis.NewLinter( - linterName, - "Inspects source code for security problems", - []*analysis.Analyzer{analyzer}, - nil, - ).WithContextSetter(func(lintCtx *linter.Context) { - analyzer.Run = func(pass *analysis.Pass) (any, error) { - // The `gosecAnalyzer` is here because of concurrency issue. - gosecAnalyzer := gosec.NewAnalyzer(conf, true, false, false, settings.Concurrency, logger) + return goanalysis. + NewLinterFromAnalyzer(analyzer). + WithContextSetter(func(lintCtx *linter.Context) { + analyzer.Run = func(pass *analysis.Pass) (any, error) { + // The `gosecAnalyzer` is here because of concurrency issue. + gosecAnalyzer := gosec.NewAnalyzer(conf, true, false, false, settings.Concurrency, logger) - gosecAnalyzer.LoadRules(ruleDefinitions.RulesInfo()) - gosecAnalyzer.LoadAnalyzers(analyzerDefinitions.AnalyzersInfo()) + gosecAnalyzer.LoadRules(ruleDefinitions.RulesInfo()) + gosecAnalyzer.LoadAnalyzers(analyzerDefinitions.AnalyzersInfo()) - issues := runGoSec(lintCtx, pass, settings, gosecAnalyzer) + issues := runGoSec(lintCtx, pass, settings, gosecAnalyzer) - mu.Lock() - resIssues = append(resIssues, issues...) - mu.Unlock() + mu.Lock() + resIssues = append(resIssues, issues...) + mu.Unlock() - return nil, nil - } - }).WithIssuesReporter(func(*linter.Context) []goanalysis.Issue { - return resIssues - }).WithLoadMode(goanalysis.LoadModeTypesInfo) + return nil, nil + } + }). + WithIssuesReporter(func(*linter.Context) []goanalysis.Issue { + return resIssues + }). + WithLoadMode(goanalysis.LoadModeTypesInfo) } func runGoSec(lintCtx *linter.Context, pass *analysis.Pass, settings *config.GoSecSettings, analyzer *gosec.Analyzer) []goanalysis.Issue { diff --git a/pkg/golinters/gosmopolitan/gosmopolitan.go b/pkg/golinters/gosmopolitan/gosmopolitan.go index 6c574403f694..76261abe1450 100644 --- a/pkg/golinters/gosmopolitan/gosmopolitan.go +++ b/pkg/golinters/gosmopolitan/gosmopolitan.go @@ -4,18 +4,16 @@ import ( "strings" "github.com/xen0n/gosmopolitan" - "golang.org/x/tools/go/analysis" "github.com/golangci/golangci-lint/v2/pkg/config" "github.com/golangci/golangci-lint/v2/pkg/goanalysis" ) func New(settings *config.GosmopolitanSettings) *goanalysis.Linter { - a := gosmopolitan.NewAnalyzer() + var cfg map[string]any - cfg := map[string]map[string]any{} if settings != nil { - cfg[a.Name] = map[string]any{ + cfg = map[string]any{ "allowtimelocal": settings.AllowTimeLocal, "escapehatches": strings.Join(settings.EscapeHatches, ","), "watchforscripts": strings.Join(settings.WatchForScripts, ","), @@ -25,10 +23,8 @@ func New(settings *config.GosmopolitanSettings) *goanalysis.Linter { } } - return goanalysis.NewLinter( - a.Name, - a.Doc, - []*analysis.Analyzer{a}, - cfg, - ).WithLoadMode(goanalysis.LoadModeTypesInfo) + return goanalysis. + NewLinterFromAnalyzer(gosmopolitan.NewAnalyzer()). + WithConfig(cfg). + WithLoadMode(goanalysis.LoadModeTypesInfo) } diff --git a/pkg/golinters/grouper/grouper.go b/pkg/golinters/grouper/grouper.go index 853e2d3e7f70..ed3601617d9a 100644 --- a/pkg/golinters/grouper/grouper.go +++ b/pkg/golinters/grouper/grouper.go @@ -2,18 +2,16 @@ package grouper import ( grouper "github.com/leonklingele/grouper/pkg/analyzer" - "golang.org/x/tools/go/analysis" "github.com/golangci/golangci-lint/v2/pkg/config" "github.com/golangci/golangci-lint/v2/pkg/goanalysis" ) func New(settings *config.GrouperSettings) *goanalysis.Linter { - a := grouper.New() + var cfg map[string]any - cfg := map[string]map[string]any{} if settings != nil { - cfg[a.Name] = map[string]any{ + cfg = map[string]any{ "const-require-single-const": settings.ConstRequireSingleConst, "const-require-grouping": settings.ConstRequireGrouping, "import-require-single-import": settings.ImportRequireSingleImport, @@ -24,11 +22,9 @@ func New(settings *config.GrouperSettings) *goanalysis.Linter { "var-require-grouping": settings.VarRequireGrouping, } } - - return goanalysis.NewLinter( - a.Name, - "Analyze expression groups.", - []*analysis.Analyzer{a}, - cfg, - ).WithLoadMode(goanalysis.LoadModeSyntax) + return goanalysis. + NewLinterFromAnalyzer(grouper.New()). + WithDesc("Analyze expression groups."). + WithConfig(cfg). + WithLoadMode(goanalysis.LoadModeSyntax) } diff --git a/pkg/golinters/importas/importas.go b/pkg/golinters/importas/importas.go index a86db68ce04e..fa7a54300e29 100644 --- a/pkg/golinters/importas/importas.go +++ b/pkg/golinters/importas/importas.go @@ -6,7 +6,6 @@ import ( "strings" "github.com/julz/importas" - "golang.org/x/tools/go/analysis" "github.com/golangci/golangci-lint/v2/pkg/config" "github.com/golangci/golangci-lint/v2/pkg/goanalysis" @@ -16,55 +15,53 @@ import ( func New(settings *config.ImportAsSettings) *goanalysis.Linter { analyzer := importas.Analyzer - return goanalysis.NewLinter( - analyzer.Name, - analyzer.Doc, - []*analysis.Analyzer{analyzer}, - nil, - ).WithContextSetter(func(lintCtx *linter.Context) { - if settings == nil { - return - } - if len(settings.Alias) == 0 { - lintCtx.Log.Infof("importas settings found, but no aliases listed. List aliases under alias: key.") - } - - if err := analyzer.Flags.Set("no-unaliased", strconv.FormatBool(settings.NoUnaliased)); err != nil { - lintCtx.Log.Errorf("failed to parse configuration: %v", err) - } - - if err := analyzer.Flags.Set("no-extra-aliases", strconv.FormatBool(settings.NoExtraAliases)); err != nil { - lintCtx.Log.Errorf("failed to parse configuration: %v", err) - } - - uniqPackages := make(map[string]config.ImportAsAlias) - uniqAliases := make(map[string]config.ImportAsAlias) - for _, a := range settings.Alias { - if a.Pkg == "" { - lintCtx.Log.Errorf("invalid configuration, empty package: pkg=%s alias=%s", a.Pkg, a.Alias) - continue + return goanalysis. + NewLinterFromAnalyzer(analyzer). + WithContextSetter(func(lintCtx *linter.Context) { + if settings == nil { + return } - - if v, ok := uniqPackages[a.Pkg]; ok { - lintCtx.Log.Errorf("invalid configuration, multiple aliases for the same package: pkg=%s aliases=[%s,%s]", a.Pkg, a.Alias, v.Alias) - } else { - uniqPackages[a.Pkg] = a + if len(settings.Alias) == 0 { + lintCtx.Log.Infof("importas settings found, but no aliases listed. List aliases under alias: key.") } - // Skips the duplication check when: - // - the alias is empty. - // - the alias is a regular expression replacement pattern (ie. contains `$`). - v, ok := uniqAliases[a.Alias] - if ok && a.Alias != "" && !strings.Contains(a.Alias, "$") { - lintCtx.Log.Errorf("invalid configuration, multiple packages with the same alias: alias=%s packages=[%s,%s]", a.Alias, a.Pkg, v.Pkg) - } else { - uniqAliases[a.Alias] = a + if err := analyzer.Flags.Set("no-unaliased", strconv.FormatBool(settings.NoUnaliased)); err != nil { + lintCtx.Log.Errorf("failed to parse configuration: %v", err) } - err := analyzer.Flags.Set("alias", fmt.Sprintf("%s:%s", a.Pkg, a.Alias)) - if err != nil { + if err := analyzer.Flags.Set("no-extra-aliases", strconv.FormatBool(settings.NoExtraAliases)); err != nil { lintCtx.Log.Errorf("failed to parse configuration: %v", err) } - } - }).WithLoadMode(goanalysis.LoadModeTypesInfo) + + uniqPackages := make(map[string]config.ImportAsAlias) + uniqAliases := make(map[string]config.ImportAsAlias) + for _, a := range settings.Alias { + if a.Pkg == "" { + lintCtx.Log.Errorf("invalid configuration, empty package: pkg=%s alias=%s", a.Pkg, a.Alias) + continue + } + + if v, ok := uniqPackages[a.Pkg]; ok { + lintCtx.Log.Errorf("invalid configuration, multiple aliases for the same package: pkg=%s aliases=[%s,%s]", a.Pkg, a.Alias, v.Alias) + } else { + uniqPackages[a.Pkg] = a + } + + // Skips the duplication check when: + // - the alias is empty. + // - the alias is a regular expression replacement pattern (ie. contains `$`). + v, ok := uniqAliases[a.Alias] + if ok && a.Alias != "" && !strings.Contains(a.Alias, "$") { + lintCtx.Log.Errorf("invalid configuration, multiple packages with the same alias: alias=%s packages=[%s,%s]", a.Alias, a.Pkg, v.Pkg) + } else { + uniqAliases[a.Alias] = a + } + + err := analyzer.Flags.Set("alias", fmt.Sprintf("%s:%s", a.Pkg, a.Alias)) + if err != nil { + lintCtx.Log.Errorf("failed to parse configuration: %v", err) + } + } + }). + WithLoadMode(goanalysis.LoadModeTypesInfo) } diff --git a/pkg/golinters/inamedparam/inamedparam.go b/pkg/golinters/inamedparam/inamedparam.go index 0a67c970deca..ecb6f7e5024f 100644 --- a/pkg/golinters/inamedparam/inamedparam.go +++ b/pkg/golinters/inamedparam/inamedparam.go @@ -2,29 +2,22 @@ package inamedparam import ( "github.com/macabu/inamedparam" - "golang.org/x/tools/go/analysis" "github.com/golangci/golangci-lint/v2/pkg/config" "github.com/golangci/golangci-lint/v2/pkg/goanalysis" ) func New(settings *config.INamedParamSettings) *goanalysis.Linter { - a := inamedparam.Analyzer - - var cfg map[string]map[string]any + var cfg map[string]any if settings != nil { - cfg = map[string]map[string]any{ - a.Name: { - "skip-single-param": settings.SkipSingleParam, - }, + cfg = map[string]any{ + "skip-single-param": settings.SkipSingleParam, } } - return goanalysis.NewLinter( - a.Name, - a.Doc, - []*analysis.Analyzer{a}, - cfg, - ).WithLoadMode(goanalysis.LoadModeSyntax) + return goanalysis. + NewLinterFromAnalyzer(inamedparam.Analyzer). + WithConfig(cfg). + WithLoadMode(goanalysis.LoadModeSyntax) } diff --git a/pkg/golinters/ineffassign/ineffassign.go b/pkg/golinters/ineffassign/ineffassign.go index bbe01ba1f37a..2c0119f1032f 100644 --- a/pkg/golinters/ineffassign/ineffassign.go +++ b/pkg/golinters/ineffassign/ineffassign.go @@ -2,18 +2,13 @@ package ineffassign import ( "github.com/gordonklaus/ineffassign/pkg/ineffassign" - "golang.org/x/tools/go/analysis" "github.com/golangci/golangci-lint/v2/pkg/goanalysis" ) func New() *goanalysis.Linter { - a := ineffassign.Analyzer - - return goanalysis.NewLinter( - a.Name, - "Detects when assignments to existing variables are not used", - []*analysis.Analyzer{a}, - nil, - ).WithLoadMode(goanalysis.LoadModeSyntax) + return goanalysis. + NewLinterFromAnalyzer(ineffassign.Analyzer). + WithDesc("Detects when assignments to existing variables are not used"). + WithLoadMode(goanalysis.LoadModeSyntax) } diff --git a/pkg/golinters/interfacebloat/interfacebloat.go b/pkg/golinters/interfacebloat/interfacebloat.go index fbafb3ac7343..f2e187423278 100644 --- a/pkg/golinters/interfacebloat/interfacebloat.go +++ b/pkg/golinters/interfacebloat/interfacebloat.go @@ -2,28 +2,22 @@ package interfacebloat import ( "github.com/sashamelentyev/interfacebloat/pkg/analyzer" - "golang.org/x/tools/go/analysis" "github.com/golangci/golangci-lint/v2/pkg/config" "github.com/golangci/golangci-lint/v2/pkg/goanalysis" ) func New(settings *config.InterfaceBloatSettings) *goanalysis.Linter { - a := analyzer.New() + var cfg map[string]any - var cfg map[string]map[string]any if settings != nil { - cfg = map[string]map[string]any{ - a.Name: { - analyzer.InterfaceMaxMethodsFlag: settings.Max, - }, + cfg = map[string]any{ + analyzer.InterfaceMaxMethodsFlag: settings.Max, } } - return goanalysis.NewLinter( - a.Name, - a.Doc, - []*analysis.Analyzer{a}, - cfg, - ).WithLoadMode(goanalysis.LoadModeSyntax) + return goanalysis. + NewLinterFromAnalyzer(analyzer.New()). + WithConfig(cfg). + WithLoadMode(goanalysis.LoadModeSyntax) } diff --git a/pkg/golinters/intrange/intrange.go b/pkg/golinters/intrange/intrange.go index c75be9b63446..1ff02964cbe5 100644 --- a/pkg/golinters/intrange/intrange.go +++ b/pkg/golinters/intrange/intrange.go @@ -2,18 +2,12 @@ package intrange import ( "github.com/ckaznocha/intrange" - "golang.org/x/tools/go/analysis" "github.com/golangci/golangci-lint/v2/pkg/goanalysis" ) func New() *goanalysis.Linter { - a := intrange.Analyzer - - return goanalysis.NewLinter( - a.Name, - a.Doc, - []*analysis.Analyzer{a}, - nil, - ).WithLoadMode(goanalysis.LoadModeTypesInfo) + return goanalysis. + NewLinterFromAnalyzer(intrange.Analyzer). + WithLoadMode(goanalysis.LoadModeTypesInfo) } diff --git a/pkg/golinters/ireturn/ireturn.go b/pkg/golinters/ireturn/ireturn.go index 44c28700b370..b9cce0001842 100644 --- a/pkg/golinters/ireturn/ireturn.go +++ b/pkg/golinters/ireturn/ireturn.go @@ -4,28 +4,24 @@ import ( "strings" "github.com/butuzov/ireturn/analyzer" - "golang.org/x/tools/go/analysis" "github.com/golangci/golangci-lint/v2/pkg/config" "github.com/golangci/golangci-lint/v2/pkg/goanalysis" ) func New(settings *config.IreturnSettings) *goanalysis.Linter { - a := analyzer.NewAnalyzer() + var cfg map[string]any - cfg := map[string]map[string]any{} if settings != nil { - cfg[a.Name] = map[string]any{ + cfg = map[string]any{ "allow": strings.Join(settings.Allow, ","), "reject": strings.Join(settings.Reject, ","), "nonolint": true, } } - return goanalysis.NewLinter( - a.Name, - a.Doc, - []*analysis.Analyzer{a}, - cfg, - ).WithLoadMode(goanalysis.LoadModeTypesInfo) + return goanalysis. + NewLinterFromAnalyzer(analyzer.NewAnalyzer()). + WithConfig(cfg). + WithLoadMode(goanalysis.LoadModeTypesInfo) } diff --git a/pkg/golinters/lll/lll.go b/pkg/golinters/lll/lll.go index eb435baa754c..c8e6717dea82 100644 --- a/pkg/golinters/lll/lll.go +++ b/pkg/golinters/lll/lll.go @@ -15,30 +15,23 @@ import ( "github.com/golangci/golangci-lint/v2/pkg/goanalysis" ) -const linterName = "lll" - const goCommentDirectivePrefix = "//go:" func New(settings *config.LllSettings) *goanalysis.Linter { - analyzer := &analysis.Analyzer{ - Name: linterName, - Doc: goanalysis.TheOnlyanalyzerDoc, - Run: func(pass *analysis.Pass) (any, error) { - err := runLll(pass, settings) - if err != nil { - return nil, err - } - - return nil, nil - }, - } - - return goanalysis.NewLinter( - linterName, - "Reports long lines", - []*analysis.Analyzer{analyzer}, - nil, - ).WithLoadMode(goanalysis.LoadModeSyntax) + return goanalysis. + NewLinterFromAnalyzer(&analysis.Analyzer{ + Name: "lll", + Doc: "Reports long lines", + Run: func(pass *analysis.Pass) (any, error) { + err := runLll(pass, settings) + if err != nil { + return nil, err + } + + return nil, nil + }, + }). + WithLoadMode(goanalysis.LoadModeSyntax) } func runLll(pass *analysis.Pass, settings *config.LllSettings) error { diff --git a/pkg/golinters/loggercheck/loggercheck.go b/pkg/golinters/loggercheck/loggercheck.go index a5dd4da48cd6..b9a6efa75fad 100644 --- a/pkg/golinters/loggercheck/loggercheck.go +++ b/pkg/golinters/loggercheck/loggercheck.go @@ -2,7 +2,6 @@ package loggercheck import ( "github.com/timonwong/loggercheck" - "golang.org/x/tools/go/analysis" "github.com/golangci/golangci-lint/v2/pkg/config" "github.com/golangci/golangci-lint/v2/pkg/goanalysis" @@ -37,11 +36,7 @@ func New(settings *config.LoggerCheckSettings) *goanalysis.Linter { } } - analyzer := loggercheck.NewAnalyzer(opts...) - return goanalysis.NewLinter( - analyzer.Name, - analyzer.Doc, - []*analysis.Analyzer{analyzer}, - nil, - ).WithLoadMode(goanalysis.LoadModeTypesInfo) + return goanalysis. + NewLinterFromAnalyzer(loggercheck.NewAnalyzer(opts...)). + WithLoadMode(goanalysis.LoadModeTypesInfo) } diff --git a/pkg/golinters/maintidx/maintidx.go b/pkg/golinters/maintidx/maintidx.go index 4e541f888dfa..f2076c8ab030 100644 --- a/pkg/golinters/maintidx/maintidx.go +++ b/pkg/golinters/maintidx/maintidx.go @@ -2,29 +2,22 @@ package maintidx import ( "github.com/yagipy/maintidx" - "golang.org/x/tools/go/analysis" "github.com/golangci/golangci-lint/v2/pkg/config" "github.com/golangci/golangci-lint/v2/pkg/goanalysis" ) func New(settings *config.MaintIdxSettings) *goanalysis.Linter { - analyzer := maintidx.Analyzer - - cfg := map[string]map[string]any{ - analyzer.Name: {"under": 20}, + cfg := map[string]any{ + "under": 20, } if settings != nil { - cfg[analyzer.Name] = map[string]any{ - "under": settings.Under, - } + cfg["under"] = settings.Under } - return goanalysis.NewLinter( - analyzer.Name, - analyzer.Doc, - []*analysis.Analyzer{analyzer}, - cfg, - ).WithLoadMode(goanalysis.LoadModeSyntax) + return goanalysis. + NewLinterFromAnalyzer(maintidx.Analyzer). + WithConfig(cfg). + WithLoadMode(goanalysis.LoadModeSyntax) } diff --git a/pkg/golinters/makezero/makezero.go b/pkg/golinters/makezero/makezero.go index 8b86f120679e..5ee298d99f4e 100644 --- a/pkg/golinters/makezero/makezero.go +++ b/pkg/golinters/makezero/makezero.go @@ -10,28 +10,21 @@ import ( "github.com/golangci/golangci-lint/v2/pkg/goanalysis" ) -const linterName = "makezero" - func New(settings *config.MakezeroSettings) *goanalysis.Linter { - analyzer := &analysis.Analyzer{ - Name: linterName, - Doc: goanalysis.TheOnlyanalyzerDoc, - Run: func(pass *analysis.Pass) (any, error) { - err := runMakeZero(pass, settings) - if err != nil { - return nil, err - } - - return nil, nil - }, - } - - return goanalysis.NewLinter( - linterName, - "Finds slice declarations with non-zero initial length", - []*analysis.Analyzer{analyzer}, - nil, - ).WithLoadMode(goanalysis.LoadModeTypesInfo) + return goanalysis. + NewLinterFromAnalyzer(&analysis.Analyzer{ + Name: "makezero", + Doc: "Find slice declarations with non-zero initial length", + Run: func(pass *analysis.Pass) (any, error) { + err := runMakeZero(pass, settings) + if err != nil { + return nil, err + } + + return nil, nil + }, + }). + WithLoadMode(goanalysis.LoadModeTypesInfo) } func runMakeZero(pass *analysis.Pass, settings *config.MakezeroSettings) error { diff --git a/pkg/golinters/mirror/mirror.go b/pkg/golinters/mirror/mirror.go index 9badb0c1ed68..07cfe25e4e44 100644 --- a/pkg/golinters/mirror/mirror.go +++ b/pkg/golinters/mirror/mirror.go @@ -2,29 +2,22 @@ package mirror import ( "github.com/butuzov/mirror" - "golang.org/x/tools/go/analysis" "github.com/golangci/golangci-lint/v2/pkg/goanalysis" ) func New() *goanalysis.Linter { - a := mirror.NewAnalyzer() - // mirror only lints test files if the `--with-tests` flag is passed, // so we pass the `with-tests` flag as true to the analyzer before running it. // This can be turned off by using the regular golangci-lint flags such as `--tests` or `--skip-files` // or can be disabled per linter via exclude rules. // (see https://github.com/golangci/golangci-lint/issues/2527#issuecomment-1023707262) - linterCfg := map[string]map[string]any{ - a.Name: { - "with-tests": true, - }, + cfg := map[string]any{ + "with-tests": true, } - return goanalysis.NewLinter( - a.Name, - a.Doc, - []*analysis.Analyzer{a}, - linterCfg, - ).WithLoadMode(goanalysis.LoadModeTypesInfo) + return goanalysis. + NewLinterFromAnalyzer(mirror.NewAnalyzer()). + WithConfig(cfg). + WithLoadMode(goanalysis.LoadModeTypesInfo) } diff --git a/pkg/golinters/misspell/misspell.go b/pkg/golinters/misspell/misspell.go index 9a170c9537b7..cbf378505b47 100644 --- a/pkg/golinters/misspell/misspell.go +++ b/pkg/golinters/misspell/misspell.go @@ -23,27 +23,22 @@ func New(settings *config.MisspellSettings) *goanalysis.Linter { internal.LinterLogger.Fatalf("%s: %v", linterName, err) } - a := &analysis.Analyzer{ - Name: linterName, - Doc: "Finds commonly misspelled English words", - Run: func(pass *analysis.Pass) (any, error) { - for _, file := range pass.Files { - err := runMisspellOnFile(pass, file, replacer, settings.Mode) - if err != nil { - return nil, err + return goanalysis. + NewLinterFromAnalyzer(&analysis.Analyzer{ + Name: linterName, + Doc: "Finds commonly misspelled English words", + Run: func(pass *analysis.Pass) (any, error) { + for _, file := range pass.Files { + err := runMisspellOnFile(pass, file, replacer, settings.Mode) + if err != nil { + return nil, err + } } - } - return nil, nil - }, - } - - return goanalysis.NewLinter( - a.Name, - a.Doc, - []*analysis.Analyzer{a}, - nil, - ).WithLoadMode(goanalysis.LoadModeSyntax) + return nil, nil + }, + }). + WithLoadMode(goanalysis.LoadModeSyntax) } func createMisspellReplacer(settings *config.MisspellSettings) (*misspell.Replacer, error) { diff --git a/pkg/golinters/mnd/mnd.go b/pkg/golinters/mnd/mnd.go index 52521e92dd15..07174c899f57 100644 --- a/pkg/golinters/mnd/mnd.go +++ b/pkg/golinters/mnd/mnd.go @@ -2,18 +2,15 @@ package mnd import ( mnd "github.com/tommy-muehle/go-mnd/v2" - "golang.org/x/tools/go/analysis" "github.com/golangci/golangci-lint/v2/pkg/config" "github.com/golangci/golangci-lint/v2/pkg/goanalysis" ) func New(settings *config.MndSettings) *goanalysis.Linter { - a := mnd.Analyzer + cfg := map[string]any{} - var linterCfg map[string]map[string]any if settings != nil { - cfg := make(map[string]any) if len(settings.Checks) > 0 { cfg["checks"] = settings.Checks } @@ -26,16 +23,11 @@ func New(settings *config.MndSettings) *goanalysis.Linter { if len(settings.IgnoredFunctions) > 0 { cfg["ignored-functions"] = settings.IgnoredFunctions } - - linterCfg = map[string]map[string]any{ - a.Name: cfg, - } } - return goanalysis.NewLinter( - a.Name, - "An analyzer to detect magic numbers.", - []*analysis.Analyzer{a}, - linterCfg, - ).WithLoadMode(goanalysis.LoadModeSyntax) + return goanalysis. + NewLinterFromAnalyzer(mnd.Analyzer). + WithDesc("An analyzer to detect magic numbers."). + WithConfig(cfg). + WithLoadMode(goanalysis.LoadModeSyntax) } diff --git a/pkg/golinters/musttag/musttag.go b/pkg/golinters/musttag/musttag.go index 030707327b7f..d17df9c2b8d9 100644 --- a/pkg/golinters/musttag/musttag.go +++ b/pkg/golinters/musttag/musttag.go @@ -2,7 +2,6 @@ package musttag import ( "go-simpler.org/musttag" - "golang.org/x/tools/go/analysis" "github.com/golangci/golangci-lint/v2/pkg/config" "github.com/golangci/golangci-lint/v2/pkg/goanalysis" @@ -21,9 +20,7 @@ func New(settings *config.MustTagSettings) *goanalysis.Linter { } } - a := musttag.New(funcs...) - return goanalysis. - NewLinter(a.Name, a.Doc, []*analysis.Analyzer{a}, nil). + NewLinterFromAnalyzer(musttag.New(funcs...)). WithLoadMode(goanalysis.LoadModeTypesInfo) } diff --git a/pkg/golinters/nakedret/nakedret.go b/pkg/golinters/nakedret/nakedret.go index 1b769acd8c8d..90053a1aab98 100644 --- a/pkg/golinters/nakedret/nakedret.go +++ b/pkg/golinters/nakedret/nakedret.go @@ -2,7 +2,6 @@ package nakedret import ( "github.com/alexkohler/nakedret/v2" - "golang.org/x/tools/go/analysis" "github.com/golangci/golangci-lint/v2/pkg/config" "github.com/golangci/golangci-lint/v2/pkg/goanalysis" @@ -16,12 +15,7 @@ func New(settings *config.NakedretSettings) *goanalysis.Linter { cfg.MaxLength = settings.MaxFuncLines } - a := nakedret.NakedReturnAnalyzer(cfg) - - return goanalysis.NewLinter( - a.Name, - a.Doc, - []*analysis.Analyzer{a}, - nil, - ).WithLoadMode(goanalysis.LoadModeSyntax) + return goanalysis. + NewLinterFromAnalyzer(nakedret.NakedReturnAnalyzer(cfg)). + WithLoadMode(goanalysis.LoadModeSyntax) } diff --git a/pkg/golinters/nestif/nestif.go b/pkg/golinters/nestif/nestif.go index 1a6b55cafc22..e5823723c83a 100644 --- a/pkg/golinters/nestif/nestif.go +++ b/pkg/golinters/nestif/nestif.go @@ -8,25 +8,18 @@ import ( "github.com/golangci/golangci-lint/v2/pkg/goanalysis" ) -const linterName = "nestif" - func New(settings *config.NestifSettings) *goanalysis.Linter { - analyzer := &analysis.Analyzer{ - Name: linterName, - Doc: goanalysis.TheOnlyanalyzerDoc, - Run: func(pass *analysis.Pass) (any, error) { - runNestIf(pass, settings) - - return nil, nil - }, - } - - return goanalysis.NewLinter( - linterName, - "Reports deeply nested if statements", - []*analysis.Analyzer{analyzer}, - nil, - ).WithLoadMode(goanalysis.LoadModeSyntax) + return goanalysis. + NewLinterFromAnalyzer(&analysis.Analyzer{ + Name: "nestif", + Doc: "Reports deeply nested if statements", + Run: func(pass *analysis.Pass) (any, error) { + runNestIf(pass, settings) + + return nil, nil + }, + }). + WithLoadMode(goanalysis.LoadModeSyntax) } func runNestIf(pass *analysis.Pass, settings *config.NestifSettings) { diff --git a/pkg/golinters/nilerr/nilerr.go b/pkg/golinters/nilerr/nilerr.go index 9345b945be11..fa5dcdc259fc 100644 --- a/pkg/golinters/nilerr/nilerr.go +++ b/pkg/golinters/nilerr/nilerr.go @@ -2,18 +2,13 @@ package nilerr import ( "github.com/gostaticanalysis/nilerr" - "golang.org/x/tools/go/analysis" "github.com/golangci/golangci-lint/v2/pkg/goanalysis" ) func New() *goanalysis.Linter { - a := nilerr.Analyzer - - return goanalysis.NewLinter( - a.Name, - "Finds the code that returns nil even if it checks that the error is not nil.", - []*analysis.Analyzer{a}, - nil, - ).WithLoadMode(goanalysis.LoadModeTypesInfo) + return goanalysis. + NewLinterFromAnalyzer(nilerr.Analyzer). + WithDesc("Find the code that returns nil even if it checks that the error is not nil."). + WithLoadMode(goanalysis.LoadModeTypesInfo) } diff --git a/pkg/golinters/nilnesserr/nilnesserr.go b/pkg/golinters/nilnesserr/nilnesserr.go index b54992e29bb5..95eaf94abe25 100644 --- a/pkg/golinters/nilnesserr/nilnesserr.go +++ b/pkg/golinters/nilnesserr/nilnesserr.go @@ -2,22 +2,18 @@ package nilnesserr import ( "github.com/alingse/nilnesserr" - "golang.org/x/tools/go/analysis" "github.com/golangci/golangci-lint/v2/pkg/goanalysis" "github.com/golangci/golangci-lint/v2/pkg/golinters/internal" ) func New() *goanalysis.Linter { - a, err := nilnesserr.NewAnalyzer(nilnesserr.LinterSetting{}) + analyzer, err := nilnesserr.NewAnalyzer(nilnesserr.LinterSetting{}) if err != nil { internal.LinterLogger.Fatalf("nilnesserr: create analyzer: %v", err) } - return goanalysis.NewLinter( - a.Name, - a.Doc, - []*analysis.Analyzer{a}, - nil, - ).WithLoadMode(goanalysis.LoadModeTypesInfo) + return goanalysis. + NewLinterFromAnalyzer(analyzer). + WithLoadMode(goanalysis.LoadModeTypesInfo) } diff --git a/pkg/golinters/nilnil/nilnil.go b/pkg/golinters/nilnil/nilnil.go index 5f42e24c96fc..4936a6b84c8f 100644 --- a/pkg/golinters/nilnil/nilnil.go +++ b/pkg/golinters/nilnil/nilnil.go @@ -2,33 +2,28 @@ package nilnil import ( "github.com/Antonboom/nilnil/pkg/analyzer" - "golang.org/x/tools/go/analysis" "github.com/golangci/golangci-lint/v2/pkg/config" "github.com/golangci/golangci-lint/v2/pkg/goanalysis" ) func New(settings *config.NilNilSettings) *goanalysis.Linter { - a := analyzer.New() + var cfg map[string]any - cfg := make(map[string]map[string]any) if settings != nil { - cfg[a.Name] = map[string]any{ + cfg = map[string]any{ "detect-opposite": settings.DetectOpposite, } if b := settings.OnlyTwo; b != nil { - cfg[a.Name]["only-two"] = *b + cfg["only-two"] = *b } if len(settings.CheckedTypes) != 0 { - cfg[a.Name]["checked-types"] = settings.CheckedTypes + cfg["checked-types"] = settings.CheckedTypes } } - return goanalysis.NewLinter( - a.Name, - a.Doc, - []*analysis.Analyzer{a}, - cfg, - ). + return goanalysis. + NewLinterFromAnalyzer(analyzer.New()). + WithConfig(cfg). WithLoadMode(goanalysis.LoadModeTypesInfo) } diff --git a/pkg/golinters/nlreturn/nlreturn.go b/pkg/golinters/nlreturn/nlreturn.go index ce2130c52c81..7b7ab745ad7b 100644 --- a/pkg/golinters/nlreturn/nlreturn.go +++ b/pkg/golinters/nlreturn/nlreturn.go @@ -2,26 +2,22 @@ package nlreturn import ( "github.com/ssgreg/nlreturn/v2/pkg/nlreturn" - "golang.org/x/tools/go/analysis" "github.com/golangci/golangci-lint/v2/pkg/config" "github.com/golangci/golangci-lint/v2/pkg/goanalysis" ) func New(settings *config.NlreturnSettings) *goanalysis.Linter { - a := nlreturn.NewAnalyzer() + var cfg map[string]any - cfg := map[string]map[string]any{} if settings != nil { - cfg[a.Name] = map[string]any{ + cfg = map[string]any{ "block-size": settings.BlockSize, } } - - return goanalysis.NewLinter( - a.Name, - "nlreturn checks for a new line before return and branch statements to increase code clarity", - []*analysis.Analyzer{a}, - cfg, - ).WithLoadMode(goanalysis.LoadModeSyntax) + return goanalysis. + NewLinterFromAnalyzer(nlreturn.NewAnalyzer()). + WithDesc("Checks for a new line before return and branch statements to increase code clarity"). + WithConfig(cfg). + WithLoadMode(goanalysis.LoadModeSyntax) } diff --git a/pkg/golinters/noctx/noctx.go b/pkg/golinters/noctx/noctx.go index 18391d4b5581..c3e5be104262 100644 --- a/pkg/golinters/noctx/noctx.go +++ b/pkg/golinters/noctx/noctx.go @@ -2,18 +2,13 @@ package noctx import ( "github.com/sonatard/noctx" - "golang.org/x/tools/go/analysis" "github.com/golangci/golangci-lint/v2/pkg/goanalysis" ) func New() *goanalysis.Linter { - a := noctx.Analyzer - - return goanalysis.NewLinter( - a.Name, - "Detects function and method with missing usage of context.Context", - []*analysis.Analyzer{a}, - nil, - ).WithLoadMode(goanalysis.LoadModeTypesInfo) + return goanalysis. + NewLinterFromAnalyzer(noctx.Analyzer). + WithDesc("Detects function and method with missing usage of context.Context"). + WithLoadMode(goanalysis.LoadModeTypesInfo) } diff --git a/pkg/golinters/nolintlint/nolintlint.go b/pkg/golinters/nolintlint/nolintlint.go index f19b8324c295..37f9cb96aac7 100644 --- a/pkg/golinters/nolintlint/nolintlint.go +++ b/pkg/golinters/nolintlint/nolintlint.go @@ -35,33 +35,29 @@ func New(settings *config.NoLintLintSettings) *goanalysis.Linter { internal.LinterLogger.Fatalf("%s: create analyzer: %v", nolintlint.LinterName, err) } - analyzer := &analysis.Analyzer{ - Name: nolintlint.LinterName, - Doc: goanalysis.TheOnlyanalyzerDoc, - Run: func(pass *analysis.Pass) (any, error) { - issues, err := lnt.Run(pass) - if err != nil { - return nil, fmt.Errorf("linter failed to run: %w", err) - } + return goanalysis. + NewLinterFromAnalyzer(&analysis.Analyzer{ + Name: nolintlint.LinterName, + Doc: "Reports ill-formed or insufficient nolint directives", + Run: func(pass *analysis.Pass) (any, error) { + issues, err := lnt.Run(pass) + if err != nil { + return nil, fmt.Errorf("linter failed to run: %w", err) + } + + if len(issues) == 0 { + return nil, nil + } + + mu.Lock() + resIssues = append(resIssues, issues...) + mu.Unlock() - if len(issues) == 0 { return nil, nil - } - - mu.Lock() - resIssues = append(resIssues, issues...) - mu.Unlock() - - return nil, nil - }, - } - - return goanalysis.NewLinter( - nolintlint.LinterName, - "Reports ill-formed or insufficient nolint directives", - []*analysis.Analyzer{analyzer}, - nil, - ).WithIssuesReporter(func(*linter.Context) []goanalysis.Issue { - return resIssues - }).WithLoadMode(goanalysis.LoadModeSyntax) + }, + }). + WithIssuesReporter(func(*linter.Context) []goanalysis.Issue { + return resIssues + }). + WithLoadMode(goanalysis.LoadModeSyntax) } diff --git a/pkg/golinters/nonamedreturns/nonamedreturns.go b/pkg/golinters/nonamedreturns/nonamedreturns.go index 91354f6a4492..4149ef818e20 100644 --- a/pkg/golinters/nonamedreturns/nonamedreturns.go +++ b/pkg/golinters/nonamedreturns/nonamedreturns.go @@ -2,28 +2,22 @@ package nonamedreturns import ( "github.com/firefart/nonamedreturns/analyzer" - "golang.org/x/tools/go/analysis" "github.com/golangci/golangci-lint/v2/pkg/config" "github.com/golangci/golangci-lint/v2/pkg/goanalysis" ) func New(settings *config.NoNamedReturnsSettings) *goanalysis.Linter { - a := analyzer.Analyzer + var cfg map[string]any - var cfg map[string]map[string]any if settings != nil { - cfg = map[string]map[string]any{ - a.Name: { - analyzer.FlagReportErrorInDefer: settings.ReportErrorInDefer, - }, + cfg = map[string]any{ + analyzer.FlagReportErrorInDefer: settings.ReportErrorInDefer, } } - return goanalysis.NewLinter( - a.Name, - a.Doc, - []*analysis.Analyzer{a}, - cfg, - ).WithLoadMode(goanalysis.LoadModeTypesInfo) + return goanalysis. + NewLinterFromAnalyzer(analyzer.Analyzer). + WithConfig(cfg). + WithLoadMode(goanalysis.LoadModeTypesInfo) } diff --git a/pkg/golinters/nosprintfhostport/nosprintfhostport.go b/pkg/golinters/nosprintfhostport/nosprintfhostport.go index cca70680cf6c..f8ca26b738c9 100644 --- a/pkg/golinters/nosprintfhostport/nosprintfhostport.go +++ b/pkg/golinters/nosprintfhostport/nosprintfhostport.go @@ -2,18 +2,12 @@ package nosprintfhostport import ( "github.com/stbenjam/no-sprintf-host-port/pkg/analyzer" - "golang.org/x/tools/go/analysis" "github.com/golangci/golangci-lint/v2/pkg/goanalysis" ) func New() *goanalysis.Linter { - a := analyzer.Analyzer - - return goanalysis.NewLinter( - a.Name, - a.Doc, - []*analysis.Analyzer{a}, - nil, - ).WithLoadMode(goanalysis.LoadModeSyntax) + return goanalysis. + NewLinterFromAnalyzer(analyzer.Analyzer). + WithLoadMode(goanalysis.LoadModeSyntax) } diff --git a/pkg/golinters/paralleltest/paralleltest.go b/pkg/golinters/paralleltest/paralleltest.go index 8c811ca511af..f3eac2e05afb 100644 --- a/pkg/golinters/paralleltest/paralleltest.go +++ b/pkg/golinters/paralleltest/paralleltest.go @@ -2,33 +2,28 @@ package paralleltest import ( "github.com/kunwardeep/paralleltest/pkg/paralleltest" - "golang.org/x/tools/go/analysis" "github.com/golangci/golangci-lint/v2/pkg/config" "github.com/golangci/golangci-lint/v2/pkg/goanalysis" ) func New(settings *config.ParallelTestSettings) *goanalysis.Linter { - a := paralleltest.NewAnalyzer() + var cfg map[string]any - var cfg map[string]map[string]any if settings != nil { - d := map[string]any{ + cfg = map[string]any{ "i": settings.IgnoreMissing, "ignoremissingsubtests": settings.IgnoreMissingSubtests, } if config.IsGoGreaterThanOrEqual(settings.Go, "1.22") { - d["ignoreloopVar"] = true + cfg["ignoreloopVar"] = true } - - cfg = map[string]map[string]any{a.Name: d} } - return goanalysis.NewLinter( - a.Name, - "Detects missing usage of t.Parallel() method in your Go test", - []*analysis.Analyzer{a}, - cfg, - ).WithLoadMode(goanalysis.LoadModeTypesInfo) + return goanalysis. + NewLinterFromAnalyzer(paralleltest.NewAnalyzer()). + WithDesc("Detects missing usage of t.Parallel() method in your Go test"). + WithConfig(cfg). + WithLoadMode(goanalysis.LoadModeTypesInfo) } diff --git a/pkg/golinters/perfsprint/perfsprint.go b/pkg/golinters/perfsprint/perfsprint.go index f870ee00115a..9684c27c6639 100644 --- a/pkg/golinters/perfsprint/perfsprint.go +++ b/pkg/golinters/perfsprint/perfsprint.go @@ -2,41 +2,36 @@ package perfsprint import ( "github.com/catenacyber/perfsprint/analyzer" - "golang.org/x/tools/go/analysis" "github.com/golangci/golangci-lint/v2/pkg/config" "github.com/golangci/golangci-lint/v2/pkg/goanalysis" ) func New(settings *config.PerfSprintSettings) *goanalysis.Linter { - a := analyzer.New() - - cfg := map[string]map[string]any{ - a.Name: {"fiximports": false}, + cfg := map[string]any{ + "fiximports": false, } if settings != nil { // NOTE: The option `ignore-tests` is not handled because it should be managed with `linters.exclusions.rules` - cfg[a.Name]["integer-format"] = settings.IntegerFormat - cfg[a.Name]["int-conversion"] = settings.IntConversion + cfg["integer-format"] = settings.IntegerFormat + cfg["int-conversion"] = settings.IntConversion - cfg[a.Name]["error-format"] = settings.ErrorFormat - cfg[a.Name]["err-error"] = settings.ErrError - cfg[a.Name]["errorf"] = settings.ErrorF + cfg["error-format"] = settings.ErrorFormat + cfg["err-error"] = settings.ErrError + cfg["errorf"] = settings.ErrorF - cfg[a.Name]["string-format"] = settings.StringFormat - cfg[a.Name]["sprintf1"] = settings.SprintF1 - cfg[a.Name]["strconcat"] = settings.StrConcat + cfg["string-format"] = settings.StringFormat + cfg["sprintf1"] = settings.SprintF1 + cfg["strconcat"] = settings.StrConcat - cfg[a.Name]["bool-format"] = settings.BoolFormat - cfg[a.Name]["hex-format"] = settings.HexFormat + cfg["bool-format"] = settings.BoolFormat + cfg["hex-format"] = settings.HexFormat } - return goanalysis.NewLinter( - a.Name, - a.Doc, - []*analysis.Analyzer{a}, - cfg, - ).WithLoadMode(goanalysis.LoadModeTypesInfo) + return goanalysis. + NewLinterFromAnalyzer(analyzer.New()). + WithConfig(cfg). + WithLoadMode(goanalysis.LoadModeTypesInfo) } diff --git a/pkg/golinters/prealloc/prealloc.go b/pkg/golinters/prealloc/prealloc.go index 1ceba6007ce0..66890ad5bc61 100644 --- a/pkg/golinters/prealloc/prealloc.go +++ b/pkg/golinters/prealloc/prealloc.go @@ -11,25 +11,18 @@ import ( "github.com/golangci/golangci-lint/v2/pkg/golinters/internal" ) -const linterName = "prealloc" - func New(settings *config.PreallocSettings) *goanalysis.Linter { - analyzer := &analysis.Analyzer{ - Name: linterName, - Doc: goanalysis.TheOnlyanalyzerDoc, - Run: func(pass *analysis.Pass) (any, error) { - runPreAlloc(pass, settings) - - return nil, nil - }, - } - - return goanalysis.NewLinter( - linterName, - "Finds slice declarations that could potentially be pre-allocated", - []*analysis.Analyzer{analyzer}, - nil, - ).WithLoadMode(goanalysis.LoadModeSyntax) + return goanalysis. + NewLinterFromAnalyzer(&analysis.Analyzer{ + Name: "prealloc", + Doc: "Find slice declarations that could potentially be pre-allocated", + Run: func(pass *analysis.Pass) (any, error) { + runPreAlloc(pass, settings) + + return nil, nil + }, + }). + WithLoadMode(goanalysis.LoadModeSyntax) } func runPreAlloc(pass *analysis.Pass, settings *config.PreallocSettings) { diff --git a/pkg/golinters/predeclared/predeclared.go b/pkg/golinters/predeclared/predeclared.go index 9bde9d2f3baa..8f2be53c4fc1 100644 --- a/pkg/golinters/predeclared/predeclared.go +++ b/pkg/golinters/predeclared/predeclared.go @@ -4,25 +4,23 @@ import ( "strings" "github.com/nishanths/predeclared/passes/predeclared" - "golang.org/x/tools/go/analysis" "github.com/golangci/golangci-lint/v2/pkg/config" "github.com/golangci/golangci-lint/v2/pkg/goanalysis" ) func New(settings *config.PredeclaredSettings) *goanalysis.Linter { - a := predeclared.Analyzer + var cfg map[string]any - var cfg map[string]map[string]any if settings != nil { - cfg = map[string]map[string]any{ - a.Name: { - predeclared.IgnoreFlag: strings.Join(settings.Ignore, ","), - predeclared.QualifiedFlag: settings.Qualified, - }, + cfg = map[string]any{ + predeclared.IgnoreFlag: strings.Join(settings.Ignore, ","), + predeclared.QualifiedFlag: settings.Qualified, } } - return goanalysis.NewLinter(a.Name, a.Doc, []*analysis.Analyzer{a}, cfg). + return goanalysis. + NewLinterFromAnalyzer(predeclared.Analyzer). + WithConfig(cfg). WithLoadMode(goanalysis.LoadModeSyntax) } diff --git a/pkg/golinters/promlinter/promlinter.go b/pkg/golinters/promlinter/promlinter.go index ab2c9c569dea..2cb59cbe6f1a 100644 --- a/pkg/golinters/promlinter/promlinter.go +++ b/pkg/golinters/promlinter/promlinter.go @@ -27,32 +27,28 @@ func New(settings *config.PromlinterSettings) *goanalysis.Linter { } } - analyzer := &analysis.Analyzer{ - Name: linterName, - Doc: goanalysis.TheOnlyanalyzerDoc, - Run: func(pass *analysis.Pass) (any, error) { - issues := runPromLinter(pass, promSettings) + return goanalysis. + NewLinterFromAnalyzer(&analysis.Analyzer{ + Name: linterName, + Doc: "Check Prometheus metrics naming via promlint", + Run: func(pass *analysis.Pass) (any, error) { + issues := runPromLinter(pass, promSettings) - if len(issues) == 0 { - return nil, nil - } - - mu.Lock() - resIssues = append(resIssues, issues...) - mu.Unlock() + if len(issues) == 0 { + return nil, nil + } - return nil, nil - }, - } + mu.Lock() + resIssues = append(resIssues, issues...) + mu.Unlock() - return goanalysis.NewLinter( - linterName, - "Check Prometheus metrics naming via promlint", - []*analysis.Analyzer{analyzer}, - nil, - ).WithIssuesReporter(func(*linter.Context) []goanalysis.Issue { - return resIssues - }).WithLoadMode(goanalysis.LoadModeSyntax) + return nil, nil + }, + }). + WithIssuesReporter(func(*linter.Context) []goanalysis.Issue { + return resIssues + }). + WithLoadMode(goanalysis.LoadModeSyntax) } func runPromLinter(pass *analysis.Pass, promSettings promlinter.Setting) []goanalysis.Issue { diff --git a/pkg/golinters/protogetter/protogetter.go b/pkg/golinters/protogetter/protogetter.go index c13c98af5792..bee5da263915 100644 --- a/pkg/golinters/protogetter/protogetter.go +++ b/pkg/golinters/protogetter/protogetter.go @@ -2,7 +2,6 @@ package protogetter import ( "github.com/ghostiam/protogetter" - "golang.org/x/tools/go/analysis" "github.com/golangci/golangci-lint/v2/pkg/config" "github.com/golangci/golangci-lint/v2/pkg/goanalysis" @@ -10,6 +9,7 @@ import ( func New(settings *config.ProtoGetterSettings) *goanalysis.Linter { var cfg protogetter.Config + if settings != nil { cfg = protogetter.Config{ SkipGeneratedBy: settings.SkipGeneratedBy, @@ -19,12 +19,7 @@ func New(settings *config.ProtoGetterSettings) *goanalysis.Linter { } } - a := protogetter.NewAnalyzer(&cfg) - - return goanalysis.NewLinter( - a.Name, - a.Doc, - []*analysis.Analyzer{a}, - nil, - ).WithLoadMode(goanalysis.LoadModeTypesInfo) + return goanalysis. + NewLinterFromAnalyzer(protogetter.NewAnalyzer(&cfg)). + WithLoadMode(goanalysis.LoadModeTypesInfo) } diff --git a/pkg/golinters/reassign/reassign.go b/pkg/golinters/reassign/reassign.go index 7d9f84285b89..35e661cae84b 100644 --- a/pkg/golinters/reassign/reassign.go +++ b/pkg/golinters/reassign/reassign.go @@ -5,28 +5,22 @@ import ( "strings" "github.com/curioswitch/go-reassign" - "golang.org/x/tools/go/analysis" "github.com/golangci/golangci-lint/v2/pkg/config" "github.com/golangci/golangci-lint/v2/pkg/goanalysis" ) func New(settings *config.ReassignSettings) *goanalysis.Linter { - a := reassign.NewAnalyzer() + var cfg map[string]any - var cfg map[string]map[string]any if settings != nil && len(settings.Patterns) > 0 { - cfg = map[string]map[string]any{ - a.Name: { - reassign.FlagPattern: fmt.Sprintf("^(%s)$", strings.Join(settings.Patterns, "|")), - }, + cfg = map[string]any{ + reassign.FlagPattern: fmt.Sprintf("^(%s)$", strings.Join(settings.Patterns, "|")), } } - return goanalysis.NewLinter( - a.Name, - a.Doc, - []*analysis.Analyzer{a}, - cfg, - ).WithLoadMode(goanalysis.LoadModeTypesInfo) + return goanalysis. + NewLinterFromAnalyzer(reassign.NewAnalyzer()). + WithConfig(cfg). + WithLoadMode(goanalysis.LoadModeTypesInfo) } diff --git a/pkg/golinters/recvcheck/recvcheck.go b/pkg/golinters/recvcheck/recvcheck.go index ed1eb0b78765..76db48f93979 100644 --- a/pkg/golinters/recvcheck/recvcheck.go +++ b/pkg/golinters/recvcheck/recvcheck.go @@ -2,7 +2,6 @@ package recvcheck import ( "github.com/raeperd/recvcheck" - "golang.org/x/tools/go/analysis" "github.com/golangci/golangci-lint/v2/pkg/config" "github.com/golangci/golangci-lint/v2/pkg/goanalysis" @@ -16,12 +15,7 @@ func New(settings *config.RecvcheckSettings) *goanalysis.Linter { cfg.Exclusions = settings.Exclusions } - a := recvcheck.NewAnalyzer(cfg) - - return goanalysis.NewLinter( - a.Name, - a.Doc, - []*analysis.Analyzer{a}, - nil, - ).WithLoadMode(goanalysis.LoadModeTypesInfo) + return goanalysis. + NewLinterFromAnalyzer(recvcheck.NewAnalyzer(cfg)). + WithLoadMode(goanalysis.LoadModeTypesInfo) } diff --git a/pkg/golinters/revive/revive.go b/pkg/golinters/revive/revive.go index 5f9b3a90ace1..32b42ba8314d 100644 --- a/pkg/golinters/revive/revive.go +++ b/pkg/golinters/revive/revive.go @@ -38,42 +38,41 @@ func New(settings *config.ReviveSettings) *goanalysis.Linter { var resIssues []goanalysis.Issue analyzer := &analysis.Analyzer{ - Name: goanalysis.TheOnlyAnalyzerName, - Doc: goanalysis.TheOnlyanalyzerDoc, + Name: linterName, + Doc: "Fast, configurable, extensible, flexible, and beautiful linter for Go. Drop-in replacement of golint.", Run: goanalysis.DummyRun, } - return goanalysis.NewLinter( - linterName, - "Fast, configurable, extensible, flexible, and beautiful linter for Go. Drop-in replacement of golint.", - []*analysis.Analyzer{analyzer}, - nil, - ).WithContextSetter(func(lintCtx *linter.Context) { - w, err := newWrapper(settings) - if err != nil { - lintCtx.Log.Errorf("setup revive: %v", err) - return - } - - analyzer.Run = func(pass *analysis.Pass) (any, error) { - issues, err := w.run(pass) + return goanalysis. + NewLinterFromAnalyzer(analyzer). + WithContextSetter(func(lintCtx *linter.Context) { + w, err := newWrapper(settings) if err != nil { - return nil, err + lintCtx.Log.Errorf("setup revive: %v", err) + return } - if len(issues) == 0 { - return nil, nil - } + analyzer.Run = func(pass *analysis.Pass) (any, error) { + issues, err := w.run(pass) + if err != nil { + return nil, err + } - mu.Lock() - resIssues = append(resIssues, issues...) - mu.Unlock() + if len(issues) == 0 { + return nil, nil + } - return nil, nil - } - }).WithIssuesReporter(func(*linter.Context) []goanalysis.Issue { - return resIssues - }).WithLoadMode(goanalysis.LoadModeSyntax) + mu.Lock() + resIssues = append(resIssues, issues...) + mu.Unlock() + + return nil, nil + } + }). + WithIssuesReporter(func(*linter.Context) []goanalysis.Issue { + return resIssues + }). + WithLoadMode(goanalysis.LoadModeSyntax) } type wrapper struct { diff --git a/pkg/golinters/rowserrcheck/rowserrcheck.go b/pkg/golinters/rowserrcheck/rowserrcheck.go index 2bd975ddf28f..de0fe4da917e 100644 --- a/pkg/golinters/rowserrcheck/rowserrcheck.go +++ b/pkg/golinters/rowserrcheck/rowserrcheck.go @@ -2,7 +2,6 @@ package rowserrcheck import ( "github.com/jingyugao/rowserrcheck/passes/rowserr" - "golang.org/x/tools/go/analysis" "github.com/golangci/golangci-lint/v2/pkg/config" "github.com/golangci/golangci-lint/v2/pkg/goanalysis" @@ -10,16 +9,13 @@ import ( func New(settings *config.RowsErrCheckSettings) *goanalysis.Linter { var pkgs []string + if settings != nil { pkgs = settings.Packages } - a := rowserr.NewAnalyzer(pkgs...) - - return goanalysis.NewLinter( - a.Name, - "checks whether Rows.Err of rows is checked successfully", - []*analysis.Analyzer{a}, - nil, - ).WithLoadMode(goanalysis.LoadModeTypesInfo) + return goanalysis. + NewLinterFromAnalyzer(rowserr.NewAnalyzer(pkgs...)). + WithDesc("checks whether Rows.Err of rows is checked successfully"). + WithLoadMode(goanalysis.LoadModeTypesInfo) } diff --git a/pkg/golinters/sloglint/sloglint.go b/pkg/golinters/sloglint/sloglint.go index 021157dd66b7..891f1fcfdbdf 100644 --- a/pkg/golinters/sloglint/sloglint.go +++ b/pkg/golinters/sloglint/sloglint.go @@ -2,7 +2,6 @@ package sloglint import ( "go-simpler.org/sloglint" - "golang.org/x/tools/go/analysis" "github.com/golangci/golangci-lint/v2/pkg/config" "github.com/golangci/golangci-lint/v2/pkg/goanalysis" @@ -10,6 +9,7 @@ import ( func New(settings *config.SlogLintSettings) *goanalysis.Linter { var opts *sloglint.Options + if settings != nil { opts = &sloglint.Options{ NoMixedArgs: settings.NoMixedArgs, @@ -26,9 +26,7 @@ func New(settings *config.SlogLintSettings) *goanalysis.Linter { } } - a := sloglint.New(opts) - return goanalysis. - NewLinter(a.Name, a.Doc, []*analysis.Analyzer{a}, nil). + NewLinterFromAnalyzer(sloglint.New(opts)). WithLoadMode(goanalysis.LoadModeTypesInfo) } diff --git a/pkg/golinters/spancheck/spancheck.go b/pkg/golinters/spancheck/spancheck.go index 264623058b1e..345c36277447 100644 --- a/pkg/golinters/spancheck/spancheck.go +++ b/pkg/golinters/spancheck/spancheck.go @@ -2,7 +2,6 @@ package spancheck import ( "github.com/jjti/go-spancheck" - "golang.org/x/tools/go/analysis" "github.com/golangci/golangci-lint/v2/pkg/config" "github.com/golangci/golangci-lint/v2/pkg/goanalysis" @@ -25,9 +24,7 @@ func New(settings *config.SpancheckSettings) *goanalysis.Linter { } } - a := spancheck.NewAnalyzerWithConfig(cfg) - return goanalysis. - NewLinter(a.Name, a.Doc, []*analysis.Analyzer{a}, nil). + NewLinterFromAnalyzer(spancheck.NewAnalyzerWithConfig(cfg)). WithLoadMode(goanalysis.LoadModeTypesInfo) } diff --git a/pkg/golinters/sqlclosecheck/sqlclosecheck.go b/pkg/golinters/sqlclosecheck/sqlclosecheck.go index 7f7e70c71401..4c970cc5295d 100644 --- a/pkg/golinters/sqlclosecheck/sqlclosecheck.go +++ b/pkg/golinters/sqlclosecheck/sqlclosecheck.go @@ -2,18 +2,12 @@ package sqlclosecheck import ( "github.com/ryanrolds/sqlclosecheck/pkg/analyzer" - "golang.org/x/tools/go/analysis" "github.com/golangci/golangci-lint/v2/pkg/goanalysis" ) func New() *goanalysis.Linter { - a := analyzer.NewAnalyzer() - - return goanalysis.NewLinter( - a.Name, - a.Doc, - []*analysis.Analyzer{a}, - nil, - ).WithLoadMode(goanalysis.LoadModeTypesInfo) + return goanalysis. + NewLinterFromAnalyzer(analyzer.NewAnalyzer()). + WithLoadMode(goanalysis.LoadModeTypesInfo) } diff --git a/pkg/golinters/swaggo/swaggo.go b/pkg/golinters/swaggo/swaggo.go index 8c4eec8e448d..98f7a6bef4dc 100644 --- a/pkg/golinters/swaggo/swaggo.go +++ b/pkg/golinters/swaggo/swaggo.go @@ -1,23 +1,20 @@ package swaggo import ( - "golang.org/x/tools/go/analysis" - "github.com/golangci/golangci-lint/v2/pkg/goanalysis" "github.com/golangci/golangci-lint/v2/pkg/goformatters" "github.com/golangci/golangci-lint/v2/pkg/goformatters/swaggo" "github.com/golangci/golangci-lint/v2/pkg/golinters/internal" ) -const linterName = "swaggo" - func New() *goanalysis.Linter { - a := goformatters.NewAnalyzer( - internal.LinterLogger.Child(linterName), - "Check if swaggo comments are formatted", - swaggo.New(), - ) - - return goanalysis.NewLinter(a.Name, a.Doc, []*analysis.Analyzer{a}, nil). + return goanalysis. + NewLinterFromAnalyzer( + goformatters.NewAnalyzer( + internal.LinterLogger.Child(swaggo.Name), + "Check if swaggo comments are formatted", + swaggo.New(), + ), + ). WithLoadMode(goanalysis.LoadModeSyntax) } diff --git a/pkg/golinters/tagalign/tagalign.go b/pkg/golinters/tagalign/tagalign.go index 412d69b937ef..eba51311c0cf 100644 --- a/pkg/golinters/tagalign/tagalign.go +++ b/pkg/golinters/tagalign/tagalign.go @@ -2,7 +2,6 @@ package tagalign import ( "github.com/4meepo/tagalign" - "golang.org/x/tools/go/analysis" "github.com/golangci/golangci-lint/v2/pkg/config" "github.com/golangci/golangci-lint/v2/pkg/goanalysis" @@ -24,12 +23,7 @@ func New(settings *config.TagAlignSettings) *goanalysis.Linter { } } - analyzer := tagalign.NewAnalyzer(options...) - - return goanalysis.NewLinter( - analyzer.Name, - analyzer.Doc, - []*analysis.Analyzer{analyzer}, - nil, - ).WithLoadMode(goanalysis.LoadModeSyntax) + return goanalysis. + NewLinterFromAnalyzer(tagalign.NewAnalyzer(options...)). + WithLoadMode(goanalysis.LoadModeSyntax) } diff --git a/pkg/golinters/tagliatelle/tagliatelle.go b/pkg/golinters/tagliatelle/tagliatelle.go index f6357e0e3747..89ebf6c2f4df 100644 --- a/pkg/golinters/tagliatelle/tagliatelle.go +++ b/pkg/golinters/tagliatelle/tagliatelle.go @@ -2,7 +2,6 @@ package tagliatelle import ( "github.com/ldez/tagliatelle" - "golang.org/x/tools/go/analysis" "github.com/golangci/golangci-lint/v2/pkg/config" "github.com/golangci/golangci-lint/v2/pkg/goanalysis" @@ -42,14 +41,9 @@ func New(settings *config.TagliatelleSettings) *goanalysis.Linter { } } - a := tagliatelle.New(cfg) - - return goanalysis.NewLinter( - a.Name, - a.Doc, - []*analysis.Analyzer{a}, - nil, - ).WithLoadMode(goanalysis.LoadModeTypesInfo) + return goanalysis. + NewLinterFromAnalyzer(tagliatelle.New(cfg)). + WithLoadMode(goanalysis.LoadModeTypesInfo) } func toExtendedRules(src map[string]config.TagliatelleExtendedRule) map[string]tagliatelle.ExtendedRule { diff --git a/pkg/golinters/testableexamples/testableexamples.go b/pkg/golinters/testableexamples/testableexamples.go index 38334a096237..45fdc900e2c3 100644 --- a/pkg/golinters/testableexamples/testableexamples.go +++ b/pkg/golinters/testableexamples/testableexamples.go @@ -2,18 +2,12 @@ package testableexamples import ( "github.com/maratori/testableexamples/pkg/testableexamples" - "golang.org/x/tools/go/analysis" "github.com/golangci/golangci-lint/v2/pkg/goanalysis" ) func New() *goanalysis.Linter { - a := testableexamples.NewAnalyzer() - - return goanalysis.NewLinter( - a.Name, - a.Doc, - []*analysis.Analyzer{a}, - nil, - ).WithLoadMode(goanalysis.LoadModeSyntax) + return goanalysis. + NewLinterFromAnalyzer(testableexamples.NewAnalyzer()). + WithLoadMode(goanalysis.LoadModeSyntax) } diff --git a/pkg/golinters/testifylint/testifylint.go b/pkg/golinters/testifylint/testifylint.go index b19471c1ea05..bb5eac0e451e 100644 --- a/pkg/golinters/testifylint/testifylint.go +++ b/pkg/golinters/testifylint/testifylint.go @@ -2,18 +2,16 @@ package testifylint import ( "github.com/Antonboom/testifylint/analyzer" - "golang.org/x/tools/go/analysis" "github.com/golangci/golangci-lint/v2/pkg/config" "github.com/golangci/golangci-lint/v2/pkg/goanalysis" ) func New(settings *config.TestifylintSettings) *goanalysis.Linter { - a := analyzer.New() + var cfg map[string]any - cfg := make(map[string]map[string]any) if settings != nil { - cfg[a.Name] = map[string]any{ + cfg = map[string]any{ "enable-all": settings.EnableAll, "disable-all": settings.DisableAll, @@ -23,30 +21,28 @@ func New(settings *config.TestifylintSettings) *goanalysis.Linter { "go-require.ignore-http-handlers": settings.GoRequire.IgnoreHTTPHandlers, } if len(settings.EnabledCheckers) > 0 { - cfg[a.Name]["enable"] = settings.EnabledCheckers + cfg["enable"] = settings.EnabledCheckers } if len(settings.DisabledCheckers) > 0 { - cfg[a.Name]["disable"] = settings.DisabledCheckers + cfg["disable"] = settings.DisabledCheckers } if b := settings.Formatter.CheckFormatString; b != nil { - cfg[a.Name]["formatter.check-format-string"] = *b + cfg["formatter.check-format-string"] = *b } if p := settings.ExpectedActual.ExpVarPattern; p != "" { - cfg[a.Name]["expected-actual.pattern"] = p + cfg["expected-actual.pattern"] = p } if p := settings.RequireError.FnPattern; p != "" { - cfg[a.Name]["require-error.fn-pattern"] = p + cfg["require-error.fn-pattern"] = p } if m := settings.SuiteExtraAssertCall.Mode; m != "" { - cfg[a.Name]["suite-extra-assert-call.mode"] = m + cfg["suite-extra-assert-call.mode"] = m } } - return goanalysis.NewLinter( - a.Name, - a.Doc, - []*analysis.Analyzer{a}, - cfg, - ).WithLoadMode(goanalysis.LoadModeTypesInfo) + return goanalysis. + NewLinterFromAnalyzer(analyzer.New()). + WithConfig(cfg). + WithLoadMode(goanalysis.LoadModeTypesInfo) } diff --git a/pkg/golinters/testpackage/testpackage.go b/pkg/golinters/testpackage/testpackage.go index ddd5ce95cd15..39c333f1b56d 100644 --- a/pkg/golinters/testpackage/testpackage.go +++ b/pkg/golinters/testpackage/testpackage.go @@ -4,25 +4,23 @@ import ( "strings" "github.com/maratori/testpackage/pkg/testpackage" - "golang.org/x/tools/go/analysis" "github.com/golangci/golangci-lint/v2/pkg/config" "github.com/golangci/golangci-lint/v2/pkg/goanalysis" ) func New(settings *config.TestpackageSettings) *goanalysis.Linter { - a := testpackage.NewAnalyzer() + var cfg map[string]any - var cfg map[string]map[string]any if settings != nil { - cfg = map[string]map[string]any{ - a.Name: { - testpackage.SkipRegexpFlagName: settings.SkipRegexp, - testpackage.AllowPackagesFlagName: strings.Join(settings.AllowPackages, ","), - }, + cfg = map[string]any{ + testpackage.SkipRegexpFlagName: settings.SkipRegexp, + testpackage.AllowPackagesFlagName: strings.Join(settings.AllowPackages, ","), } } - return goanalysis.NewLinter(a.Name, a.Doc, []*analysis.Analyzer{a}, cfg). + return goanalysis. + NewLinterFromAnalyzer(testpackage.NewAnalyzer()). + WithConfig(cfg). WithLoadMode(goanalysis.LoadModeSyntax) } diff --git a/pkg/golinters/thelper/thelper.go b/pkg/golinters/thelper/thelper.go index d9058582d83c..77090c5f8b15 100644 --- a/pkg/golinters/thelper/thelper.go +++ b/pkg/golinters/thelper/thelper.go @@ -6,7 +6,6 @@ import ( "strings" "github.com/kulti/thelper/pkg/analyzer" - "golang.org/x/tools/go/analysis" "github.com/golangci/golangci-lint/v2/pkg/config" "github.com/golangci/golangci-lint/v2/pkg/goanalysis" @@ -14,8 +13,6 @@ import ( ) func New(settings *config.ThelperSettings) *goanalysis.Linter { - a := analyzer.NewAnalyzer() - opts := map[string]struct{}{ "t_name": {}, "t_begin": {}, @@ -47,18 +44,14 @@ func New(settings *config.ThelperSettings) *goanalysis.Linter { args := slices.Collect(maps.Keys(opts)) - cfg := map[string]map[string]any{ - a.Name: { - "checks": strings.Join(args, ","), - }, + cfg := map[string]any{ + "checks": strings.Join(args, ","), } - return goanalysis.NewLinter( - a.Name, - a.Doc, - []*analysis.Analyzer{a}, - cfg, - ).WithLoadMode(goanalysis.LoadModeTypesInfo) + return goanalysis. + NewLinterFromAnalyzer(analyzer.NewAnalyzer()). + WithConfig(cfg). + WithLoadMode(goanalysis.LoadModeTypesInfo) } func applyTHelperOptions(o config.ThelperOptions, prefix string, opts map[string]struct{}) { diff --git a/pkg/golinters/tparallel/tparallel.go b/pkg/golinters/tparallel/tparallel.go index f3ce2fcf7975..480ef3b1e92b 100644 --- a/pkg/golinters/tparallel/tparallel.go +++ b/pkg/golinters/tparallel/tparallel.go @@ -2,17 +2,12 @@ package tparallel import ( "github.com/moricho/tparallel" - "golang.org/x/tools/go/analysis" "github.com/golangci/golangci-lint/v2/pkg/goanalysis" ) func New() *goanalysis.Linter { - a := tparallel.Analyzer - return goanalysis.NewLinter( - a.Name, - a.Doc, - []*analysis.Analyzer{a}, - nil, - ).WithLoadMode(goanalysis.LoadModeTypesInfo) + return goanalysis. + NewLinterFromAnalyzer(tparallel.Analyzer). + WithLoadMode(goanalysis.LoadModeTypesInfo) } diff --git a/pkg/golinters/typecheck.go b/pkg/golinters/typecheck.go index ad51e8d00f90..db29f7c18394 100644 --- a/pkg/golinters/typecheck.go +++ b/pkg/golinters/typecheck.go @@ -7,18 +7,11 @@ import ( ) func NewTypecheck() *goanalysis.Linter { - const linterName = "typecheck" - - analyzer := &analysis.Analyzer{ - Name: linterName, - Doc: goanalysis.TheOnlyanalyzerDoc, - Run: goanalysis.DummyRun, - } - - return goanalysis.NewLinter( - linterName, - "Like the front-end of a Go compiler, parses and type-checks Go code", - []*analysis.Analyzer{analyzer}, - nil, - ).WithLoadMode(goanalysis.LoadModeNone) + return goanalysis. + NewLinterFromAnalyzer(&analysis.Analyzer{ + Name: "typecheck", + Doc: "Like the front-end of a Go compiler, parses and type-checks Go code", + Run: goanalysis.DummyRun, + }). + WithLoadMode(goanalysis.LoadModeNone) } diff --git a/pkg/golinters/unconvert/unconvert.go b/pkg/golinters/unconvert/unconvert.go index d48cf5175ad4..c9b3f75dd169 100644 --- a/pkg/golinters/unconvert/unconvert.go +++ b/pkg/golinters/unconvert/unconvert.go @@ -21,32 +21,28 @@ func New(settings *config.UnconvertSettings) *goanalysis.Linter { unconvert.SetFastMath(settings.FastMath) unconvert.SetSafe(settings.Safe) - analyzer := &analysis.Analyzer{ - Name: linterName, - Doc: goanalysis.TheOnlyanalyzerDoc, - Run: func(pass *analysis.Pass) (any, error) { - issues := runUnconvert(pass) + return goanalysis. + NewLinterFromAnalyzer(&analysis.Analyzer{ + Name: linterName, + Doc: "Remove unnecessary type conversions", + Run: func(pass *analysis.Pass) (any, error) { + issues := runUnconvert(pass) - if len(issues) == 0 { - return nil, nil - } - - mu.Lock() - resIssues = append(resIssues, issues...) - mu.Unlock() + if len(issues) == 0 { + return nil, nil + } - return nil, nil - }, - } + mu.Lock() + resIssues = append(resIssues, issues...) + mu.Unlock() - return goanalysis.NewLinter( - linterName, - "Remove unnecessary type conversions", - []*analysis.Analyzer{analyzer}, - nil, - ).WithIssuesReporter(func(*linter.Context) []goanalysis.Issue { - return resIssues - }).WithLoadMode(goanalysis.LoadModeTypesInfo) + return nil, nil + }, + }). + WithIssuesReporter(func(*linter.Context) []goanalysis.Issue { + return resIssues + }). + WithLoadMode(goanalysis.LoadModeTypesInfo) } func runUnconvert(pass *analysis.Pass) []goanalysis.Issue { diff --git a/pkg/golinters/unparam/unparam.go b/pkg/golinters/unparam/unparam.go index 5a9bc8a5e473..b6cb2668b076 100644 --- a/pkg/golinters/unparam/unparam.go +++ b/pkg/golinters/unparam/unparam.go @@ -10,29 +10,22 @@ import ( "github.com/golangci/golangci-lint/v2/pkg/goanalysis" ) -const linterName = "unparam" - func New(settings *config.UnparamSettings) *goanalysis.Linter { - analyzer := &analysis.Analyzer{ - Name: linterName, - Doc: goanalysis.TheOnlyanalyzerDoc, - Requires: []*analysis.Analyzer{buildssa.Analyzer}, - Run: func(pass *analysis.Pass) (any, error) { - err := runUnparam(pass, settings) - if err != nil { - return nil, err - } - - return nil, nil - }, - } - - return goanalysis.NewLinter( - linterName, - "Reports unused function parameters", - []*analysis.Analyzer{analyzer}, - nil, - ).WithLoadMode(goanalysis.LoadModeTypesInfo) + return goanalysis. + NewLinterFromAnalyzer(&analysis.Analyzer{ + Name: "unparam", + Doc: "Reports unused function parameters", + Requires: []*analysis.Analyzer{buildssa.Analyzer}, + Run: func(pass *analysis.Pass) (any, error) { + err := runUnparam(pass, settings) + if err != nil { + return nil, err + } + + return nil, nil + }, + }). + WithLoadMode(goanalysis.LoadModeTypesInfo) } func runUnparam(pass *analysis.Pass, settings *config.UnparamSettings) error { diff --git a/pkg/golinters/usestdlibvars/usestdlibvars.go b/pkg/golinters/usestdlibvars/usestdlibvars.go index f0b5f5420d00..9342c4ccd7a3 100644 --- a/pkg/golinters/usestdlibvars/usestdlibvars.go +++ b/pkg/golinters/usestdlibvars/usestdlibvars.go @@ -2,18 +2,16 @@ package usestdlibvars import ( "github.com/sashamelentyev/usestdlibvars/pkg/analyzer" - "golang.org/x/tools/go/analysis" "github.com/golangci/golangci-lint/v2/pkg/config" "github.com/golangci/golangci-lint/v2/pkg/goanalysis" ) func New(settings *config.UseStdlibVarsSettings) *goanalysis.Linter { - a := analyzer.New() + var cfg map[string]any - cfg := make(map[string]map[string]any) if settings != nil { - cfg[a.Name] = map[string]any{ + cfg = map[string]any{ analyzer.ConstantKindFlag: settings.ConstantKind, analyzer.CryptoHashFlag: settings.CryptoHash, analyzer.HTTPMethodFlag: settings.HTTPMethod, @@ -29,10 +27,8 @@ func New(settings *config.UseStdlibVarsSettings) *goanalysis.Linter { } } - return goanalysis.NewLinter( - a.Name, - a.Doc, - []*analysis.Analyzer{a}, - cfg, - ).WithLoadMode(goanalysis.LoadModeSyntax) + return goanalysis. + NewLinterFromAnalyzer(analyzer.New()). + WithConfig(cfg). + WithLoadMode(goanalysis.LoadModeSyntax) } diff --git a/pkg/golinters/usetesting/usetesting.go b/pkg/golinters/usetesting/usetesting.go index 5dfa9f11ad54..7371cc28eb01 100644 --- a/pkg/golinters/usetesting/usetesting.go +++ b/pkg/golinters/usetesting/usetesting.go @@ -2,18 +2,16 @@ package usetesting import ( "github.com/ldez/usetesting" - "golang.org/x/tools/go/analysis" "github.com/golangci/golangci-lint/v2/pkg/config" "github.com/golangci/golangci-lint/v2/pkg/goanalysis" ) func New(settings *config.UseTestingSettings) *goanalysis.Linter { - a := usetesting.NewAnalyzer() + var cfg map[string]any - cfg := make(map[string]map[string]any) if settings != nil { - cfg[a.Name] = map[string]any{ + cfg = map[string]any{ "contextbackground": settings.ContextBackground, "contexttodo": settings.ContextTodo, "oschdir": settings.OSChdir, @@ -24,10 +22,8 @@ func New(settings *config.UseTestingSettings) *goanalysis.Linter { } } - return goanalysis.NewLinter( - a.Name, - a.Doc, - []*analysis.Analyzer{a}, - cfg, - ).WithLoadMode(goanalysis.LoadModeTypesInfo) + return goanalysis. + NewLinterFromAnalyzer(usetesting.NewAnalyzer()). + WithConfig(cfg). + WithLoadMode(goanalysis.LoadModeTypesInfo) } diff --git a/pkg/golinters/varnamelen/varnamelen.go b/pkg/golinters/varnamelen/varnamelen.go index dbd8005ee0d1..a19d7987ddcd 100644 --- a/pkg/golinters/varnamelen/varnamelen.go +++ b/pkg/golinters/varnamelen/varnamelen.go @@ -5,15 +5,13 @@ import ( "strings" "github.com/blizzy78/varnamelen" - "golang.org/x/tools/go/analysis" "github.com/golangci/golangci-lint/v2/pkg/config" "github.com/golangci/golangci-lint/v2/pkg/goanalysis" ) func New(settings *config.VarnamelenSettings) *goanalysis.Linter { - analyzer := varnamelen.NewAnalyzer() - cfg := map[string]map[string]any{} + var cfg map[string]any if settings != nil { vnlCfg := map[string]any{ @@ -30,17 +28,15 @@ func New(settings *config.VarnamelenSettings) *goanalysis.Linter { if settings.MaxDistance > 0 { vnlCfg["maxDistance"] = strconv.Itoa(settings.MaxDistance) } + if settings.MinNameLength > 0 { vnlCfg["minNameLength"] = strconv.Itoa(settings.MinNameLength) } - - cfg[analyzer.Name] = vnlCfg } - return goanalysis.NewLinter( - analyzer.Name, - "checks that the length of a variable's name matches its scope", - []*analysis.Analyzer{analyzer}, - cfg, - ).WithLoadMode(goanalysis.LoadModeTypesInfo) + return goanalysis. + NewLinterFromAnalyzer(varnamelen.NewAnalyzer()). + WithDesc("checks that the length of a variable's name matches its scope"). + WithConfig(cfg). + WithLoadMode(goanalysis.LoadModeTypesInfo) } diff --git a/pkg/golinters/wastedassign/wastedassign.go b/pkg/golinters/wastedassign/wastedassign.go index 6599f7d4dace..d103a8d5a55b 100644 --- a/pkg/golinters/wastedassign/wastedassign.go +++ b/pkg/golinters/wastedassign/wastedassign.go @@ -2,18 +2,13 @@ package wastedassign import ( "github.com/sanposhiho/wastedassign/v2" - "golang.org/x/tools/go/analysis" "github.com/golangci/golangci-lint/v2/pkg/goanalysis" ) func New() *goanalysis.Linter { - a := wastedassign.Analyzer - - return goanalysis.NewLinter( - a.Name, - "Finds wasted assignment statements", - []*analysis.Analyzer{a}, - nil, - ).WithLoadMode(goanalysis.LoadModeTypesInfo) + return goanalysis. + NewLinterFromAnalyzer(wastedassign.Analyzer). + WithDesc("Finds wasted assignment statements"). + WithLoadMode(goanalysis.LoadModeTypesInfo) } diff --git a/pkg/golinters/whitespace/whitespace.go b/pkg/golinters/whitespace/whitespace.go index cd7fda1ce0d0..bf03e1d8088b 100644 --- a/pkg/golinters/whitespace/whitespace.go +++ b/pkg/golinters/whitespace/whitespace.go @@ -2,7 +2,6 @@ package whitespace import ( "github.com/ultraware/whitespace" - "golang.org/x/tools/go/analysis" "github.com/golangci/golangci-lint/v2/pkg/config" "github.com/golangci/golangci-lint/v2/pkg/goanalysis" @@ -17,12 +16,7 @@ func New(settings *config.WhitespaceSettings) *goanalysis.Linter { } } - a := whitespace.NewAnalyzer(&wsSettings) - - return goanalysis.NewLinter( - a.Name, - a.Doc, - []*analysis.Analyzer{a}, - nil, - ).WithLoadMode(goanalysis.LoadModeSyntax) + return goanalysis. + NewLinterFromAnalyzer(whitespace.NewAnalyzer(&wsSettings)). + WithLoadMode(goanalysis.LoadModeSyntax) } diff --git a/pkg/golinters/wrapcheck/wrapcheck.go b/pkg/golinters/wrapcheck/wrapcheck.go index 8a4427f7d368..c29c509a80fd 100644 --- a/pkg/golinters/wrapcheck/wrapcheck.go +++ b/pkg/golinters/wrapcheck/wrapcheck.go @@ -2,7 +2,6 @@ package wrapcheck import ( "github.com/tomarrell/wrapcheck/v2/wrapcheck" - "golang.org/x/tools/go/analysis" "github.com/golangci/golangci-lint/v2/pkg/config" "github.com/golangci/golangci-lint/v2/pkg/goanalysis" @@ -29,12 +28,7 @@ func New(settings *config.WrapcheckSettings) *goanalysis.Linter { } } - a := wrapcheck.NewAnalyzer(cfg) - - return goanalysis.NewLinter( - a.Name, - a.Doc, - []*analysis.Analyzer{a}, - nil, - ).WithLoadMode(goanalysis.LoadModeTypesInfo) + return goanalysis. + NewLinterFromAnalyzer(wrapcheck.NewAnalyzer(cfg)). + WithLoadMode(goanalysis.LoadModeTypesInfo) } diff --git a/pkg/golinters/wsl/wsl.go b/pkg/golinters/wsl/wsl.go index 12148627eb5b..c71706f5c1d3 100644 --- a/pkg/golinters/wsl/wsl.go +++ b/pkg/golinters/wsl/wsl.go @@ -2,7 +2,6 @@ package wsl import ( "github.com/bombsimon/wsl/v4" - "golang.org/x/tools/go/analysis" "github.com/golangci/golangci-lint/v2/pkg/config" "github.com/golangci/golangci-lint/v2/pkg/goanalysis" @@ -10,6 +9,7 @@ import ( func New(settings *config.WSLSettings) *goanalysis.Linter { var conf *wsl.Configuration + if settings != nil { conf = &wsl.Configuration{ StrictAppend: settings.StrictAppend, @@ -30,12 +30,7 @@ func New(settings *config.WSLSettings) *goanalysis.Linter { } } - a := wsl.NewAnalyzer(conf) - - return goanalysis.NewLinter( - a.Name, - a.Doc, - []*analysis.Analyzer{a}, - nil, - ).WithLoadMode(goanalysis.LoadModeSyntax) + return goanalysis. + NewLinterFromAnalyzer(wsl.NewAnalyzer(conf)). + WithLoadMode(goanalysis.LoadModeSyntax) } diff --git a/pkg/golinters/zerologlint/zerologlint.go b/pkg/golinters/zerologlint/zerologlint.go index 0daf0d48a4d6..46832da96c8b 100644 --- a/pkg/golinters/zerologlint/zerologlint.go +++ b/pkg/golinters/zerologlint/zerologlint.go @@ -2,18 +2,12 @@ package zerologlint import ( "github.com/ykadowak/zerologlint" - "golang.org/x/tools/go/analysis" "github.com/golangci/golangci-lint/v2/pkg/goanalysis" ) func New() *goanalysis.Linter { - a := zerologlint.Analyzer - - return goanalysis.NewLinter( - a.Name, - a.Doc, - []*analysis.Analyzer{a}, - nil, - ).WithLoadMode(goanalysis.LoadModeTypesInfo) + return goanalysis. + NewLinterFromAnalyzer(zerologlint.Analyzer). + WithLoadMode(goanalysis.LoadModeTypesInfo) } From 736980cd0ec2a08b7cf88666a3e4c9665a250b71 Mon Sep 17 00:00:00 2001 From: Ludovic Fernandez Date: Wed, 14 May 2025 12:41:42 +0200 Subject: [PATCH 57/96] dev: remove AUR publishing (#5799) --- .goreleaser.yml | 72 ------------------------------------------------- 1 file changed, 72 deletions(-) diff --git a/.goreleaser.yml b/.goreleaser.yml index 98346da5f7fd..b8bba3bea74f 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -140,78 +140,6 @@ brews: # source_repo: "https://push.chocolatey.org/" # goamd64: v1 -aurs: - - description: Fast linters runner for Go. - skip_upload: false - homepage: https://golangci.com - provides: - - "golangci-lint-bin" - maintainers: - - "Fernandez Ludovic " - license: GPL-3.0 - private_key: "{{ .Env.AUR_KEY }}" - git_url: "ssh://aur@aur.archlinux.org/golangci-lint-bin.git" - commit_author: - name: golangci-releaser - email: 65486276+golangci-releaser@users.noreply.github.com - package: |- - local x86_64=amd64 i686=386 aarch64=arm64 armv6h=armv6 armv7h=armv7 - cd "golangci-lint-${pkgver}-linux-${!CARCH}" - - # bin - install -Dm755 "./golangci-lint" "${pkgdir}/usr/bin/golangci-lint" - - # license - install -Dm644 "./LICENSE" "${pkgdir}/usr/share/licenses/golangci-lint/LICENSE" - - # completions - mkdir -p "${pkgdir}/usr/share/bash-completion/completions/" - mkdir -p "${pkgdir}/usr/share/zsh/site-functions/" - mkdir -p "${pkgdir}/usr/share/fish/vendor_completions.d/" - ./golangci-lint completion bash | install -Dm644 /dev/stdin "${pkgdir}/usr/share/bash-completion/completions/golangci-lint" - ./golangci-lint completion zsh | install -Dm644 /dev/stdin "${pkgdir}/usr/share/zsh/site-functions/_golangci-lint" - ./golangci-lint completion fish | install -Dm644 /dev/stdin "${pkgdir}/usr/share/fish/vendor_completions.d/golangci-lint.fish" - -aur_sources: - - description: Fast linters runner for Go. - skip_upload: false - homepage: https://golangci.com - provides: - - "golangci-lint" - maintainers: - - "Fernandez Ludovic " - license: GPL-3.0 - private_key: "{{ .Env.AUR_KEY }}" - git_url: "ssh://aur@aur.archlinux.org/golangci-lint.git" - commit_author: - name: golangci-releaser - email: 65486276+golangci-releaser@users.noreply.github.com - build: |- - local _commit _flags - _commit=$(bsdcat "${pkgname}_${pkgver}.tar.gz" | git get-tar-commit-id) - _flags=( - -X=main.version="$pkgver" - -X=main.commit="${_commit::7}" - -X=main.date="$(date -u -d "@${SOURCE_DATE_EPOCH}" +'%FT%TZ')" - -linkmode=external - ) - export CGO_ENABLED=1 - export CGO_CFLAGS="${CFLAGS}" - export CGO_CPPFLAGS="$CPPFLAGS" - export CGO_CXXFLAGS="$CXXFLAGS" - export CGO_LDFLAGS="${LDFLAGS}" - export GOFLAGS='-buildmode=pie -trimpath -modcacherw' - - go build -o "$pkgname" -ldflags="${_flags[*]}" ./cmd/"$pkgname" - ./"$pkgname" completion bash > completion.bash - ./"$pkgname" completion zsh > completion.zsh - ./"$pkgname" completion fish > completion.fish - package: |- - install -Dm755 "$pkgname" -t "$pkgdir"/usr/bin - install -Dm644 completion.bash "$pkgdir"/usr/share/bash-completion/completions/"$pkgname" - install -Dm644 completion.zsh "$pkgdir"/usr/share/zsh/site-functions/_"$pkgname" - install -Dm644 completion.fish "$pkgdir"/usr/share/fish/vendor_completions.d/"$pkgname".fish - snapcrafts: - summary: Fast linters runner for Go. description: | From 522c98c0bb57d46f2b6960867adb320da50a9b31 Mon Sep 17 00:00:00 2001 From: Ludovic Fernandez Date: Wed, 14 May 2025 21:43:06 +0200 Subject: [PATCH 58/96] dev: restore aur-bin (#5803) --- .goreleaser.yml | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/.goreleaser.yml b/.goreleaser.yml index b8bba3bea74f..d40fb1a4a034 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -140,6 +140,38 @@ brews: # source_repo: "https://push.chocolatey.org/" # goamd64: v1 +aurs: + - description: Fast linters runner for Go. + skip_upload: false + homepage: https://golangci.com + provides: + - "golangci-lint-bin" + maintainers: + - "Fernandez Ludovic " + license: GPL-3.0 + private_key: "{{ .Env.AUR_KEY }}" + git_url: "ssh://aur@aur.archlinux.org/golangci-lint-bin.git" + commit_author: + name: golangci-releaser + email: 65486276+golangci-releaser@users.noreply.github.com + package: |- + local x86_64=amd64 i686=386 aarch64=arm64 armv6h=armv6 armv7h=armv7 + cd "golangci-lint-${pkgver}-linux-${!CARCH}" + + # bin + install -Dm755 "./golangci-lint" "${pkgdir}/usr/bin/golangci-lint" + + # license + install -Dm644 "./LICENSE" "${pkgdir}/usr/share/licenses/golangci-lint/LICENSE" + + # completions + mkdir -p "${pkgdir}/usr/share/bash-completion/completions/" + mkdir -p "${pkgdir}/usr/share/zsh/site-functions/" + mkdir -p "${pkgdir}/usr/share/fish/vendor_completions.d/" + ./golangci-lint completion bash | install -Dm644 /dev/stdin "${pkgdir}/usr/share/bash-completion/completions/golangci-lint" + ./golangci-lint completion zsh | install -Dm644 /dev/stdin "${pkgdir}/usr/share/zsh/site-functions/_golangci-lint" + ./golangci-lint completion fish | install -Dm644 /dev/stdin "${pkgdir}/usr/share/fish/vendor_completions.d/golangci-lint.fish" + snapcrafts: - summary: Fast linters runner for Go. description: | From 37932d1812d56aff9409ddde35e779a5ebfc854b Mon Sep 17 00:00:00 2001 From: Ludovic Fernandez Date: Wed, 14 May 2025 21:45:30 +0200 Subject: [PATCH 59/96] chore: remove dead code (#5801) --- pkg/golinters/dupl/dupl.go | 2 +- pkg/golinters/errcheck/errcheck.go | 6 +++--- pkg/golinters/gochecknoinits/gochecknoinits.go | 2 +- pkg/golinters/gocognit/gocognit.go | 2 +- pkg/golinters/goconst/goconst.go | 6 +++--- pkg/golinters/gocyclo/gocyclo.go | 2 +- pkg/golinters/internal/util.go | 3 +-- pkg/golinters/prealloc/prealloc.go | 2 +- 8 files changed, 12 insertions(+), 13 deletions(-) diff --git a/pkg/golinters/dupl/dupl.go b/pkg/golinters/dupl/dupl.go index 654c795ff696..6d5323a8bad4 100644 --- a/pkg/golinters/dupl/dupl.go +++ b/pkg/golinters/dupl/dupl.go @@ -70,7 +70,7 @@ func runDupl(pass *analysis.Pass, settings *config.DuplSettings) ([]goanalysis.I dupl := fmt.Sprintf("%s:%d-%d", toFilename, i.To.LineStart(), i.To.LineEnd()) text := fmt.Sprintf("%d-%d lines are duplicate of %s", i.From.LineStart(), i.From.LineEnd(), - internal.FormatCode(dupl, nil)) + internal.FormatCode(dupl)) res = append(res, goanalysis.NewIssue(&result.Issue{ Pos: token.Position{ diff --git a/pkg/golinters/errcheck/errcheck.go b/pkg/golinters/errcheck/errcheck.go index c3c813d4f828..2e2136caa2ea 100644 --- a/pkg/golinters/errcheck/errcheck.go +++ b/pkg/golinters/errcheck/errcheck.go @@ -37,7 +37,7 @@ func New(settings *config.ErrcheckSettings) *goanalysis.Linter { checker.Tags = lintCtx.Cfg.Run.BuildTags analyzer.Run = func(pass *analysis.Pass) (any, error) { - issues := runErrCheck(lintCtx, pass, checker) + issues := runErrCheck(pass, checker) if len(issues) == 0 { return nil, nil @@ -56,7 +56,7 @@ func New(settings *config.ErrcheckSettings) *goanalysis.Linter { WithLoadMode(goanalysis.LoadModeTypesInfo) } -func runErrCheck(lintCtx *linter.Context, pass *analysis.Pass, checker *errcheck.Checker) []goanalysis.Issue { +func runErrCheck(pass *analysis.Pass, checker *errcheck.Checker) []goanalysis.Issue { pkg := &packages.Package{ Fset: pass.Fset, Syntax: pass.Files, @@ -77,7 +77,7 @@ func runErrCheck(lintCtx *linter.Context, pass *analysis.Pass, checker *errcheck if err.FuncName != "" { code := cmp.Or(err.SelectorName, err.FuncName) - text = fmt.Sprintf("Error return value of %s is not checked", internal.FormatCode(code, lintCtx.Cfg)) + text = fmt.Sprintf("Error return value of %s is not checked", internal.FormatCode(code)) } issues[i] = goanalysis.NewIssue( diff --git a/pkg/golinters/gochecknoinits/gochecknoinits.go b/pkg/golinters/gochecknoinits/gochecknoinits.go index c027aa8ab928..9158ee07da55 100644 --- a/pkg/golinters/gochecknoinits/gochecknoinits.go +++ b/pkg/golinters/gochecknoinits/gochecknoinits.go @@ -40,7 +40,7 @@ func run(pass *analysis.Pass) (any, error) { fnName := funcDecl.Name.Name if fnName == "init" && funcDecl.Recv.NumFields() == 0 { - pass.Reportf(funcDecl.Pos(), "don't use %s function", internal.FormatCode(fnName, nil)) + pass.Reportf(funcDecl.Pos(), "don't use %s function", internal.FormatCode(fnName)) } }) diff --git a/pkg/golinters/gocognit/gocognit.go b/pkg/golinters/gocognit/gocognit.go index e60bcfb17080..e72a9bdfe67a 100644 --- a/pkg/golinters/gocognit/gocognit.go +++ b/pkg/golinters/gocognit/gocognit.go @@ -67,7 +67,7 @@ func runGocognit(pass *analysis.Pass, settings *config.GocognitSettings) []goana issues = append(issues, goanalysis.NewIssue(&result.Issue{ Pos: s.Pos, Text: fmt.Sprintf("cognitive complexity %d of func %s is high (> %d)", - s.Complexity, internal.FormatCode(s.FuncName, nil), settings.MinComplexity), + s.Complexity, internal.FormatCode(s.FuncName), settings.MinComplexity), FromLinter: linterName, }, pass)) } diff --git a/pkg/golinters/goconst/goconst.go b/pkg/golinters/goconst/goconst.go index f32a4c6575e2..5a44d4a5ce3a 100644 --- a/pkg/golinters/goconst/goconst.go +++ b/pkg/golinters/goconst/goconst.go @@ -85,17 +85,17 @@ func runGoconst(pass *analysis.Pass, settings *config.GoConstSettings) ([]goanal switch { case issue.OccurrencesCount > 0: - text = fmt.Sprintf("string %s has %d occurrences", internal.FormatCode(issue.Str, nil), issue.OccurrencesCount) + text = fmt.Sprintf("string %s has %d occurrences", internal.FormatCode(issue.Str), issue.OccurrencesCount) if issue.MatchingConst == "" { text += ", make it a constant" } else { - text += fmt.Sprintf(", but such constant %s already exists", internal.FormatCode(issue.MatchingConst, nil)) + text += fmt.Sprintf(", but such constant %s already exists", internal.FormatCode(issue.MatchingConst)) } case issue.DuplicateConst != "": text = fmt.Sprintf("This constant is a duplicate of %s at %s", - internal.FormatCode(issue.DuplicateConst, nil), + internal.FormatCode(issue.DuplicateConst), issue.DuplicatePos.String()) default: diff --git a/pkg/golinters/gocyclo/gocyclo.go b/pkg/golinters/gocyclo/gocyclo.go index 514194709385..17b868d4972a 100644 --- a/pkg/golinters/gocyclo/gocyclo.go +++ b/pkg/golinters/gocyclo/gocyclo.go @@ -59,7 +59,7 @@ func runGoCyclo(pass *analysis.Pass, settings *config.GoCycloSettings) []goanaly for _, s := range stats { text := fmt.Sprintf("cyclomatic complexity %d of func %s is high (> %d)", - s.Complexity, internal.FormatCode(s.FuncName, nil), settings.MinComplexity) + s.Complexity, internal.FormatCode(s.FuncName), settings.MinComplexity) issues = append(issues, goanalysis.NewIssue(&result.Issue{ Pos: s.Pos, diff --git a/pkg/golinters/internal/util.go b/pkg/golinters/internal/util.go index 2e5fb29f91c9..86137cf66081 100644 --- a/pkg/golinters/internal/util.go +++ b/pkg/golinters/internal/util.go @@ -6,11 +6,10 @@ import ( "golang.org/x/tools/go/analysis" - "github.com/golangci/golangci-lint/v2/pkg/config" "github.com/golangci/golangci-lint/v2/pkg/goanalysis" ) -func FormatCode(code string, _ *config.Config) string { +func FormatCode(code string) string { if strings.Contains(code, "`") { return code // TODO: properly escape or remove } diff --git a/pkg/golinters/prealloc/prealloc.go b/pkg/golinters/prealloc/prealloc.go index 66890ad5bc61..c750df990459 100644 --- a/pkg/golinters/prealloc/prealloc.go +++ b/pkg/golinters/prealloc/prealloc.go @@ -31,7 +31,7 @@ func runPreAlloc(pass *analysis.Pass, settings *config.PreallocSettings) { for _, hint := range hints { pass.Report(analysis.Diagnostic{ Pos: hint.Pos, - Message: fmt.Sprintf("Consider pre-allocating %s", internal.FormatCode(hint.DeclaredSliceName, nil)), + Message: fmt.Sprintf("Consider pre-allocating %s", internal.FormatCode(hint.DeclaredSliceName)), }) } } From deee4e75cd912954538449a2f35d795ea04545ce Mon Sep 17 00:00:00 2001 From: Ludovic Fernandez Date: Thu, 15 May 2025 11:23:02 +0200 Subject: [PATCH 60/96] errcheck: add verbose option (#5802) --- .golangci.next.reference.yml | 4 ++++ jsonschema/golangci.next.jsonschema.json | 5 +++++ pkg/config/linters_settings.go | 1 + pkg/golinters/errcheck/errcheck.go | 7 +++++-- 4 files changed, 15 insertions(+), 2 deletions(-) diff --git a/.golangci.next.reference.yml b/.golangci.next.reference.yml index ff015539fabb..9801a5c3ff87 100644 --- a/.golangci.next.reference.yml +++ b/.golangci.next.reference.yml @@ -408,6 +408,10 @@ linters: - io.Copy(*bytes.Buffer) - io.Copy(os.Stdout) + # Display function signature instead of selector. + # Default: false + verbose: true + errchkjson: # With check-error-free-encoding set to true, errchkjson does warn about errors # from json encoding functions that are safe to be ignored, diff --git a/jsonschema/golangci.next.jsonschema.json b/jsonschema/golangci.next.jsonschema.json index 9da8ac328072..e98d54dc4dc4 100644 --- a/jsonschema/golangci.next.jsonschema.json +++ b/jsonschema/golangci.next.jsonschema.json @@ -1115,6 +1115,11 @@ "description": "To disable the errcheck built-in exclude list", "type": "boolean", "default": false + }, + "verbose": { + "description": "Display function signature instead of selector", + "type": "boolean", + "default": false } } }, diff --git a/pkg/config/linters_settings.go b/pkg/config/linters_settings.go index 065abfab47c1..cadb4a765914 100644 --- a/pkg/config/linters_settings.go +++ b/pkg/config/linters_settings.go @@ -372,6 +372,7 @@ type ErrcheckSettings struct { CheckTypeAssertions bool `mapstructure:"check-type-assertions"` CheckAssignToBlank bool `mapstructure:"check-blank"` ExcludeFunctions []string `mapstructure:"exclude-functions"` + Verbose bool `mapstructure:"verbose"` } type ErrChkJSONSettings struct { diff --git a/pkg/golinters/errcheck/errcheck.go b/pkg/golinters/errcheck/errcheck.go index 2e2136caa2ea..ae34a53ef62c 100644 --- a/pkg/golinters/errcheck/errcheck.go +++ b/pkg/golinters/errcheck/errcheck.go @@ -37,7 +37,7 @@ func New(settings *config.ErrcheckSettings) *goanalysis.Linter { checker.Tags = lintCtx.Cfg.Run.BuildTags analyzer.Run = func(pass *analysis.Pass) (any, error) { - issues := runErrCheck(pass, checker) + issues := runErrCheck(pass, checker, settings.Verbose) if len(issues) == 0 { return nil, nil @@ -56,7 +56,7 @@ func New(settings *config.ErrcheckSettings) *goanalysis.Linter { WithLoadMode(goanalysis.LoadModeTypesInfo) } -func runErrCheck(pass *analysis.Pass, checker *errcheck.Checker) []goanalysis.Issue { +func runErrCheck(pass *analysis.Pass, checker *errcheck.Checker, verbose bool) []goanalysis.Issue { pkg := &packages.Package{ Fset: pass.Fset, Syntax: pass.Files, @@ -76,6 +76,9 @@ func runErrCheck(pass *analysis.Pass, checker *errcheck.Checker) []goanalysis.Is if err.FuncName != "" { code := cmp.Or(err.SelectorName, err.FuncName) + if verbose { + code = err.FuncName + } text = fmt.Sprintf("Error return value of %s is not checked", internal.FormatCode(code)) } From ccf16f7213cccce4c6e5d5896a18e148e4392b81 Mon Sep 17 00:00:00 2001 From: Takeo Kasai <73113050+take0fit@users.noreply.github.com> Date: Fri, 16 May 2025 04:36:37 +0900 Subject: [PATCH 61/96] docs: fix revive defer rule configuration (#5804) Co-authored-by: Fernandez Ludovic --- .golangci.reference.yml | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/.golangci.reference.yml b/.golangci.reference.yml index 37866ff00f2c..6aad45d89868 100644 --- a/.golangci.reference.yml +++ b/.golangci.reference.yml @@ -2300,12 +2300,11 @@ linters: disabled: false exclude: [""] arguments: - - "call-chain" - - "loop" - - "method-call" - - "recover" - - "immediate-recover" - - "return" + - - "call-chain" + - "loop" + - "method-call" + - "recover" + - "return" # https://github.com/mgechev/revive/blob/HEAD/RULES_DESCRIPTIONS.md#dot-imports - name: dot-imports severity: warning From f5f2c1654bc47cbde49e6849acc9e2b30da2fda0 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sun, 18 May 2025 23:40:52 +0200 Subject: [PATCH 62/96] build(deps): bump github.com/Abirdcfly/dupword from 0.1.3 to 0.1.4 (#5809) --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index ca6b23a4880b..ad7a63bd6abc 100644 --- a/go.mod +++ b/go.mod @@ -6,7 +6,7 @@ require ( 4d63.com/gocheckcompilerdirectives v1.3.0 4d63.com/gochecknoglobals v0.2.2 github.com/4meepo/tagalign v1.4.2 - github.com/Abirdcfly/dupword v0.1.3 + github.com/Abirdcfly/dupword v0.1.4 github.com/Antonboom/errname v1.1.0 github.com/Antonboom/nilnil v1.1.0 github.com/Antonboom/testifylint v1.6.1 diff --git a/go.sum b/go.sum index 6c6f2bf9639b..0cb2e8b15c54 100644 --- a/go.sum +++ b/go.sum @@ -37,8 +37,8 @@ cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9 dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= github.com/4meepo/tagalign v1.4.2 h1:0hcLHPGMjDyM1gHG58cS73aQF8J4TdVR96TZViorO9E= github.com/4meepo/tagalign v1.4.2/go.mod h1:+p4aMyFM+ra7nb41CnFG6aSDXqRxU/w1VQqScKqDARI= -github.com/Abirdcfly/dupword v0.1.3 h1:9Pa1NuAsZvpFPi9Pqkd93I7LIYRURj+A//dFd5tgBeE= -github.com/Abirdcfly/dupword v0.1.3/go.mod h1:8VbB2t7e10KRNdwTVoxdBaxla6avbhGzb8sCTygUMhw= +github.com/Abirdcfly/dupword v0.1.4 h1:jxqkdgO0L7FSwq4fMu3d+fAA1E3bBQAtl4utA3tcQZM= +github.com/Abirdcfly/dupword v0.1.4/go.mod h1:s+BFMuL/I4YSiFv29snqyjwzDp4b65W2Kvy+PKzZ6cw= github.com/Antonboom/errname v1.1.0 h1:A+ucvdpMwlo/myWrkHEUEBWc/xuXdud23S8tmTb/oAE= github.com/Antonboom/errname v1.1.0/go.mod h1:O1NMrzgUcVBGIfi3xlVuvX8Q/VP/73sseCaAppfjqZw= github.com/Antonboom/nilnil v1.1.0 h1:jGxJxjgYS3VUUtOTNk8Z1icwT5ESpLH/426fjmQG+ng= From 66fc278beb5bae9ccce66711ee1223efc56aef69 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sun, 18 May 2025 23:41:08 +0200 Subject: [PATCH 63/96] build(deps): bump github.com/uudashr/iface from 1.3.1 to 1.3.2 (#5810) --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index ad7a63bd6abc..0f444d56424b 100644 --- a/go.mod +++ b/go.mod @@ -119,7 +119,7 @@ require ( github.com/ultraware/funlen v0.2.0 github.com/ultraware/whitespace v0.2.0 github.com/uudashr/gocognit v1.2.0 - github.com/uudashr/iface v1.3.1 + github.com/uudashr/iface v1.3.2 github.com/valyala/quicktemplate v1.8.0 github.com/xen0n/gosmopolitan v1.3.0 github.com/yagipy/maintidx v1.0.0 diff --git a/go.sum b/go.sum index 0cb2e8b15c54..0873061afebd 100644 --- a/go.sum +++ b/go.sum @@ -598,8 +598,8 @@ github.com/ultraware/whitespace v0.2.0 h1:TYowo2m9Nfj1baEQBjuHzvMRbp19i+RCcRYrSW github.com/ultraware/whitespace v0.2.0/go.mod h1:XcP1RLD81eV4BW8UhQlpaR+SDc2givTvyI8a586WjW8= github.com/uudashr/gocognit v1.2.0 h1:3BU9aMr1xbhPlvJLSydKwdLN3tEUUrzPSSM8S4hDYRA= github.com/uudashr/gocognit v1.2.0/go.mod h1:k/DdKPI6XBZO1q7HgoV2juESI2/Ofj9AcHPZhBBdrTU= -github.com/uudashr/iface v1.3.1 h1:bA51vmVx1UIhiIsQFSNq6GZ6VPTk3WNMZgRiCe9R29U= -github.com/uudashr/iface v1.3.1/go.mod h1:4QvspiRd3JLPAEXBQ9AiZpLbJlrWWgRChOKDJEuQTdg= +github.com/uudashr/iface v1.3.2 h1:viQ7WtLvznR+Z4H+IP/fqhqPl3UF9Y2aj6wTeHF6X+Y= +github.com/uudashr/iface v1.3.2/go.mod h1:i/H4cfRMPe0izticV8Yz0g6/zcsh5xXlvthrdh1kqcY= github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw= github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc= github.com/valyala/quicktemplate v1.8.0 h1:zU0tjbIqTRgKQzFY1L42zq0qR3eh4WoQQdIdqCysW5k= From 58036ddeefcfc8814b9787742a6985b13d02c4b0 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sun, 18 May 2025 23:42:58 +0200 Subject: [PATCH 64/96] build(deps): bump github.com/alecthomas/chroma/v2 from 2.17.2 to 2.18.0 (#5812) --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 0f444d56424b..f4c0b3ced505 100644 --- a/go.mod +++ b/go.mod @@ -14,7 +14,7 @@ require ( github.com/Djarvur/go-err113 v0.0.0-20210108212216-aea10b59be24 github.com/GaijinEntertainment/go-exhaustruct/v3 v3.3.1 github.com/OpenPeeDeeP/depguard/v2 v2.2.1 - github.com/alecthomas/chroma/v2 v2.17.2 + github.com/alecthomas/chroma/v2 v2.18.0 github.com/alecthomas/go-check-sumtype v0.3.1 github.com/alexkohler/nakedret/v2 v2.0.6 github.com/alexkohler/prealloc v1.0.0 diff --git a/go.sum b/go.sum index 0873061afebd..cf2b6fbc84a9 100644 --- a/go.sum +++ b/go.sum @@ -59,8 +59,8 @@ github.com/OpenPeeDeeP/depguard/v2 v2.2.1 h1:vckeWVESWp6Qog7UZSARNqfu/cZqvki8zsu github.com/OpenPeeDeeP/depguard/v2 v2.2.1/go.mod h1:q4DKzC4UcVaAvcfd41CZh0PWpGgzrVxUYBlgKNGquUo= github.com/alecthomas/assert/v2 v2.11.0 h1:2Q9r3ki8+JYXvGsDyBXwH3LcJ+WK5D0gc5E8vS6K3D0= github.com/alecthomas/assert/v2 v2.11.0/go.mod h1:Bze95FyfUr7x34QZrjL+XP+0qgp/zg8yS+TtBj1WA3k= -github.com/alecthomas/chroma/v2 v2.17.2 h1:Rm81SCZ2mPoH+Q8ZCc/9YvzPUN/E7HgPiPJD8SLV6GI= -github.com/alecthomas/chroma/v2 v2.17.2/go.mod h1:RVX6AvYm4VfYe/zsk7mjHueLDZor3aWCNE14TFlepBk= +github.com/alecthomas/chroma/v2 v2.18.0 h1:6h53Q4hW83SuF+jcsp7CVhLsMozzvQvO8HBbKQW+gn4= +github.com/alecthomas/chroma/v2 v2.18.0/go.mod h1:RVX6AvYm4VfYe/zsk7mjHueLDZor3aWCNE14TFlepBk= github.com/alecthomas/go-check-sumtype v0.3.1 h1:u9aUvbGINJxLVXiFvHUlPEaD7VDULsrxJb4Aq31NLkU= github.com/alecthomas/go-check-sumtype v0.3.1/go.mod h1:A8TSiN3UPRw3laIgWEUOHHLPa6/r9MtoigdlP5h3K/E= github.com/alecthomas/repr v0.4.0 h1:GhI2A8MACjfegCPVq9f1FLvIBS+DrQ2KQBFZP1iFzXc= From 8e38a6ef025ba738f23ca4a34d6d86eec0d99a72 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 19 May 2025 00:21:15 +0200 Subject: [PATCH 65/96] build(deps): bump github.com/manuelarte/embeddedstructfieldcheck from 0.2.1 to 0.3.0 (#5811) Co-authored-by: Fernandez Ludovic --- .golangci.next.reference.yml | 5 + go.mod | 2 +- go.sum | 4 +- jsonschema/golangci.next.jsonschema.json | 14 ++ pkg/config/linters_settings.go | 161 +++++++++--------- .../embeddedstructfieldcheck.go | 12 +- .../embeddedstructfieldcheck_comments.go | 2 +- .../embeddedstructfieldcheck_mutex.go | 29 ++++ .../embeddedstructfieldcheck_mutex.yml | 6 + .../embeddedstructfieldcheck_simple.go | 2 +- .../embeddedstructfieldcheck_special_cases.go | 2 +- pkg/lint/lintersdb/builder_linter.go | 2 +- 12 files changed, 155 insertions(+), 86 deletions(-) create mode 100644 pkg/golinters/embeddedstructfieldcheck/testdata/embeddedstructfieldcheck_mutex.go create mode 100644 pkg/golinters/embeddedstructfieldcheck/testdata/embeddedstructfieldcheck_mutex.yml diff --git a/.golangci.next.reference.yml b/.golangci.next.reference.yml index 9801a5c3ff87..8a4fc69e22b1 100644 --- a/.golangci.next.reference.yml +++ b/.golangci.next.reference.yml @@ -385,6 +385,11 @@ linters: ignore: - "0C0C" + embeddedstructfieldcheck: + # Checks that sync.Mutex and sync.RWMutex are not used as embedded fields. + # Default: false + forbid-mutex: true + errcheck: # Report about not checking of errors in type assertions: `a := b.(MyStruct)`. # Such cases aren't reported by default. diff --git a/go.mod b/go.mod index f4c0b3ced505..7a1711e4277a 100644 --- a/go.mod +++ b/go.mod @@ -74,7 +74,7 @@ require ( github.com/ldez/usetesting v0.4.3 github.com/leonklingele/grouper v1.1.2 github.com/macabu/inamedparam v0.2.0 - github.com/manuelarte/embeddedstructfieldcheck v0.2.1 + github.com/manuelarte/embeddedstructfieldcheck v0.3.0 github.com/manuelarte/funcorder v0.5.0 github.com/maratori/testableexamples v1.0.0 github.com/maratori/testpackage v1.1.1 diff --git a/go.sum b/go.sum index cf2b6fbc84a9..ba8cde2b19d6 100644 --- a/go.sum +++ b/go.sum @@ -391,8 +391,8 @@ github.com/macabu/inamedparam v0.2.0 h1:VyPYpOc10nkhI2qeNUdh3Zket4fcZjEWe35poddB github.com/macabu/inamedparam v0.2.0/go.mod h1:+Pee9/YfGe5LJ62pYXqB89lJ+0k5bsR8Wgz/C0Zlq3U= github.com/magiconair/properties v1.8.6 h1:5ibWZ6iY0NctNGWo87LalDlEZ6R41TqbbDamhfG/Qzo= github.com/magiconair/properties v1.8.6/go.mod h1:y3VJvCyxH9uVvJTWEGAELF3aiYNyPKd5NZ3oSwXrF60= -github.com/manuelarte/embeddedstructfieldcheck v0.2.1 h1:oKexdVGs8Jy31IzOD/EMKfZmgogFhAaDbHb1o0qmA1Q= -github.com/manuelarte/embeddedstructfieldcheck v0.2.1/go.mod h1:LSo/IQpPfx1dXMcX4ibZCYA7Yy6ayZHIaOGM70+1Wy8= +github.com/manuelarte/embeddedstructfieldcheck v0.3.0 h1:VhGqK8gANDvFYDxQkjPbv7/gDJtsGU9k6qj/hC2hgso= +github.com/manuelarte/embeddedstructfieldcheck v0.3.0/go.mod h1:LSo/IQpPfx1dXMcX4ibZCYA7Yy6ayZHIaOGM70+1Wy8= github.com/manuelarte/funcorder v0.5.0 h1:llMuHXXbg7tD0i/LNw8vGnkDTHFpTnWqKPI85Rknc+8= github.com/manuelarte/funcorder v0.5.0/go.mod h1:Yt3CiUQthSBMBxjShjdXMexmzpP8YGvGLjrxJNkO2hA= github.com/maratori/testableexamples v1.0.0 h1:dU5alXRrD8WKSjOUnmJZuzdxWOEQ57+7s93SLMxb2vI= diff --git a/jsonschema/golangci.next.jsonschema.json b/jsonschema/golangci.next.jsonschema.json index e98d54dc4dc4..ef1c956ef1c4 100644 --- a/jsonschema/golangci.next.jsonschema.json +++ b/jsonschema/golangci.next.jsonschema.json @@ -1089,6 +1089,17 @@ } } }, + "embeddedstructfieldcheckSettings": { + "type": "object", + "additionalProperties": false, + "properties": { + "forbid-mutex": { + "description": "Checks that sync.Mutex and sync.RWMutex are not used as embedded fields.", + "type": "boolean", + "default": false + } + } + }, "errcheckSettings": { "type": "object", "additionalProperties": false, @@ -4356,6 +4367,9 @@ "dupl": { "$ref": "#/definitions/settings/definitions/duplSettings" }, + "embeddedstructfieldcheck": { + "$ref": "#/definitions/settings/definitions/embeddedstructfieldcheckSettings" + }, "errcheck": { "$ref": "#/definitions/settings/definitions/errcheckSettings" }, diff --git a/pkg/config/linters_settings.go b/pkg/config/linters_settings.go index cadb4a765914..2398186d3812 100644 --- a/pkg/config/linters_settings.go +++ b/pkg/config/linters_settings.go @@ -205,84 +205,85 @@ var defaultLintersSettings = LintersSettings{ type LintersSettings struct { FormatterSettings `mapstructure:"-"` - Asasalint AsasalintSettings `mapstructure:"asasalint"` - BiDiChk BiDiChkSettings `mapstructure:"bidichk"` - CopyLoopVar CopyLoopVarSettings `mapstructure:"copyloopvar"` - Cyclop CyclopSettings `mapstructure:"cyclop"` - Decorder DecorderSettings `mapstructure:"decorder"` - Depguard DepGuardSettings `mapstructure:"depguard"` - Dogsled DogsledSettings `mapstructure:"dogsled"` - Dupl DuplSettings `mapstructure:"dupl"` - DupWord DupWordSettings `mapstructure:"dupword"` - Errcheck ErrcheckSettings `mapstructure:"errcheck"` - ErrChkJSON ErrChkJSONSettings `mapstructure:"errchkjson"` - ErrorLint ErrorLintSettings `mapstructure:"errorlint"` - Exhaustive ExhaustiveSettings `mapstructure:"exhaustive"` - Exhaustruct ExhaustructSettings `mapstructure:"exhaustruct"` - Fatcontext FatcontextSettings `mapstructure:"fatcontext"` - Forbidigo ForbidigoSettings `mapstructure:"forbidigo"` - FuncOrder FuncOrderSettings `mapstructure:"funcorder"` - Funlen FunlenSettings `mapstructure:"funlen"` - GinkgoLinter GinkgoLinterSettings `mapstructure:"ginkgolinter"` - Gocognit GocognitSettings `mapstructure:"gocognit"` - GoChecksumType GoChecksumTypeSettings `mapstructure:"gochecksumtype"` - Goconst GoConstSettings `mapstructure:"goconst"` - Gocritic GoCriticSettings `mapstructure:"gocritic"` - Gocyclo GoCycloSettings `mapstructure:"gocyclo"` - Godot GodotSettings `mapstructure:"godot"` - Godox GodoxSettings `mapstructure:"godox"` - Goheader GoHeaderSettings `mapstructure:"goheader"` - GoModDirectives GoModDirectivesSettings `mapstructure:"gomoddirectives"` - Gomodguard GoModGuardSettings `mapstructure:"gomodguard"` - Gosec GoSecSettings `mapstructure:"gosec"` - Gosmopolitan GosmopolitanSettings `mapstructure:"gosmopolitan"` - Govet GovetSettings `mapstructure:"govet"` - Grouper GrouperSettings `mapstructure:"grouper"` - Iface IfaceSettings `mapstructure:"iface"` - ImportAs ImportAsSettings `mapstructure:"importas"` - Inamedparam INamedParamSettings `mapstructure:"inamedparam"` - InterfaceBloat InterfaceBloatSettings `mapstructure:"interfacebloat"` - Ireturn IreturnSettings `mapstructure:"ireturn"` - Lll LllSettings `mapstructure:"lll"` - LoggerCheck LoggerCheckSettings `mapstructure:"loggercheck"` - MaintIdx MaintIdxSettings `mapstructure:"maintidx"` - Makezero MakezeroSettings `mapstructure:"makezero"` - Misspell MisspellSettings `mapstructure:"misspell"` - Mnd MndSettings `mapstructure:"mnd"` - MustTag MustTagSettings `mapstructure:"musttag"` - Nakedret NakedretSettings `mapstructure:"nakedret"` - Nestif NestifSettings `mapstructure:"nestif"` - NilNil NilNilSettings `mapstructure:"nilnil"` - Nlreturn NlreturnSettings `mapstructure:"nlreturn"` - NoLintLint NoLintLintSettings `mapstructure:"nolintlint"` - NoNamedReturns NoNamedReturnsSettings `mapstructure:"nonamedreturns"` - ParallelTest ParallelTestSettings `mapstructure:"paralleltest"` - PerfSprint PerfSprintSettings `mapstructure:"perfsprint"` - Prealloc PreallocSettings `mapstructure:"prealloc"` - Predeclared PredeclaredSettings `mapstructure:"predeclared"` - Promlinter PromlinterSettings `mapstructure:"promlinter"` - ProtoGetter ProtoGetterSettings `mapstructure:"protogetter"` - Reassign ReassignSettings `mapstructure:"reassign"` - Recvcheck RecvcheckSettings `mapstructure:"recvcheck"` - Revive ReviveSettings `mapstructure:"revive"` - RowsErrCheck RowsErrCheckSettings `mapstructure:"rowserrcheck"` - SlogLint SlogLintSettings `mapstructure:"sloglint"` - Spancheck SpancheckSettings `mapstructure:"spancheck"` - Staticcheck StaticCheckSettings `mapstructure:"staticcheck"` - TagAlign TagAlignSettings `mapstructure:"tagalign"` - Tagliatelle TagliatelleSettings `mapstructure:"tagliatelle"` - Testifylint TestifylintSettings `mapstructure:"testifylint"` - Testpackage TestpackageSettings `mapstructure:"testpackage"` - Thelper ThelperSettings `mapstructure:"thelper"` - Unconvert UnconvertSettings `mapstructure:"unconvert"` - Unparam UnparamSettings `mapstructure:"unparam"` - Unused UnusedSettings `mapstructure:"unused"` - UseStdlibVars UseStdlibVarsSettings `mapstructure:"usestdlibvars"` - UseTesting UseTestingSettings `mapstructure:"usetesting"` - Varnamelen VarnamelenSettings `mapstructure:"varnamelen"` - Whitespace WhitespaceSettings `mapstructure:"whitespace"` - Wrapcheck WrapcheckSettings `mapstructure:"wrapcheck"` - WSL WSLSettings `mapstructure:"wsl"` + Asasalint AsasalintSettings `mapstructure:"asasalint"` + BiDiChk BiDiChkSettings `mapstructure:"bidichk"` + CopyLoopVar CopyLoopVarSettings `mapstructure:"copyloopvar"` + Cyclop CyclopSettings `mapstructure:"cyclop"` + Decorder DecorderSettings `mapstructure:"decorder"` + Depguard DepGuardSettings `mapstructure:"depguard"` + Dogsled DogsledSettings `mapstructure:"dogsled"` + Dupl DuplSettings `mapstructure:"dupl"` + DupWord DupWordSettings `mapstructure:"dupword"` + EmbeddedStructFieldCheck EmbeddedStructFieldCheckSettings `mapstructure:"embeddedstructfieldcheck"` + Errcheck ErrcheckSettings `mapstructure:"errcheck"` + ErrChkJSON ErrChkJSONSettings `mapstructure:"errchkjson"` + ErrorLint ErrorLintSettings `mapstructure:"errorlint"` + Exhaustive ExhaustiveSettings `mapstructure:"exhaustive"` + Exhaustruct ExhaustructSettings `mapstructure:"exhaustruct"` + Fatcontext FatcontextSettings `mapstructure:"fatcontext"` + Forbidigo ForbidigoSettings `mapstructure:"forbidigo"` + FuncOrder FuncOrderSettings `mapstructure:"funcorder"` + Funlen FunlenSettings `mapstructure:"funlen"` + GinkgoLinter GinkgoLinterSettings `mapstructure:"ginkgolinter"` + Gocognit GocognitSettings `mapstructure:"gocognit"` + GoChecksumType GoChecksumTypeSettings `mapstructure:"gochecksumtype"` + Goconst GoConstSettings `mapstructure:"goconst"` + Gocritic GoCriticSettings `mapstructure:"gocritic"` + Gocyclo GoCycloSettings `mapstructure:"gocyclo"` + Godot GodotSettings `mapstructure:"godot"` + Godox GodoxSettings `mapstructure:"godox"` + Goheader GoHeaderSettings `mapstructure:"goheader"` + GoModDirectives GoModDirectivesSettings `mapstructure:"gomoddirectives"` + Gomodguard GoModGuardSettings `mapstructure:"gomodguard"` + Gosec GoSecSettings `mapstructure:"gosec"` + Gosmopolitan GosmopolitanSettings `mapstructure:"gosmopolitan"` + Govet GovetSettings `mapstructure:"govet"` + Grouper GrouperSettings `mapstructure:"grouper"` + Iface IfaceSettings `mapstructure:"iface"` + ImportAs ImportAsSettings `mapstructure:"importas"` + Inamedparam INamedParamSettings `mapstructure:"inamedparam"` + InterfaceBloat InterfaceBloatSettings `mapstructure:"interfacebloat"` + Ireturn IreturnSettings `mapstructure:"ireturn"` + Lll LllSettings `mapstructure:"lll"` + LoggerCheck LoggerCheckSettings `mapstructure:"loggercheck"` + MaintIdx MaintIdxSettings `mapstructure:"maintidx"` + Makezero MakezeroSettings `mapstructure:"makezero"` + Misspell MisspellSettings `mapstructure:"misspell"` + Mnd MndSettings `mapstructure:"mnd"` + MustTag MustTagSettings `mapstructure:"musttag"` + Nakedret NakedretSettings `mapstructure:"nakedret"` + Nestif NestifSettings `mapstructure:"nestif"` + NilNil NilNilSettings `mapstructure:"nilnil"` + Nlreturn NlreturnSettings `mapstructure:"nlreturn"` + NoLintLint NoLintLintSettings `mapstructure:"nolintlint"` + NoNamedReturns NoNamedReturnsSettings `mapstructure:"nonamedreturns"` + ParallelTest ParallelTestSettings `mapstructure:"paralleltest"` + PerfSprint PerfSprintSettings `mapstructure:"perfsprint"` + Prealloc PreallocSettings `mapstructure:"prealloc"` + Predeclared PredeclaredSettings `mapstructure:"predeclared"` + Promlinter PromlinterSettings `mapstructure:"promlinter"` + ProtoGetter ProtoGetterSettings `mapstructure:"protogetter"` + Reassign ReassignSettings `mapstructure:"reassign"` + Recvcheck RecvcheckSettings `mapstructure:"recvcheck"` + Revive ReviveSettings `mapstructure:"revive"` + RowsErrCheck RowsErrCheckSettings `mapstructure:"rowserrcheck"` + SlogLint SlogLintSettings `mapstructure:"sloglint"` + Spancheck SpancheckSettings `mapstructure:"spancheck"` + Staticcheck StaticCheckSettings `mapstructure:"staticcheck"` + TagAlign TagAlignSettings `mapstructure:"tagalign"` + Tagliatelle TagliatelleSettings `mapstructure:"tagliatelle"` + Testifylint TestifylintSettings `mapstructure:"testifylint"` + Testpackage TestpackageSettings `mapstructure:"testpackage"` + Thelper ThelperSettings `mapstructure:"thelper"` + Unconvert UnconvertSettings `mapstructure:"unconvert"` + Unparam UnparamSettings `mapstructure:"unparam"` + Unused UnusedSettings `mapstructure:"unused"` + UseStdlibVars UseStdlibVarsSettings `mapstructure:"usestdlibvars"` + UseTesting UseTestingSettings `mapstructure:"usetesting"` + Varnamelen VarnamelenSettings `mapstructure:"varnamelen"` + Whitespace WhitespaceSettings `mapstructure:"whitespace"` + Wrapcheck WrapcheckSettings `mapstructure:"wrapcheck"` + WSL WSLSettings `mapstructure:"wsl"` Custom map[string]CustomLinterSettings `mapstructure:"custom"` } @@ -367,6 +368,10 @@ type DupWordSettings struct { Ignore []string `mapstructure:"ignore"` } +type EmbeddedStructFieldCheckSettings struct { + ForbidMutex bool `mapstructure:"forbid-mutex"` +} + type ErrcheckSettings struct { DisableDefaultExclusions bool `mapstructure:"disable-default-exclusions"` CheckTypeAssertions bool `mapstructure:"check-type-assertions"` diff --git a/pkg/golinters/embeddedstructfieldcheck/embeddedstructfieldcheck.go b/pkg/golinters/embeddedstructfieldcheck/embeddedstructfieldcheck.go index 0932ac4fed66..c9df5038c064 100644 --- a/pkg/golinters/embeddedstructfieldcheck/embeddedstructfieldcheck.go +++ b/pkg/golinters/embeddedstructfieldcheck/embeddedstructfieldcheck.go @@ -3,11 +3,21 @@ package embeddedstructfieldcheck import ( "github.com/manuelarte/embeddedstructfieldcheck/analyzer" + "github.com/golangci/golangci-lint/v2/pkg/config" "github.com/golangci/golangci-lint/v2/pkg/goanalysis" ) -func New() *goanalysis.Linter { +func New(settings *config.EmbeddedStructFieldCheckSettings) *goanalysis.Linter { + var cfg map[string]any + + if settings != nil { + cfg = map[string]any{ + analyzer.ForbidMutexName: settings.ForbidMutex, + } + } + return goanalysis. NewLinterFromAnalyzer(analyzer.NewAnalyzer()). + WithConfig(cfg). WithLoadMode(goanalysis.LoadModeSyntax) } diff --git a/pkg/golinters/embeddedstructfieldcheck/testdata/embeddedstructfieldcheck_comments.go b/pkg/golinters/embeddedstructfieldcheck/testdata/embeddedstructfieldcheck_comments.go index 12a6a4fa1ddf..8dd119ede62a 100644 --- a/pkg/golinters/embeddedstructfieldcheck/testdata/embeddedstructfieldcheck_comments.go +++ b/pkg/golinters/embeddedstructfieldcheck/testdata/embeddedstructfieldcheck_comments.go @@ -1,5 +1,5 @@ //golangcitest:args -Eembeddedstructfieldcheck -package simple +package testdata import "time" diff --git a/pkg/golinters/embeddedstructfieldcheck/testdata/embeddedstructfieldcheck_mutex.go b/pkg/golinters/embeddedstructfieldcheck/testdata/embeddedstructfieldcheck_mutex.go new file mode 100644 index 000000000000..e0a586ef6f02 --- /dev/null +++ b/pkg/golinters/embeddedstructfieldcheck/testdata/embeddedstructfieldcheck_mutex.go @@ -0,0 +1,29 @@ +//golangcitest:args -Eembeddedstructfieldcheck +//golangcitest:config_path testdata/embeddedstructfieldcheck_mutex.yml +package testdata + +import "sync" + +type MutextEmbedded struct { + sync.Mutex // want `sync.Mutex should not be embedded` +} + +type MutextNotEmbedded struct { + mu sync.Mutex +} + +type PointerMutextEmbedded struct { + *sync.Mutex // want `sync.Mutex should not be embedded` +} + +type RWMutextEmbedded struct { + sync.RWMutex // want `sync.RWMutex should not be embedded` +} + +type RWMutextNotEmbedded struct { + mu sync.RWMutex +} + +type PointerRWMutextEmbedded struct { + *sync.RWMutex // want `sync.RWMutex should not be embedded` +} diff --git a/pkg/golinters/embeddedstructfieldcheck/testdata/embeddedstructfieldcheck_mutex.yml b/pkg/golinters/embeddedstructfieldcheck/testdata/embeddedstructfieldcheck_mutex.yml new file mode 100644 index 000000000000..ff5e68bc81e3 --- /dev/null +++ b/pkg/golinters/embeddedstructfieldcheck/testdata/embeddedstructfieldcheck_mutex.yml @@ -0,0 +1,6 @@ +version: "2" + +linters: + settings: + embeddedstructfieldcheck: + forbid-mutex: true diff --git a/pkg/golinters/embeddedstructfieldcheck/testdata/embeddedstructfieldcheck_simple.go b/pkg/golinters/embeddedstructfieldcheck/testdata/embeddedstructfieldcheck_simple.go index 47b155e5f52a..da13d29c95f7 100644 --- a/pkg/golinters/embeddedstructfieldcheck/testdata/embeddedstructfieldcheck_simple.go +++ b/pkg/golinters/embeddedstructfieldcheck/testdata/embeddedstructfieldcheck_simple.go @@ -1,5 +1,5 @@ //golangcitest:args -Eembeddedstructfieldcheck -package simple +package testdata import ( "context" diff --git a/pkg/golinters/embeddedstructfieldcheck/testdata/embeddedstructfieldcheck_special_cases.go b/pkg/golinters/embeddedstructfieldcheck/testdata/embeddedstructfieldcheck_special_cases.go index 95b5356b5824..b9ae5f3e187c 100644 --- a/pkg/golinters/embeddedstructfieldcheck/testdata/embeddedstructfieldcheck_special_cases.go +++ b/pkg/golinters/embeddedstructfieldcheck/testdata/embeddedstructfieldcheck_special_cases.go @@ -1,5 +1,5 @@ //golangcitest:args -Eembeddedstructfieldcheck -package simple +package testdata import "time" diff --git a/pkg/lint/lintersdb/builder_linter.go b/pkg/lint/lintersdb/builder_linter.go index 37f18bdc9eae..48a64375f53c 100644 --- a/pkg/lint/lintersdb/builder_linter.go +++ b/pkg/lint/lintersdb/builder_linter.go @@ -213,7 +213,7 @@ func (LinterBuilder) Build(cfg *config.Config) ([]*linter.Config, error) { WithLoadForGoAnalysis(). WithURL("https://github.com/charithe/durationcheck"), - linter.NewConfig(embeddedstructfieldcheck.New()). + linter.NewConfig(embeddedstructfieldcheck.New(&cfg.Linters.Settings.EmbeddedStructFieldCheck)). WithSince("v2.2.0"). WithURL("https://github.com/manuelarte/embeddedstructfieldcheck"), From f40f9d70b29e63faa798e685c7024383d536640a Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 19 May 2025 00:21:49 +0200 Subject: [PATCH 66/96] build(deps): bump github.com/golangci/misspell from 0.6.0 to 0.7.0 (#5813) --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 7a1711e4277a..cdc954f4ad7b 100644 --- a/go.mod +++ b/go.mod @@ -48,7 +48,7 @@ require ( github.com/golangci/go-printf-func-name v0.1.0 github.com/golangci/gofmt v0.0.0-20250106114630-d62b90e6713d github.com/golangci/golines v0.0.0-20250217134842-442fd0091d95 - github.com/golangci/misspell v0.6.0 + github.com/golangci/misspell v0.7.0 github.com/golangci/plugin-module-register v0.1.1 github.com/golangci/revgrep v0.8.0 github.com/golangci/swaggoswag v0.0.0-20250504205917-77f2aca3143e diff --git a/go.sum b/go.sum index ba8cde2b19d6..41ec9620c99d 100644 --- a/go.sum +++ b/go.sum @@ -257,8 +257,8 @@ github.com/golangci/gofmt v0.0.0-20250106114630-d62b90e6713d h1:viFft9sS/dxoYY0a github.com/golangci/gofmt v0.0.0-20250106114630-d62b90e6713d/go.mod h1:ivJ9QDg0XucIkmwhzCDsqcnxxlDStoTl89jDMIoNxKY= github.com/golangci/golines v0.0.0-20250217134842-442fd0091d95 h1:AkK+w9FZBXlU/xUmBtSJN1+tAI4FIvy5WtnUnY8e4p8= github.com/golangci/golines v0.0.0-20250217134842-442fd0091d95/go.mod h1:k9mmcyWKSTMcPPvQUCfRWWQ9VHJ1U9Dc0R7kaXAgtnQ= -github.com/golangci/misspell v0.6.0 h1:JCle2HUTNWirNlDIAUO44hUsKhOFqGPoC4LZxlaSXDs= -github.com/golangci/misspell v0.6.0/go.mod h1:keMNyY6R9isGaSAu+4Q8NMBwMPkh15Gtc8UCVoDtAWo= +github.com/golangci/misspell v0.7.0 h1:4GOHr/T1lTW0hhR4tgaaV1WS/lJ+ncvYCoFKmqJsj0c= +github.com/golangci/misspell v0.7.0/go.mod h1:WZyyI2P3hxPY2UVHs3cS8YcllAeyfquQcKfdeE9AFVg= github.com/golangci/plugin-module-register v0.1.1 h1:TCmesur25LnyJkpsVrupv1Cdzo+2f7zX0H6Jkw1Ol6c= github.com/golangci/plugin-module-register v0.1.1/go.mod h1:TTpqoB6KkwOJMV8u7+NyXMrkwwESJLOkfl9TxR1DGFc= github.com/golangci/revgrep v0.8.0 h1:EZBctwbVd0aMeRnNUsFogoyayvKHyxlV3CdUA46FX2s= From 48d1da459b3ebd905519d870bfb15b12890fb544 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 19 May 2025 00:22:12 +0200 Subject: [PATCH 67/96] build(deps): bump the linter-testdata group across 2 directories with 2 updates (#5814) Co-authored-by: Fernandez Ludovic --- pkg/golinters/arangolint/testdata/go.mod | 10 +++++----- pkg/golinters/arangolint/testdata/go.sum | 21 +++++++++++---------- pkg/golinters/exptostd/testdata/go.mod | 4 ++-- pkg/golinters/exptostd/testdata/go.sum | 4 ++-- pkg/golinters/ginkgolinter/testdata/go.mod | 8 ++++---- pkg/golinters/ginkgolinter/testdata/go.sum | 16 ++++++++-------- pkg/golinters/gomodguard/testdata/go.mod | 4 ++-- pkg/golinters/gomodguard/testdata/go.sum | 2 ++ pkg/golinters/protogetter/testdata/go.mod | 8 ++++---- pkg/golinters/protogetter/testdata/go.sum | 16 ++++++++-------- pkg/golinters/zerologlint/testdata/go.mod | 2 +- pkg/golinters/zerologlint/testdata/go.sum | 4 ++-- 12 files changed, 51 insertions(+), 48 deletions(-) diff --git a/pkg/golinters/arangolint/testdata/go.mod b/pkg/golinters/arangolint/testdata/go.mod index c9d56c70228d..0fb1fc8b4a4e 100644 --- a/pkg/golinters/arangolint/testdata/go.mod +++ b/pkg/golinters/arangolint/testdata/go.mod @@ -9,11 +9,11 @@ require ( github.com/dchest/siphash v1.2.3 // indirect github.com/google/uuid v1.6.0 // indirect github.com/kkdai/maglev v0.2.0 // indirect - github.com/mattn/go-colorable v0.1.13 // indirect + github.com/mattn/go-colorable v0.1.14 // indirect github.com/mattn/go-isatty v0.0.20 // indirect github.com/pkg/errors v0.9.1 // indirect - github.com/rs/zerolog v1.33.0 // indirect - golang.org/x/net v0.33.0 // indirect - golang.org/x/sys v0.28.0 // indirect - golang.org/x/text v0.21.0 // indirect + github.com/rs/zerolog v1.34.0 // indirect + golang.org/x/net v0.40.0 // indirect + golang.org/x/sys v0.33.0 // indirect + golang.org/x/text v0.25.0 // indirect ) diff --git a/pkg/golinters/arangolint/testdata/go.sum b/pkg/golinters/arangolint/testdata/go.sum index 9f27a49c38c8..69d72038590d 100644 --- a/pkg/golinters/arangolint/testdata/go.sum +++ b/pkg/golinters/arangolint/testdata/go.sum @@ -14,8 +14,9 @@ github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/kkdai/maglev v0.2.0 h1:w6DCW0kAA6fstZqXkrBrlgIC3jeIRXkjOYea/m6EK/Y= github.com/kkdai/maglev v0.2.0/go.mod h1:d+mt8Lmt3uqi9aRb/BnPjzD0fy+ETs1vVXiGRnqHVZ4= -github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA= github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg= +github.com/mattn/go-colorable v0.1.14 h1:9A9LHSqF/7dyVVX6g0U9cwm9pG3kP9gSzcuIPHPsaIE= +github.com/mattn/go-colorable v0.1.14/go.mod h1:6LmQG8QLFO4G5z1gPvYEzlUgJ2wF+stgPZH1UqBm1s8= github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= github.com/mattn/go-isatty v0.0.19/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= @@ -24,22 +25,22 @@ github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/rs/xid v1.5.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg= -github.com/rs/zerolog v1.33.0 h1:1cU2KZkvPxNyfgEmhHAz/1A9Bz+llsdYzklWFzgp0r8= -github.com/rs/zerolog v1.33.0/go.mod h1:/7mN4D5sKwJLZQ2b/znpjC3/GQWY/xaDXUM0kKWRHss= +github.com/rs/xid v1.6.0/go.mod h1:7XoLgs4eV+QndskICGsho+ADou8ySMSjJKDIan90Nz0= +github.com/rs/zerolog v1.34.0 h1:k43nTLIwcTVQAncfCw4KZ2VY6ukYoZaBPNOE8txlOeY= +github.com/rs/zerolog v1.34.0/go.mod h1:bJsvje4Z08ROH4Nhs5iH600c3IkWhwp44iRc54W6wYQ= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= -golang.org/x/net v0.33.0 h1:74SYHlV8BIgHIFC/LrYkOGIwL19eTYXQ5wc6TBuO36I= -golang.org/x/net v0.33.0/go.mod h1:HXLR5J+9DxmrqMwG9qjGCxZ+zKXxBru04zlTvWlWuN4= +golang.org/x/net v0.40.0 h1:79Xs7wF06Gbdcg4kdCCIQArK11Z1hr5POQ6+fIYHNuY= +golang.org/x/net v0.40.0/go.mod h1:y0hY0exeL2Pku80/zKK7tpntoX23cqL3Oa6njdgRtds= golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.28.0 h1:Fksou7UEQUWlKvIdsqzJmUmCX3cZuD2+P3XyyzwMhlA= -golang.org/x/sys v0.28.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= -golang.org/x/text v0.21.0 h1:zyQAAkrwaneQ066sspRyJaG9VNi/YJ1NfzcGB3hZ/qo= -golang.org/x/text v0.21.0/go.mod h1:4IBbMaMmOPCJ8SecivzSH54+73PCFmPWxNTLm+vZkEQ= +golang.org/x/sys v0.33.0 h1:q3i8TbbEz+JRD9ywIRlyRAQbM0qF7hu24q3teo2hbuw= +golang.org/x/sys v0.33.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k= +golang.org/x/text v0.25.0 h1:qVyWApTSYLk/drJRO5mDlNYskwQznZmkpV2c8q9zls4= +golang.org/x/text v0.25.0/go.mod h1:WEdwpYrmk1qmdHvhkSTNPm3app7v4rsT8F2UD6+VHIA= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= diff --git a/pkg/golinters/exptostd/testdata/go.mod b/pkg/golinters/exptostd/testdata/go.mod index 5261142a3036..3bd4f2c04ce5 100644 --- a/pkg/golinters/exptostd/testdata/go.mod +++ b/pkg/golinters/exptostd/testdata/go.mod @@ -1,5 +1,5 @@ module exptostd -go 1.22.0 +go 1.23.0 -require golang.org/x/exp v0.0.0-20241217172543-b2144cdd0a67 +require golang.org/x/exp v0.0.0-20250506013437-ce4c2cf36ca6 diff --git a/pkg/golinters/exptostd/testdata/go.sum b/pkg/golinters/exptostd/testdata/go.sum index c487fae960b3..2fbef45b9043 100644 --- a/pkg/golinters/exptostd/testdata/go.sum +++ b/pkg/golinters/exptostd/testdata/go.sum @@ -1,2 +1,2 @@ -golang.org/x/exp v0.0.0-20241217172543-b2144cdd0a67 h1:1UoZQm6f0P/ZO0w1Ri+f+ifG/gXhegadRdwBIXEFWDo= -golang.org/x/exp v0.0.0-20241217172543-b2144cdd0a67/go.mod h1:qj5a5QZpwLU2NLQudwIN5koi3beDhSAlJwa67PuM98c= +golang.org/x/exp v0.0.0-20250506013437-ce4c2cf36ca6 h1:y5zboxd6LQAqYIhHnB48p0ByQ/GnQx2BE33L8BOHQkI= +golang.org/x/exp v0.0.0-20250506013437-ce4c2cf36ca6/go.mod h1:U6Lno4MTRCDY+Ba7aCcauB9T60gsv5s4ralQzP72ZoQ= diff --git a/pkg/golinters/ginkgolinter/testdata/go.mod b/pkg/golinters/ginkgolinter/testdata/go.mod index fe2cc945898c..ede5795987b6 100644 --- a/pkg/golinters/ginkgolinter/testdata/go.mod +++ b/pkg/golinters/ginkgolinter/testdata/go.mod @@ -13,9 +13,9 @@ require ( github.com/google/go-cmp v0.7.0 // indirect github.com/google/pprof v0.0.0-20250403155104-27863c87afa6 // indirect go.uber.org/automaxprocs v1.6.0 // indirect - golang.org/x/net v0.37.0 // indirect - golang.org/x/sys v0.32.0 // indirect - golang.org/x/text v0.23.0 // indirect - golang.org/x/tools v0.31.0 // indirect + golang.org/x/net v0.40.0 // indirect + golang.org/x/sys v0.33.0 // indirect + golang.org/x/text v0.25.0 // indirect + golang.org/x/tools v0.33.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/pkg/golinters/ginkgolinter/testdata/go.sum b/pkg/golinters/ginkgolinter/testdata/go.sum index 0acd79618257..bbd84ab067c2 100644 --- a/pkg/golinters/ginkgolinter/testdata/go.sum +++ b/pkg/golinters/ginkgolinter/testdata/go.sum @@ -24,14 +24,14 @@ github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcU github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= go.uber.org/automaxprocs v1.6.0 h1:O3y2/QNTOdbF+e/dpXNNW7Rx2hZ4sTIPyybbxyNqTUs= go.uber.org/automaxprocs v1.6.0/go.mod h1:ifeIMSnPZuznNm6jmdzmU3/bfk01Fe2fotchwEFJ8r8= -golang.org/x/net v0.37.0 h1:1zLorHbz+LYj7MQlSf1+2tPIIgibq2eL5xkrGk6f+2c= -golang.org/x/net v0.37.0/go.mod h1:ivrbrMbzFq5J41QOQh0siUuly180yBYtLp+CKbEaFx8= -golang.org/x/sys v0.32.0 h1:s77OFDvIQeibCmezSnk/q6iAfkdiQaJi4VzroCFrN20= -golang.org/x/sys v0.32.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k= -golang.org/x/text v0.23.0 h1:D71I7dUrlY+VX0gQShAThNGHFxZ13dGLBHQLVl1mJlY= -golang.org/x/text v0.23.0/go.mod h1:/BLNzu4aZCJ1+kcD0DNRotWKage4q2rGVAg4o22unh4= -golang.org/x/tools v0.31.0 h1:0EedkvKDbh+qistFTd0Bcwe/YLh4vHwWEkiI0toFIBU= -golang.org/x/tools v0.31.0/go.mod h1:naFTU+Cev749tSJRXJlna0T3WxKvb1kWEx15xA4SdmQ= +golang.org/x/net v0.40.0 h1:79Xs7wF06Gbdcg4kdCCIQArK11Z1hr5POQ6+fIYHNuY= +golang.org/x/net v0.40.0/go.mod h1:y0hY0exeL2Pku80/zKK7tpntoX23cqL3Oa6njdgRtds= +golang.org/x/sys v0.33.0 h1:q3i8TbbEz+JRD9ywIRlyRAQbM0qF7hu24q3teo2hbuw= +golang.org/x/sys v0.33.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k= +golang.org/x/text v0.25.0 h1:qVyWApTSYLk/drJRO5mDlNYskwQznZmkpV2c8q9zls4= +golang.org/x/text v0.25.0/go.mod h1:WEdwpYrmk1qmdHvhkSTNPm3app7v4rsT8F2UD6+VHIA= +golang.org/x/tools v0.33.0 h1:4qz2S3zmRxbGIhDIAgjxvFutSvH5EfnsYrRBj0UI0bc= +golang.org/x/tools v0.33.0/go.mod h1:CIJMaWEY88juyUfo7UbgPqbC8rU2OqfAV1h2Qp0oMYI= google.golang.org/protobuf v1.36.5 h1:tPhr+woSbjfYvY6/GPufUoYizxw1cF/yFoxJ2fmpwlM= google.golang.org/protobuf v1.36.5/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= diff --git a/pkg/golinters/gomodguard/testdata/go.mod b/pkg/golinters/gomodguard/testdata/go.mod index ab174ed19807..c5512cba7f95 100644 --- a/pkg/golinters/gomodguard/testdata/go.mod +++ b/pkg/golinters/gomodguard/testdata/go.mod @@ -1,8 +1,8 @@ module gomodguard -go 1.22.0 +go 1.23.0 require ( - golang.org/x/mod v0.22.0 + golang.org/x/mod v0.24.0 gopkg.in/yaml.v3 v3.0.1 ) diff --git a/pkg/golinters/gomodguard/testdata/go.sum b/pkg/golinters/gomodguard/testdata/go.sum index 7c483c93b9e0..5dce74976ef5 100644 --- a/pkg/golinters/gomodguard/testdata/go.sum +++ b/pkg/golinters/gomodguard/testdata/go.sum @@ -1,5 +1,7 @@ golang.org/x/mod v0.22.0 h1:D4nJWe9zXqHOmWqj4VMOJhvzj7bEZg4wEYa759z1pH4= golang.org/x/mod v0.22.0/go.mod h1:6SkKJ3Xj0I0BrPOZoBy3bdMptDDU9oJrpohJ3eWZ1fY= +golang.org/x/mod v0.24.0 h1:ZfthKaKaT4NrhGVZHO1/WDTwGES4De8KtWO0SIbNJMU= +golang.org/x/mod v0.24.0/go.mod h1:IXM97Txy2VM4PJ3gI61r1YEk/gAj6zAHN3AdZt6S9Ww= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= diff --git a/pkg/golinters/protogetter/testdata/go.mod b/pkg/golinters/protogetter/testdata/go.mod index 0cca1725136e..894a03ffa01e 100644 --- a/pkg/golinters/protogetter/testdata/go.mod +++ b/pkg/golinters/protogetter/testdata/go.mod @@ -3,13 +3,13 @@ module protogetter go 1.23.0 require ( - google.golang.org/grpc v1.72.0 + google.golang.org/grpc v1.72.1 google.golang.org/protobuf v1.36.6 ) require ( - golang.org/x/net v0.38.0 // indirect - golang.org/x/sys v0.31.0 // indirect - golang.org/x/text v0.23.0 // indirect + golang.org/x/net v0.40.0 // indirect + golang.org/x/sys v0.33.0 // indirect + golang.org/x/text v0.25.0 // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20250218202821-56aae31c358a // indirect ) diff --git a/pkg/golinters/protogetter/testdata/go.sum b/pkg/golinters/protogetter/testdata/go.sum index 11d34e556344..99952097dc15 100644 --- a/pkg/golinters/protogetter/testdata/go.sum +++ b/pkg/golinters/protogetter/testdata/go.sum @@ -20,15 +20,15 @@ go.opentelemetry.io/otel/sdk/metric v1.34.0 h1:5CeK9ujjbFVL5c1PhLuStg1wxA7vQv7ce go.opentelemetry.io/otel/sdk/metric v1.34.0/go.mod h1:jQ/r8Ze28zRKoNRdkjCZxfs6YvBTG1+YIqyFVFYec5w= go.opentelemetry.io/otel/trace v1.34.0 h1:+ouXS2V8Rd4hp4580a8q23bg0azF2nI8cqLYnC8mh/k= go.opentelemetry.io/otel/trace v1.34.0/go.mod h1:Svm7lSjQD7kG7KJ/MUHPVXSDGz2OX4h0M2jHBhmSfRE= -golang.org/x/net v0.38.0 h1:vRMAPTMaeGqVhG5QyLJHqNDwecKTomGeqbnfZyKlBI8= -golang.org/x/net v0.38.0/go.mod h1:ivrbrMbzFq5J41QOQh0siUuly180yBYtLp+CKbEaFx8= -golang.org/x/sys v0.31.0 h1:ioabZlmFYtWhL+TRYpcnNlLwhyxaM9kWTDEmfnprqik= -golang.org/x/sys v0.31.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k= -golang.org/x/text v0.23.0 h1:D71I7dUrlY+VX0gQShAThNGHFxZ13dGLBHQLVl1mJlY= -golang.org/x/text v0.23.0/go.mod h1:/BLNzu4aZCJ1+kcD0DNRotWKage4q2rGVAg4o22unh4= +golang.org/x/net v0.40.0 h1:79Xs7wF06Gbdcg4kdCCIQArK11Z1hr5POQ6+fIYHNuY= +golang.org/x/net v0.40.0/go.mod h1:y0hY0exeL2Pku80/zKK7tpntoX23cqL3Oa6njdgRtds= +golang.org/x/sys v0.33.0 h1:q3i8TbbEz+JRD9ywIRlyRAQbM0qF7hu24q3teo2hbuw= +golang.org/x/sys v0.33.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k= +golang.org/x/text v0.25.0 h1:qVyWApTSYLk/drJRO5mDlNYskwQznZmkpV2c8q9zls4= +golang.org/x/text v0.25.0/go.mod h1:WEdwpYrmk1qmdHvhkSTNPm3app7v4rsT8F2UD6+VHIA= google.golang.org/genproto/googleapis/rpc v0.0.0-20250218202821-56aae31c358a h1:51aaUVRocpvUOSQKM6Q7VuoaktNIaMCLuhZB6DKksq4= google.golang.org/genproto/googleapis/rpc v0.0.0-20250218202821-56aae31c358a/go.mod h1:uRxBH1mhmO8PGhU89cMcHaXKZqO+OfakD8QQO0oYwlQ= -google.golang.org/grpc v1.72.0 h1:S7UkcVa60b5AAQTaO6ZKamFp1zMZSU0fGDK2WZLbBnM= -google.golang.org/grpc v1.72.0/go.mod h1:wH5Aktxcg25y1I3w7H69nHfXdOG3UiadoBtjh3izSDM= +google.golang.org/grpc v1.72.1 h1:HR03wO6eyZ7lknl75XlxABNVLLFc2PAb6mHlYh756mA= +google.golang.org/grpc v1.72.1/go.mod h1:wH5Aktxcg25y1I3w7H69nHfXdOG3UiadoBtjh3izSDM= google.golang.org/protobuf v1.36.6 h1:z1NpPI8ku2WgiWnf+t9wTPsn6eP1L7ksHUlkfLvd9xY= google.golang.org/protobuf v1.36.6/go.mod h1:jduwjTPXsFjZGTmRluh+L6NjiWu7pchiJ2/5YcXBHnY= diff --git a/pkg/golinters/zerologlint/testdata/go.mod b/pkg/golinters/zerologlint/testdata/go.mod index 42508c71c705..6e255ef19b13 100644 --- a/pkg/golinters/zerologlint/testdata/go.mod +++ b/pkg/golinters/zerologlint/testdata/go.mod @@ -7,5 +7,5 @@ require github.com/rs/zerolog v1.34.0 require ( github.com/mattn/go-colorable v0.1.14 // indirect github.com/mattn/go-isatty v0.0.20 // indirect - golang.org/x/sys v0.31.0 // indirect + golang.org/x/sys v0.33.0 // indirect ) diff --git a/pkg/golinters/zerologlint/testdata/go.sum b/pkg/golinters/zerologlint/testdata/go.sum index 4c01b0c5ed90..3b0d10eedda7 100644 --- a/pkg/golinters/zerologlint/testdata/go.sum +++ b/pkg/golinters/zerologlint/testdata/go.sum @@ -14,5 +14,5 @@ github.com/rs/zerolog v1.34.0/go.mod h1:bJsvje4Z08ROH4Nhs5iH600c3IkWhwp44iRc54W6 golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.31.0 h1:ioabZlmFYtWhL+TRYpcnNlLwhyxaM9kWTDEmfnprqik= -golang.org/x/sys v0.31.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k= +golang.org/x/sys v0.33.0 h1:q3i8TbbEz+JRD9ywIRlyRAQbM0qF7hu24q3teo2hbuw= +golang.org/x/sys v0.33.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k= From 1c222b488bbc2c0ae2cad8423a24b8452f2fc3a9 Mon Sep 17 00:00:00 2001 From: Ludovic Fernandez Date: Mon, 19 May 2025 22:46:51 +0200 Subject: [PATCH 68/96] dev: consistent version (#5817) --- cmd/golangci-lint/main.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/cmd/golangci-lint/main.go b/cmd/golangci-lint/main.go index f7f3091dc653..acb09cd8c0be 100644 --- a/cmd/golangci-lint/main.go +++ b/cmd/golangci-lint/main.go @@ -4,7 +4,9 @@ import ( "cmp" "fmt" "os" + "regexp" "runtime/debug" + "strings" "github.com/golangci/golangci-lint/v2/pkg/commands" "github.com/golangci/golangci-lint/v2/pkg/exitcodes" @@ -23,7 +25,7 @@ func main() { info := createBuildInfo() if err := commands.Execute(info); err != nil { - _, _ = fmt.Fprintf(os.Stderr, "Failed executing command with error: %v\n", err) + _, _ = fmt.Fprintf(os.Stderr, "The command is terminated due to an error: %v\n", err) os.Exit(exitcodes.Failure) } } @@ -49,6 +51,11 @@ func createBuildInfo() commands.BuildInfo { info.Version = buildInfo.Main.Version + matched, _ := regexp.MatchString(`v\d+\.\d+\.\d+`, buildInfo.Main.Version) + if matched { + info.Version = strings.TrimPrefix(buildInfo.Main.Version, "v") + } + var revision string var modified string for _, setting := range buildInfo.Settings { From 79fb722b27d3ecb1b68ce759e14b32da1b15f4ed Mon Sep 17 00:00:00 2001 From: Ludovic Fernandez Date: Mon, 19 May 2025 22:47:11 +0200 Subject: [PATCH 69/96] docs: add description for linters.default sets (#5818) --- .golangci.next.reference.yml | 10 ++++++---- .golangci.reference.yml | 8 +++++--- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/.golangci.next.reference.yml b/.golangci.next.reference.yml index 8a4fc69e22b1..fa205ce7596f 100644 --- a/.golangci.next.reference.yml +++ b/.golangci.next.reference.yml @@ -10,12 +10,15 @@ version: "2" linters: # Default set of linters. - # The value can be: `standard`, `all`, `none`, or `fast`. + # The value can be: + # - `standard`: https://golangci-lint.run/usage/linters/#enabled-by-default + # - `all`: enables all linters by default. + # - `none`: disables all linters by default. + # - `fast`: enables only linters considered as "fast" (`golangci-lint help linters --json | jq '[ .[] | select(.fast==true) ] | map(.name)'`). # Default: standard default: all # Enable specific linter. - # https://golangci-lint.run/usage/linters/#enabled-by-default enable: - arangolint - asasalint @@ -124,8 +127,7 @@ linters: - wsl - zerologlint - # Disable specific linter. - # https://golangci-lint.run/usage/linters/#disabled-by-default + # Disable specific linters. disable: - arangolint - asasalint diff --git a/.golangci.reference.yml b/.golangci.reference.yml index 6aad45d89868..38b1d26ed729 100644 --- a/.golangci.reference.yml +++ b/.golangci.reference.yml @@ -10,12 +10,15 @@ version: "2" linters: # Default set of linters. - # The value can be: `standard`, `all`, `none`, or `fast`. + # The value can be: + # - `standard`: https://golangci-lint.run/usage/linters/#enabled-by-default + # - `all`: enables all linters by default. + # - `none`: disables all linters by default. + # - `fast`: enables only linters considered as "fast" (`golangci-lint help linters --json | jq '[ .[] | select(.fast==true) ] | map(.name)'`). # Default: standard default: all # Enable specific linter. - # https://golangci-lint.run/usage/linters/#enabled-by-default enable: - asasalint - asciicheck @@ -123,7 +126,6 @@ linters: - zerologlint # Disable specific linter. - # https://golangci-lint.run/usage/linters/#disabled-by-default disable: - asasalint - asciicheck From 36ddc0e035ac1892701dbff8c64980959b5f8f1c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 20 May 2025 20:25:19 +0200 Subject: [PATCH 70/96] build(deps): bump github.com/uudashr/iface from 1.3.2 to 1.4.0 (#5820) Co-authored-by: Fernandez Ludovic --- .golangci.next.reference.yml | 1 + go.mod | 2 +- go.sum | 4 +- jsonschema/golangci.next.jsonschema.json | 3 +- pkg/golinters/iface/iface.go | 8 +- pkg/golinters/iface/testdata/iface_all.go | 8 +- pkg/golinters/iface/testdata/iface_cgo.go | 4 +- pkg/golinters/iface/testdata/iface_default.go | 4 +- .../iface/testdata/iface_identical.go | 4 +- pkg/golinters/iface/testdata/iface_opaque.go | 2 +- .../iface/testdata/iface_unexported.go | 84 +++++++++++++++++++ .../iface/testdata/iface_unexported.yml | 7 ++ pkg/golinters/iface/testdata/iface_unused.go | 6 +- 13 files changed, 116 insertions(+), 21 deletions(-) create mode 100644 pkg/golinters/iface/testdata/iface_unexported.go create mode 100644 pkg/golinters/iface/testdata/iface_unexported.yml diff --git a/.golangci.next.reference.yml b/.golangci.next.reference.yml index fa205ce7596f..4c8e1615682b 100644 --- a/.golangci.next.reference.yml +++ b/.golangci.next.reference.yml @@ -1795,6 +1795,7 @@ linters: - identical # Identifies interfaces in the same package that have identical method sets. - unused # Identifies interfaces that are not used anywhere in the same package where the interface is defined. - opaque # Identifies functions that return interfaces, but the actual returned value is always a single concrete implementation. + - unexported # Identifies interfaces that are not exported but are used in exported functions or methods. settings: unused: # List of packages path to exclude from the check. diff --git a/go.mod b/go.mod index cdc954f4ad7b..03810322d94d 100644 --- a/go.mod +++ b/go.mod @@ -119,7 +119,7 @@ require ( github.com/ultraware/funlen v0.2.0 github.com/ultraware/whitespace v0.2.0 github.com/uudashr/gocognit v1.2.0 - github.com/uudashr/iface v1.3.2 + github.com/uudashr/iface v1.4.0 github.com/valyala/quicktemplate v1.8.0 github.com/xen0n/gosmopolitan v1.3.0 github.com/yagipy/maintidx v1.0.0 diff --git a/go.sum b/go.sum index 41ec9620c99d..2c8a91e0c1b7 100644 --- a/go.sum +++ b/go.sum @@ -598,8 +598,8 @@ github.com/ultraware/whitespace v0.2.0 h1:TYowo2m9Nfj1baEQBjuHzvMRbp19i+RCcRYrSW github.com/ultraware/whitespace v0.2.0/go.mod h1:XcP1RLD81eV4BW8UhQlpaR+SDc2givTvyI8a586WjW8= github.com/uudashr/gocognit v1.2.0 h1:3BU9aMr1xbhPlvJLSydKwdLN3tEUUrzPSSM8S4hDYRA= github.com/uudashr/gocognit v1.2.0/go.mod h1:k/DdKPI6XBZO1q7HgoV2juESI2/Ofj9AcHPZhBBdrTU= -github.com/uudashr/iface v1.3.2 h1:viQ7WtLvznR+Z4H+IP/fqhqPl3UF9Y2aj6wTeHF6X+Y= -github.com/uudashr/iface v1.3.2/go.mod h1:i/H4cfRMPe0izticV8Yz0g6/zcsh5xXlvthrdh1kqcY= +github.com/uudashr/iface v1.4.0 h1:ImZ+1oEJPXvjap7nK0md7gA9RRH7PMp4vliaLkJ2+cg= +github.com/uudashr/iface v1.4.0/go.mod h1:i/H4cfRMPe0izticV8Yz0g6/zcsh5xXlvthrdh1kqcY= github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw= github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc= github.com/valyala/quicktemplate v1.8.0 h1:zU0tjbIqTRgKQzFY1L42zq0qR3eh4WoQQdIdqCysW5k= diff --git a/jsonschema/golangci.next.jsonschema.json b/jsonschema/golangci.next.jsonschema.json index ef1c956ef1c4..1bd33923a5de 100644 --- a/jsonschema/golangci.next.jsonschema.json +++ b/jsonschema/golangci.next.jsonschema.json @@ -661,7 +661,8 @@ "enum": [ "identical", "unused", - "opaque" + "opaque", + "unexported" ] }, "tagliatelle-cases": { diff --git a/pkg/golinters/iface/iface.go b/pkg/golinters/iface/iface.go index a3c2816d4385..0a4a38abc931 100644 --- a/pkg/golinters/iface/iface.go +++ b/pkg/golinters/iface/iface.go @@ -5,6 +5,7 @@ import ( "github.com/uudashr/iface/identical" "github.com/uudashr/iface/opaque" + "github.com/uudashr/iface/unexported" "github.com/uudashr/iface/unused" "golang.org/x/tools/go/analysis" @@ -28,9 +29,10 @@ func New(settings *config.IfaceSettings) *goanalysis.Linter { func analyzersFromSettings(settings *config.IfaceSettings) []*analysis.Analyzer { allAnalyzers := map[string]*analysis.Analyzer{ - "identical": identical.Analyzer, - "unused": unused.Analyzer, - "opaque": opaque.Analyzer, + "identical": identical.Analyzer, + "unused": unused.Analyzer, + "opaque": opaque.Analyzer, + "unexported": unexported.Analyzer, } if settings == nil || len(settings.Enable) == 0 { diff --git a/pkg/golinters/iface/testdata/iface_all.go b/pkg/golinters/iface/testdata/iface_all.go index 3a6f912a1d2a..3dd95cdc24bf 100644 --- a/pkg/golinters/iface/testdata/iface_all.go +++ b/pkg/golinters/iface/testdata/iface_all.go @@ -6,11 +6,11 @@ import "fmt" // identical -type Pinger interface { // want "identical: interface Pinger contains identical methods or type constraints from another interface, causing redundancy" +type Pinger interface { // want "identical: interface 'Pinger' contains identical methods or type constraints with another interface, causing redundancy" Ping() error } -type Healthcheck interface { // want "identical: interface Healthcheck contains identical methods or type constraints from another interface, causing redundancy" +type Healthcheck interface { // want "identical: interface 'Healthcheck' contains identical methods or type constraints with another interface, causing redundancy" Ping() error } @@ -28,7 +28,7 @@ func (s server) Serve() error { return nil } -func NewServer(addr string) Server { // want "opaque: NewServer function return Server interface at the 1st result, abstract a single concrete implementation of \\*server" +func NewServer(addr string) Server { // want "opaque: 'NewServer' function return 'Server' interface at the 1st result, abstract a single concrete implementation of '\\*server'" return &server{addr: addr} } @@ -39,7 +39,7 @@ type User struct { Name string } -type UserRepository interface { // want "unused: interface UserRepository is declared but not used within the package" +type UserRepository interface { // want "unused: interface 'UserRepository' is declared but not used within the package" UserOf(id string) (*User, error) } diff --git a/pkg/golinters/iface/testdata/iface_cgo.go b/pkg/golinters/iface/testdata/iface_cgo.go index 43ef0216a036..16a9944854f0 100644 --- a/pkg/golinters/iface/testdata/iface_cgo.go +++ b/pkg/golinters/iface/testdata/iface_cgo.go @@ -24,11 +24,11 @@ func _() { // identical -type Pinger interface { // want "identical: interface Pinger contains identical methods or type constraints from another interface, causing redundancy" +type Pinger interface { // want "identical: interface 'Pinger' contains identical methods or type constraints with another interface, causing redundancy" Ping() error } -type Healthcheck interface { // want "identical: interface Healthcheck contains identical methods or type constraints from another interface, causing redundancy" +type Healthcheck interface { // want "identical: interface 'Healthcheck' contains identical methods or type constraints with another interface, causing redundancy" Ping() error } diff --git a/pkg/golinters/iface/testdata/iface_default.go b/pkg/golinters/iface/testdata/iface_default.go index 34117389738b..d0344b36c58f 100644 --- a/pkg/golinters/iface/testdata/iface_default.go +++ b/pkg/golinters/iface/testdata/iface_default.go @@ -5,11 +5,11 @@ import "fmt" // identical -type Pinger interface { // want "identical: interface Pinger contains identical methods or type constraints from another interface, causing redundancy" +type Pinger interface { // want "identical: interface 'Pinger' contains identical methods or type constraints with another interface, causing redundancy" Ping() error } -type Healthcheck interface { // want "identical: interface Healthcheck contains identical methods or type constraints from another interface, causing redundancy" +type Healthcheck interface { // want "identical: interface 'Healthcheck' contains identical methods or type constraints with another interface, causing redundancy" Ping() error } diff --git a/pkg/golinters/iface/testdata/iface_identical.go b/pkg/golinters/iface/testdata/iface_identical.go index 821aff7bd41e..c8a2de4818bb 100644 --- a/pkg/golinters/iface/testdata/iface_identical.go +++ b/pkg/golinters/iface/testdata/iface_identical.go @@ -6,11 +6,11 @@ import "fmt" // identical -type Pinger interface { // want "identical: interface Pinger contains identical methods or type constraints from another interface, causing redundancy" +type Pinger interface { // want "identical: interface 'Pinger' contains identical methods or type constraints with another interface, causing redundancy" Ping() error } -type Healthcheck interface { // want "identical: interface Healthcheck contains identical methods or type constraints from another interface, causing redundancy" +type Healthcheck interface { // want "identical: interface 'Healthcheck' contains identical methods or type constraints with another interface, causing redundancy" Ping() error } diff --git a/pkg/golinters/iface/testdata/iface_opaque.go b/pkg/golinters/iface/testdata/iface_opaque.go index b7ebeddc600f..8610a3fa05c1 100644 --- a/pkg/golinters/iface/testdata/iface_opaque.go +++ b/pkg/golinters/iface/testdata/iface_opaque.go @@ -28,7 +28,7 @@ func (s server) Serve() error { return nil } -func NewServer(addr string) Server { // want "opaque: NewServer function return Server interface at the 1st result, abstract a single concrete implementation of \\*server" +func NewServer(addr string) Server { // want "opaque: 'NewServer' function return 'Server' interface at the 1st result, abstract a single concrete implementation of '\\*server'" return &server{addr: addr} } diff --git a/pkg/golinters/iface/testdata/iface_unexported.go b/pkg/golinters/iface/testdata/iface_unexported.go new file mode 100644 index 000000000000..01a4f210f9f7 --- /dev/null +++ b/pkg/golinters/iface/testdata/iface_unexported.go @@ -0,0 +1,84 @@ +//golangcitest:args -Eiface +//golangcitest:config_path testdata/iface_unexported.yml +package testdata + +import "fmt" + +// identical + +type Pinger interface { + Ping() error +} + +type Healthcheck interface { + Ping() error +} + +// opaque + +type Server interface { + Serve() error +} + +type server struct { + addr string +} + +func (s server) Serve() error { + return nil +} + +func NewServer(addr string) Server { + return &server{addr: addr} +} + +// unused + +type User struct { + ID string + Name string +} + +type UserRepository interface { + UserOf(id string) (*User, error) +} + +type UserRepositorySQL struct { +} + +func (r *UserRepositorySQL) UserOf(id string) (*User, error) { + return nil, nil +} + +type Granter interface { + Grant(permission string) error +} + +func AllowAll(g Granter) error { + return g.Grant("all") +} + +type Allower interface { + Allow(permission string) error +} + +func Allow(x any) { + _ = x.(Allower) + fmt.Println("allow") +} + +// unexported + +type unexportedReader interface { + Read([]byte) (int, error) +} + +func ReadAll(r unexportedReader) ([]byte, error) { // want "unexported interface 'unexportedReader' used as parameter in exported function 'ReadAll'" + buf := make([]byte, 1024) + _, err := r.Read(buf) + return buf, err +} + +func NewUnexportedReader() unexportedReader { // want "unexported interface 'unexportedReader' used as return value in exported function 'NewUnexportedReader'" + return nil // stub +} diff --git a/pkg/golinters/iface/testdata/iface_unexported.yml b/pkg/golinters/iface/testdata/iface_unexported.yml new file mode 100644 index 000000000000..cc0a84c0aa1e --- /dev/null +++ b/pkg/golinters/iface/testdata/iface_unexported.yml @@ -0,0 +1,7 @@ +version: "2" + +linters: + settings: + iface: + enable: + - unexported diff --git a/pkg/golinters/iface/testdata/iface_unused.go b/pkg/golinters/iface/testdata/iface_unused.go index b75fdc8964c6..58e5ffdbaf25 100644 --- a/pkg/golinters/iface/testdata/iface_unused.go +++ b/pkg/golinters/iface/testdata/iface_unused.go @@ -6,11 +6,11 @@ import "fmt" // identical -type Pinger interface { // want "unused: interface Pinger is declared but not used within the package" +type Pinger interface { // want "unused: interface 'Pinger' is declared but not used within the package" Ping() error } -type Healthcheck interface { // want "unused: interface Healthcheck is declared but not used within the package" +type Healthcheck interface { // want "unused: interface 'Healthcheck' is declared but not used within the package" Ping() error } @@ -39,7 +39,7 @@ type User struct { Name string } -type UserRepository interface { // want "unused: interface UserRepository is declared but not used within the package" +type UserRepository interface { // want "unused: interface 'UserRepository' is declared but not used within the package" UserOf(id string) (*User, error) } From a6d5fa62302cb8cf02d436d3ae79f9f9152abade Mon Sep 17 00:00:00 2001 From: Ludovic Fernandez Date: Wed, 21 May 2025 21:47:19 +0200 Subject: [PATCH 71/96] docs: improve typecheck FAQ (#5821) Co-authored-by: Simon Sawert --- docs/src/docs/welcome/faq.mdx | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/docs/src/docs/welcome/faq.mdx b/docs/src/docs/welcome/faq.mdx index 46e57aacdbaa..62109ac5afb7 100644 --- a/docs/src/docs/welcome/faq.mdx +++ b/docs/src/docs/welcome/faq.mdx @@ -33,7 +33,7 @@ it's just a way to identify, parse, and display compiling errors (produced by th It cannot be disabled because of that. -Of course, this is just as good as the compiler itself and a lot of compilation issues will not properly show where in the code your error lies. +Of course, this is just as good as the compiler itself, and a lot of compilation issues will not properly show where in the code your error lies. As a consequence, the code to analyze should compile. It means that if you try to run an analysis on a single file or a group of files or a package or a group of packages, @@ -45,10 +45,11 @@ If there are `typecheck` errors, golangci-lint will not be able to produce other How to troubleshoot: - [ ] Ensure the version of golangci-lint is built with a compatible version of Go. -- [ ] Ensure dependencies are up-to-date with `go mod tidy`. +- [ ] Ensure dependencies are up to date with `go mod tidy`. - [ ] Ensure building works with `go run ./...`/`go build ./...` - whole package. - [ ] Ensure you are not running an analysis on code that depends on files/packages outside the scope of the analyzed elements. - [ ] If using CGO, ensure all require system libraries are installed. +- [ ] If you are using private repositories/dependencies, ensure the [Go proxy](https://go.dev/ref/mod#module-proxy) (`GOPROXY`) and [checksum database](https://go.dev/ref/mod#checksum-database) (`GOSUMDB`) are right and/or your git configuration. ## Why is it not possible to skip/ignore `typecheck` errors? From b6459b0483d0df3987684c1f732f2293c2486428 Mon Sep 17 00:00:00 2001 From: Ludovic Fernandez Date: Wed, 21 May 2025 23:02:00 +0200 Subject: [PATCH 72/96] docs: note about plugin system (#5822) --- docs/src/docs/contributing/new-linters.mdx | 2 +- docs/src/docs/plugins/go-plugins.mdx | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/docs/src/docs/contributing/new-linters.mdx b/docs/src/docs/contributing/new-linters.mdx index 1e22d714a896..57654e887f89 100644 --- a/docs/src/docs/contributing/new-linters.mdx +++ b/docs/src/docs/contributing/new-linters.mdx @@ -43,5 +43,5 @@ Typically, these linters can't be open-sourced or too specific. Such linters can be added through 2 plugin systems: -1. [Module Plugin System](/plugins/module-plugins) +1. [Module Plugin System](/plugins/module-plugins) (Recommended) 2. [Go Plugin System](/plugins/go-plugins) diff --git a/docs/src/docs/plugins/go-plugins.mdx b/docs/src/docs/plugins/go-plugins.mdx index ce742b9bc62c..bf05d1fc92b4 100644 --- a/docs/src/docs/plugins/go-plugins.mdx +++ b/docs/src/docs/plugins/go-plugins.mdx @@ -2,6 +2,10 @@ title: Go Plugin System --- +**We recommend using [Module Plugin System](/plugins/module-plugins) instead of the Go Plugin System.** + +--- + Private linters can be added through [Go's plugin system](https://pkg.go.dev/plugin). For a private linter (which acts as a plugin) to work properly, From 8eab120d6baa9675be6076ccd4a1549f76a8e736 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 23 May 2025 01:05:02 +0200 Subject: [PATCH 73/96] build(deps): bump github.com/jgautheron/goconst from 1.8.1 to 1.8.2 (#5825) --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 03810322d94d..b6c4dcfee25d 100644 --- a/go.mod +++ b/go.mod @@ -57,7 +57,7 @@ require ( github.com/gostaticanalysis/forcetypeassert v0.2.0 github.com/gostaticanalysis/nilerr v0.1.1 github.com/hashicorp/go-version v1.7.0 - github.com/jgautheron/goconst v1.8.1 + github.com/jgautheron/goconst v1.8.2 github.com/jingyugao/rowserrcheck v1.1.1 github.com/jjti/go-spancheck v0.6.5 github.com/julz/importas v0.2.0 diff --git a/go.sum b/go.sum index 2c8a91e0c1b7..6e693c71c7a1 100644 --- a/go.sum +++ b/go.sum @@ -331,8 +331,8 @@ github.com/hexops/gotextdiff v1.0.3/go.mod h1:pSWU5MAI3yDq+fZBTazCSJysOMbxWL1BSo github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8= github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw= -github.com/jgautheron/goconst v1.8.1 h1:PPqCYp3K/xlOj5JmIe6O1Mj6r1DbkdbLtR3AJuZo414= -github.com/jgautheron/goconst v1.8.1/go.mod h1:A0oxgBCHy55NQn6sYpO7UdnA9p+h7cPtoOZUmvNIako= +github.com/jgautheron/goconst v1.8.2 h1:y0XF7X8CikZ93fSNT6WBTb/NElBu9IjaY7CCYQrCMX4= +github.com/jgautheron/goconst v1.8.2/go.mod h1:A0oxgBCHy55NQn6sYpO7UdnA9p+h7cPtoOZUmvNIako= github.com/jingyugao/rowserrcheck v1.1.1 h1:zibz55j/MJtLsjP1OF4bSdgXxwL1b+Vn7Tjzq7gFzUs= github.com/jingyugao/rowserrcheck v1.1.1/go.mod h1:4yvlZSDb3IyDTUZJUmpZfm2Hwok+Dtp+nu2qOq+er9c= github.com/jjti/go-spancheck v0.6.5 h1:lmi7pKxa37oKYIMScialXUK6hP3iY5F1gu+mLBPgYB8= From cd315cdc3f54583194ae286000bde5df6222f839 Mon Sep 17 00:00:00 2001 From: Ludovic Fernandez Date: Sat, 24 May 2025 11:35:43 +0200 Subject: [PATCH 74/96] fix: write the input to stdout when using stdin and there are no changes (#5827) --- .golangci.next.reference.yml | 1 + pkg/goformat/runner.go | 43 +++++++++++++++++++++++++++--------- 2 files changed, 34 insertions(+), 10 deletions(-) diff --git a/.golangci.next.reference.yml b/.golangci.next.reference.yml index 4c8e1615682b..d372c128b82d 100644 --- a/.golangci.next.reference.yml +++ b/.golangci.next.reference.yml @@ -4088,6 +4088,7 @@ formatters: # Default: lax generated: strict # Which file paths to exclude. + # This option is ignored when using `--stdin` as the path is unknown. # Default: [] paths: - ".*\\.my\\.go$" diff --git a/pkg/goformat/runner.go b/pkg/goformat/runner.go index fa1d1acc3019..f87626158179 100644 --- a/pkg/goformat/runner.go +++ b/pkg/goformat/runner.go @@ -57,7 +57,7 @@ func (c *Runner) Run(paths []string) error { } if c.opts.stdin { - return c.process("", savedStdout, os.Stdin) + return c.formatStdIn("", savedStdout, os.Stdin) } for _, path := range paths { @@ -121,15 +121,6 @@ func (c *Runner) process(path string, stdout io.Writer, in io.Reader) error { output := c.metaFormatter.Format(path, input) - if c.opts.stdin { - _, err = stdout.Write(output) - if err != nil { - return err - } - - return nil - } - if bytes.Equal(input, output) { return nil } @@ -168,6 +159,38 @@ func (c *Runner) process(path string, stdout io.Writer, in io.Reader) error { return os.WriteFile(path, output, perms) } +func (c *Runner) formatStdIn(path string, stdout io.Writer, in io.Reader) error { + input, err := io.ReadAll(in) + if err != nil { + return err + } + + match, err := c.matcher.IsGeneratedFile(path, input) + if err != nil { + return err + } + + if match { + // If the file is generated, + // the input should be written to the stdout to avoid emptied the file. + _, err = stdout.Write(input) + if err != nil { + return err + } + + return nil + } + + output := c.metaFormatter.Format(path, input) + + _, err = stdout.Write(output) + if err != nil { + return err + } + + return nil +} + func (c *Runner) setOutputToDevNull() { devNull, err := os.Open(os.DevNull) if err != nil { From ee5054adbef639ee2b48f42668d8e9fb01e99dcc Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sat, 24 May 2025 12:48:30 +0200 Subject: [PATCH 75/96] build(deps): bump github.com/santhosh-tekuri/jsonschema/v6 from 6.0.1 to 6.0.2 (#5829) --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index b6c4dcfee25d..a266a80067f0 100644 --- a/go.mod +++ b/go.mod @@ -95,7 +95,7 @@ require ( github.com/ryancurrah/gomodguard v1.4.1 github.com/ryanrolds/sqlclosecheck v0.5.1 github.com/sanposhiho/wastedassign/v2 v2.1.0 - github.com/santhosh-tekuri/jsonschema/v6 v6.0.1 + github.com/santhosh-tekuri/jsonschema/v6 v6.0.2 github.com/sashamelentyev/interfacebloat v1.1.0 github.com/sashamelentyev/usestdlibvars v1.28.0 github.com/securego/gosec/v2 v2.22.4 diff --git a/go.sum b/go.sum index 6e693c71c7a1..5940dc688322 100644 --- a/go.sum +++ b/go.sum @@ -513,8 +513,8 @@ github.com/ryanrolds/sqlclosecheck v0.5.1 h1:dibWW826u0P8jNLsLN+En7+RqWWTYrjCB9f github.com/ryanrolds/sqlclosecheck v0.5.1/go.mod h1:2g3dUjoS6AL4huFdv6wn55WpLIDjY7ZgUR4J8HOO/XQ= github.com/sanposhiho/wastedassign/v2 v2.1.0 h1:crurBF7fJKIORrV85u9UUpePDYGWnwvv3+A96WvwXT0= github.com/sanposhiho/wastedassign/v2 v2.1.0/go.mod h1:+oSmSC+9bQ+VUAxA66nBb0Z7N8CK7mscKTDYC6aIek4= -github.com/santhosh-tekuri/jsonschema/v6 v6.0.1 h1:PKK9DyHxif4LZo+uQSgXNqs0jj5+xZwwfKHgph2lxBw= -github.com/santhosh-tekuri/jsonschema/v6 v6.0.1/go.mod h1:JXeL+ps8p7/KNMjDQk3TCwPpBy0wYklyWTfbkIzdIFU= +github.com/santhosh-tekuri/jsonschema/v6 v6.0.2 h1:KRzFb2m7YtdldCEkzs6KqmJw4nqEVZGK7IN2kJkjTuQ= +github.com/santhosh-tekuri/jsonschema/v6 v6.0.2/go.mod h1:JXeL+ps8p7/KNMjDQk3TCwPpBy0wYklyWTfbkIzdIFU= github.com/sashamelentyev/interfacebloat v1.1.0 h1:xdRdJp0irL086OyW1H/RTZTr1h/tMEOsumirXcOJqAw= github.com/sashamelentyev/interfacebloat v1.1.0/go.mod h1:+Y9yU5YdTkrNvoX0xHc84dxiN1iBi9+G8zZIhPVoNjQ= github.com/sashamelentyev/usestdlibvars v1.28.0 h1:jZnudE2zKCtYlGzLVreNp5pmCdOxXUzwsMDBkR21cyQ= From e7c45898cada168d6f2c98e309974d8405d49635 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sat, 24 May 2025 16:01:13 +0200 Subject: [PATCH 76/96] build(deps): bump github.com/sashamelentyev/usestdlibvars from 1.28.0 to 1.29.0 (#5828) Co-authored-by: Fernandez Ludovic --- .golangci.next.reference.yml | 3 +++ go.mod | 2 +- go.sum | 4 ++-- jsonschema/golangci.next.jsonschema.json | 5 +++++ pkg/config/linters_settings.go | 1 + .../testdata/usestdlibvars_non_default.go | 10 +++++++++- .../testdata/usestdlibvars_non_default.yml | 1 + pkg/golinters/usestdlibvars/usestdlibvars.go | 1 + 8 files changed, 23 insertions(+), 4 deletions(-) diff --git a/.golangci.next.reference.yml b/.golangci.next.reference.yml index d372c128b82d..36af28206aa1 100644 --- a/.golangci.next.reference.yml +++ b/.golangci.next.reference.yml @@ -3616,6 +3616,9 @@ linters: # Suggest the use of http.StatusXX. # Default: true http-status-code: false + # Suggest the use of time.Month in time.Date. + # Default: false + time-date-month: true # Suggest the use of time.Weekday.String(). # Default: true time-weekday: true diff --git a/go.mod b/go.mod index a266a80067f0..95776f35e674 100644 --- a/go.mod +++ b/go.mod @@ -97,7 +97,7 @@ require ( github.com/sanposhiho/wastedassign/v2 v2.1.0 github.com/santhosh-tekuri/jsonschema/v6 v6.0.2 github.com/sashamelentyev/interfacebloat v1.1.0 - github.com/sashamelentyev/usestdlibvars v1.28.0 + github.com/sashamelentyev/usestdlibvars v1.29.0 github.com/securego/gosec/v2 v2.22.4 github.com/shirou/gopsutil/v4 v4.25.4 github.com/sirupsen/logrus v1.9.3 diff --git a/go.sum b/go.sum index 5940dc688322..240f74257922 100644 --- a/go.sum +++ b/go.sum @@ -517,8 +517,8 @@ github.com/santhosh-tekuri/jsonschema/v6 v6.0.2 h1:KRzFb2m7YtdldCEkzs6KqmJw4nqEV github.com/santhosh-tekuri/jsonschema/v6 v6.0.2/go.mod h1:JXeL+ps8p7/KNMjDQk3TCwPpBy0wYklyWTfbkIzdIFU= github.com/sashamelentyev/interfacebloat v1.1.0 h1:xdRdJp0irL086OyW1H/RTZTr1h/tMEOsumirXcOJqAw= github.com/sashamelentyev/interfacebloat v1.1.0/go.mod h1:+Y9yU5YdTkrNvoX0xHc84dxiN1iBi9+G8zZIhPVoNjQ= -github.com/sashamelentyev/usestdlibvars v1.28.0 h1:jZnudE2zKCtYlGzLVreNp5pmCdOxXUzwsMDBkR21cyQ= -github.com/sashamelentyev/usestdlibvars v1.28.0/go.mod h1:9nl0jgOfHKWNFS43Ojw0i7aRoS4j6EBye3YBhmAIRF8= +github.com/sashamelentyev/usestdlibvars v1.29.0 h1:8J0MoRrw4/NAXtjQqTHrbW9NN+3iMf7Knkq057v4XOQ= +github.com/sashamelentyev/usestdlibvars v1.29.0/go.mod h1:8PpnjHMk5VdeWlVb4wCdrB8PNbLqZ3wBZTZWkrpZZL8= github.com/securego/gosec/v2 v2.22.4 h1:21VdNGcKicFSv6rUDBc0cEtEl7lWyCKZxKIm0iwvrIM= github.com/securego/gosec/v2 v2.22.4/go.mod h1:ww5Yie7KJ3AH8XZQTletkW5zOmIse6FACs/Ys8VR3qE= github.com/sergi/go-diff v1.2.0 h1:XU+rvMAioB0UC3q1MFrIQy4Vo5/4VsRDQQXHsEya6xQ= diff --git a/jsonschema/golangci.next.jsonschema.json b/jsonschema/golangci.next.jsonschema.json index 1bd33923a5de..a84a30121f38 100644 --- a/jsonschema/golangci.next.jsonschema.json +++ b/jsonschema/golangci.next.jsonschema.json @@ -3728,6 +3728,11 @@ "type": "boolean", "default": false }, + "time-date-month": { + "description": "Suggest the use of time.Month in time.Date.", + "type": "boolean", + "default": false + }, "crypto-hash": { "description": "Suggest the use of crypto.Hash.String().", "type": "boolean", diff --git a/pkg/config/linters_settings.go b/pkg/config/linters_settings.go index 2398186d3812..e2838d808acb 100644 --- a/pkg/config/linters_settings.go +++ b/pkg/config/linters_settings.go @@ -934,6 +934,7 @@ type UseStdlibVarsSettings struct { SQLIsolationLevel bool `mapstructure:"sql-isolation-level"` TLSSignatureScheme bool `mapstructure:"tls-signature-scheme"` ConstantKind bool `mapstructure:"constant-kind"` + TimeDateMonth bool `mapstructure:"time-date-month"` } type UseTestingSettings struct { diff --git a/pkg/golinters/usestdlibvars/testdata/usestdlibvars_non_default.go b/pkg/golinters/usestdlibvars/testdata/usestdlibvars_non_default.go index 14f4a93a6b3c..9eee473f0d6d 100644 --- a/pkg/golinters/usestdlibvars/testdata/usestdlibvars_non_default.go +++ b/pkg/golinters/usestdlibvars/testdata/usestdlibvars_non_default.go @@ -2,7 +2,10 @@ //golangcitest:config_path testdata/usestdlibvars_non_default.yml package testdata -import "net/http" +import ( + "net/http" + "time" +) func _200() { _ = 200 @@ -52,3 +55,8 @@ const ( _ = "ECDSAWithP256AndSHA256" // want `"ECDSAWithP256AndSHA256" can be replaced by tls\.ECDSAWithP256AndSHA256\.String\(\)` _ = "ECDSAWithP384AndSHA384" // want `"ECDSAWithP384AndSHA384" can be replaced by tls\.ECDSAWithP384AndSHA384\.String\(\)` ) + +func _() { + var _ = time.Date(2023, 1, 2, 3, 4, 5, 0, time.UTC) // want `"1" can be replaced by time\.January` + var _ = time.Date(2023, 10, 2, 3, 4, 5, 0, time.UTC) // want `"10" can be replaced by time\.October` +} diff --git a/pkg/golinters/usestdlibvars/testdata/usestdlibvars_non_default.yml b/pkg/golinters/usestdlibvars/testdata/usestdlibvars_non_default.yml index 8100af59cdb1..d2942621daee 100644 --- a/pkg/golinters/usestdlibvars/testdata/usestdlibvars_non_default.yml +++ b/pkg/golinters/usestdlibvars/testdata/usestdlibvars_non_default.yml @@ -13,3 +13,4 @@ linters: sql-isolation-level: true tls-signature-scheme: true constant-kind: true + time-date-month: true diff --git a/pkg/golinters/usestdlibvars/usestdlibvars.go b/pkg/golinters/usestdlibvars/usestdlibvars.go index 9342c4ccd7a3..e4a900ff6465 100644 --- a/pkg/golinters/usestdlibvars/usestdlibvars.go +++ b/pkg/golinters/usestdlibvars/usestdlibvars.go @@ -24,6 +24,7 @@ func New(settings *config.UseStdlibVarsSettings) *goanalysis.Linter { analyzer.TimeMonthFlag: settings.TimeMonth, analyzer.TimeWeekdayFlag: settings.TimeWeekday, analyzer.TLSSignatureSchemeFlag: settings.TLSSignatureScheme, + analyzer.TimeDateMonthFlag: settings.TimeDateMonth, } } From 156db1d836e664439e1dbf181948ddd66e156374 Mon Sep 17 00:00:00 2001 From: ccoVeille <3875889+ccoVeille@users.noreply.github.com> Date: Tue, 27 May 2025 12:02:00 +0200 Subject: [PATCH 77/96] fix: error message when trying to migrate a migrated config (#5836) Co-authored-by: Fernandez Ludovic --- pkg/commands/migrate.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pkg/commands/migrate.go b/pkg/commands/migrate.go index 7c73209ed180..78e7842bed04 100644 --- a/pkg/commands/migrate.go +++ b/pkg/commands/migrate.go @@ -81,10 +81,6 @@ func newMigrateCommand(log logutils.Log, info BuildInfo) *migrateCommand { } func (c *migrateCommand) execute(_ *cobra.Command, _ []string) error { - if c.cfg.Version != "" { - return fmt.Errorf("configuration version is already set: %s", c.cfg.Version) - } - srcPath := c.viper.ConfigFileUsed() if srcPath == "" { c.log.Warnf("No config file detected") @@ -141,6 +137,10 @@ func (c *migrateCommand) preRunE(cmd *cobra.Command, _ []string) error { return fmt.Errorf("unsupported format: %s", c.opts.format) } + if c.cfg.Version != "" { + return fmt.Errorf("configuration version is already set: %s", c.cfg.Version) + } + if c.opts.skipValidation { return nil } From d4bc40ed76ec038911cb56bacdbae38565dd3f8f Mon Sep 17 00:00:00 2001 From: ccoVeille <3875889+ccoVeille@users.noreply.github.com> Date: Tue, 27 May 2025 12:02:31 +0200 Subject: [PATCH 78/96] fix: formatters CLI flags help message (#5835) --- pkg/commands/formatters.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pkg/commands/formatters.go b/pkg/commands/formatters.go index a3fafd1d25c9..22a9914ae2ff 100644 --- a/pkg/commands/formatters.go +++ b/pkg/commands/formatters.go @@ -59,7 +59,8 @@ func newFormattersCommand(logger logutils.Log) *formattersCommand { fs.SortFlags = false // sort them as they are defined here setupConfigFileFlagSet(fs, &c.opts.LoaderOptions) - setupLintersFlagSet(c.viper, fs) + + setupFormattersFlagSet(c.viper, fs) fs.BoolVar(&c.opts.JSON, "json", false, color.GreenString("Display as JSON")) From b9510d7a4edbd5d9c821075fb56d5d426dae8783 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 28 May 2025 14:15:47 +0200 Subject: [PATCH 79/96] build(deps): bump github.com/golangci/plugin-module-register from 0.1.1 to 0.1.2 (#5838) --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 95776f35e674..c4850ff4f3bb 100644 --- a/go.mod +++ b/go.mod @@ -49,7 +49,7 @@ require ( github.com/golangci/gofmt v0.0.0-20250106114630-d62b90e6713d github.com/golangci/golines v0.0.0-20250217134842-442fd0091d95 github.com/golangci/misspell v0.7.0 - github.com/golangci/plugin-module-register v0.1.1 + github.com/golangci/plugin-module-register v0.1.2 github.com/golangci/revgrep v0.8.0 github.com/golangci/swaggoswag v0.0.0-20250504205917-77f2aca3143e github.com/golangci/unconvert v0.0.0-20250410112200-a129a6e6413e diff --git a/go.sum b/go.sum index 240f74257922..64adaf104e62 100644 --- a/go.sum +++ b/go.sum @@ -259,8 +259,8 @@ github.com/golangci/golines v0.0.0-20250217134842-442fd0091d95 h1:AkK+w9FZBXlU/x github.com/golangci/golines v0.0.0-20250217134842-442fd0091d95/go.mod h1:k9mmcyWKSTMcPPvQUCfRWWQ9VHJ1U9Dc0R7kaXAgtnQ= github.com/golangci/misspell v0.7.0 h1:4GOHr/T1lTW0hhR4tgaaV1WS/lJ+ncvYCoFKmqJsj0c= github.com/golangci/misspell v0.7.0/go.mod h1:WZyyI2P3hxPY2UVHs3cS8YcllAeyfquQcKfdeE9AFVg= -github.com/golangci/plugin-module-register v0.1.1 h1:TCmesur25LnyJkpsVrupv1Cdzo+2f7zX0H6Jkw1Ol6c= -github.com/golangci/plugin-module-register v0.1.1/go.mod h1:TTpqoB6KkwOJMV8u7+NyXMrkwwESJLOkfl9TxR1DGFc= +github.com/golangci/plugin-module-register v0.1.2 h1:e5WM6PO6NIAEcij3B053CohVp3HIYbzSuP53UAYgOpg= +github.com/golangci/plugin-module-register v0.1.2/go.mod h1:1+QGTsKBvAIvPvoY/os+G5eoqxWn70HYDm2uvUyGuVw= github.com/golangci/revgrep v0.8.0 h1:EZBctwbVd0aMeRnNUsFogoyayvKHyxlV3CdUA46FX2s= github.com/golangci/revgrep v0.8.0/go.mod h1:U4R/s9dlXZsg8uJmaR1GrloUr14D7qDl8gi2iPXJH8k= github.com/golangci/swaggoswag v0.0.0-20250504205917-77f2aca3143e h1:ai0EfmVYE2bRA5htgAG9r7s3tHsfjIhN98WshBTJ9jM= From 10525556561539351fb38b679be789900ba00c29 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 28 May 2025 14:35:40 +0200 Subject: [PATCH 80/96] build(deps): bump github.com/mgechev/revive from 1.9.0 to 1.10.0 (#5837) Co-authored-by: Fernandez Ludovic --- .golangci.next.reference.yml | 17 +++- go.mod | 5 +- go.sum | 16 +--- jsonschema/golangci.next.jsonschema.json | 3 + pkg/golinters/revive/revive.go | 102 ++++++++++++----------- 5 files changed, 78 insertions(+), 65 deletions(-) diff --git a/.golangci.next.reference.yml b/.golangci.next.reference.yml index 36af28206aa1..0e8609212c6b 100644 --- a/.golangci.next.reference.yml +++ b/.golangci.next.reference.yml @@ -2589,7 +2589,7 @@ linters: severity: warning disabled: false exclude: [""] - # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#redundant-test-main-exit + # https://github.com/mgechev/revive/blob/HEAD/RULES_DESCRIPTIONS.md#redundant-test-main-exit - name: redundant-test-main-exit severity: warning disabled: false @@ -2629,6 +2629,11 @@ linters: exclude: [""] arguments: - "preserve-scope" + # https://github.com/mgechev/revive/blob/HEAD/RULES_DESCRIPTIONS.md#time-date + - name: time-date + severity: warning + disabled: false + exclude: [""] # https://github.com/mgechev/revive/blob/HEAD/RULES_DESCRIPTIONS.md#time-equal - name: time-equal severity: warning @@ -2669,6 +2674,11 @@ linters: arguments: - "fmt.Printf" - "myFunction" + # https://github.com/mgechev/revive/blob/HEAD/RULES_DESCRIPTIONS.md#unnecessary-format + - name: unnecessary-format + severity: warning + disabled: false + exclude: [""] # https://github.com/mgechev/revive/blob/HEAD/RULES_DESCRIPTIONS.md#unnecessary-stmt - name: unnecessary-stmt severity: warning @@ -2703,6 +2713,11 @@ linters: severity: warning disabled: false exclude: [""] + # https://github.com/mgechev/revive/blob/HEAD/RULES_DESCRIPTIONS.md#use-fmt-print + - name: use-fmt-print + severity: warning + disabled: false + exclude: [""] # https://github.com/mgechev/revive/blob/HEAD/RULES_DESCRIPTIONS.md#useless-break - name: useless-break severity: warning diff --git a/go.mod b/go.mod index c4850ff4f3bb..20488af3e2eb 100644 --- a/go.mod +++ b/go.mod @@ -80,7 +80,7 @@ require ( github.com/maratori/testpackage v1.1.1 github.com/matoous/godox v1.1.0 github.com/mattn/go-colorable v0.1.14 - github.com/mgechev/revive v1.9.0 + github.com/mgechev/revive v1.10.0 github.com/mitchellh/go-homedir v1.1.0 github.com/moricho/tparallel v0.3.2 github.com/nakabonne/nestif v0.3.1 @@ -141,6 +141,7 @@ require ( ) require ( + codeberg.org/chavacava/garif v0.2.0 // indirect github.com/Masterminds/semver/v3 v3.3.1 // indirect github.com/aymanbagabas/go-osc52/v2 v2.0.1 // indirect github.com/beorn7/perks v1.0.1 // indirect @@ -150,7 +151,6 @@ require ( github.com/charmbracelet/x/ansi v0.8.0 // indirect github.com/charmbracelet/x/cellbuf v0.0.13-0.20250311204145-2c3ea96c31dd // indirect github.com/charmbracelet/x/term v0.2.1 // indirect - github.com/chavacava/garif v0.1.0 // indirect github.com/dave/dst v0.27.3 // indirect github.com/davecgh/go-spew v1.1.1 // indirect github.com/dlclark/regexp2 v1.11.5 // indirect @@ -184,7 +184,6 @@ require ( github.com/matttproud/golang_protobuf_extensions v1.0.1 // indirect github.com/mitchellh/mapstructure v1.5.0 // indirect github.com/muesli/termenv v0.16.0 // indirect - github.com/olekukonko/tablewriter v0.0.5 // indirect github.com/pelletier/go-toml v1.9.5 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c // indirect diff --git a/go.sum b/go.sum index 64adaf104e62..732d7ef4d6af 100644 --- a/go.sum +++ b/go.sum @@ -34,6 +34,8 @@ cloud.google.com/go/storage v1.5.0/go.mod h1:tpKbwo567HUNpVclU5sGELwQWBDZ8gh0Zeo cloud.google.com/go/storage v1.6.0/go.mod h1:N7U0C8pVQ/+NIKOBQyamJIeKQKkZ+mxpohlUTyfDhBk= cloud.google.com/go/storage v1.8.0/go.mod h1:Wv1Oy7z6Yz3DshWRJFhqM/UCfaWIRTdp0RXyy7KQOVs= cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9ullr3+Kg0= +codeberg.org/chavacava/garif v0.2.0 h1:F0tVjhYbuOCnvNcU3YSpO6b3Waw6Bimy4K0mM8y6MfY= +codeberg.org/chavacava/garif v0.2.0/go.mod h1:P2BPbVbT4QcvLZrORc2T29szK3xEOlnl0GiPTJmEqBQ= dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= github.com/4meepo/tagalign v1.4.2 h1:0hcLHPGMjDyM1gHG58cS73aQF8J4TdVR96TZViorO9E= github.com/4meepo/tagalign v1.4.2/go.mod h1:+p4aMyFM+ra7nb41CnFG6aSDXqRxU/w1VQqScKqDARI= @@ -125,8 +127,6 @@ github.com/charmbracelet/x/cellbuf v0.0.13-0.20250311204145-2c3ea96c31dd h1:vy0G github.com/charmbracelet/x/cellbuf v0.0.13-0.20250311204145-2c3ea96c31dd/go.mod h1:xe0nKWGd3eJgtqZRaN9RjMtK7xUYchjzPr7q6kcvCCs= github.com/charmbracelet/x/term v0.2.1 h1:AQeHeLZ1OqSXhrAWpYUtZyX1T3zVxfpZuEQMIQaGIAQ= github.com/charmbracelet/x/term v0.2.1/go.mod h1:oQ4enTYFV7QN4m0i9mzHrViD7TQKvNEEkHUMCmsxdUg= -github.com/chavacava/garif v0.1.0 h1:2JHa3hbYf5D9dsgseMKAmc/MZ109otzgNFk5s87H9Pc= -github.com/chavacava/garif v0.1.0/go.mod h1:XMyYCkEL58DF0oyW4qDjjnPWONs2HBqYKI+UIPD+Gww= github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI= github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI= github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU= @@ -407,13 +407,12 @@ github.com/mattn/go-colorable v0.1.14 h1:9A9LHSqF/7dyVVX6g0U9cwm9pG3kP9gSzcuIPHP github.com/mattn/go-colorable v0.1.14/go.mod h1:6LmQG8QLFO4G5z1gPvYEzlUgJ2wF+stgPZH1UqBm1s8= github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= -github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI= github.com/mattn/go-runewidth v0.0.16 h1:E5ScNMtiwvlvB5paMFdw9p4kSQzbXFikJ5SQO6TULQc= github.com/mattn/go-runewidth v0.0.16/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= github.com/matttproud/golang_protobuf_extensions v1.0.1 h1:4hp9jkHxhMHkqkrB3Ix0jegS5sx/RkqARlsWZ6pIwiU= github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= -github.com/mgechev/revive v1.9.0 h1:8LaA62XIKrb8lM6VsBSQ92slt/o92z5+hTw3CmrvSrM= -github.com/mgechev/revive v1.9.0/go.mod h1:LAPq3+MgOf7GcL5PlWIkHb0PT7XH4NuC2LdWymhb9Mo= +github.com/mgechev/revive v1.10.0 h1:x2oJsd7yrDp0mC6IgZqSKBTjSUC9Zk5Ob2WfBwZic2I= +github.com/mgechev/revive v1.10.0/go.mod h1:1MRO9zUV7Yukhqh/nGRKSaw6xC5XDzPWPja5GMPWoSE= github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y= github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY= @@ -437,8 +436,6 @@ github.com/nishanths/predeclared v0.2.2 h1:V2EPdZPliZymNAn79T8RkNApBjMmVKh5XRpLm github.com/nishanths/predeclared v0.2.2/go.mod h1:RROzoN6TnGQupbC+lqggsOlcgysk3LMK/HI84Mp280c= github.com/nunnatsa/ginkgolinter v0.19.1 h1:mjwbOlDQxZi9Cal+KfbEJTCz327OLNfwNvoZ70NJ+c4= github.com/nunnatsa/ginkgolinter v0.19.1/go.mod h1:jkQ3naZDmxaZMXPWaS9rblH+i+GWXQCaS/JFIWcOH2s= -github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N7AbDhec= -github.com/olekukonko/tablewriter v0.0.5/go.mod h1:hPp6KlRPjbx+hW8ykQs1w3UBbZlj6HuIJcUGPhkA7kY= github.com/onsi/ginkgo/v2 v2.23.4 h1:ktYTpKJAVZnDT4VjxSbiBenUjmlL/5QkBEocaWXiQus= github.com/onsi/ginkgo/v2 v2.23.4/go.mod h1:Bt66ApGPBFzHyR+JO10Zbt0Gsp4uWxu5mIOTusL46e8= github.com/onsi/gomega v1.37.0 h1:CdEG8g0S133B4OswTDC/5XPSzE1OeP29QOioj2PID2Y= @@ -557,17 +554,12 @@ github.com/stbenjam/no-sprintf-host-port v0.2.0 h1:i8pxvGrt1+4G0czLr/WnmyH7zbZ8B github.com/stbenjam/no-sprintf-host-port v0.2.0/go.mod h1:eL0bQ9PasS0hsyTyfTjjG+E80QIyPnBVQbYZyv20Jfk= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= -github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= github.com/stretchr/objx v0.5.2 h1:xuMeJ0Sdp5ZMRXx/aWO6RZxdr3beISkG5/G/aIRr3pY= github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= -github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA= github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= github.com/subosito/gotenv v1.4.1 h1:jyEFiXpy21Wm81FBN71l9VoMMV8H8jG+qIK3GCpY6Qs= diff --git a/jsonschema/golangci.next.jsonschema.json b/jsonschema/golangci.next.jsonschema.json index a84a30121f38..70fa57bdad74 100644 --- a/jsonschema/golangci.next.jsonschema.json +++ b/jsonschema/golangci.next.jsonschema.json @@ -638,6 +638,7 @@ "string-of-int", "struct-tag", "superfluous-else", + "time-date", "time-equal", "time-naming", "unchecked-type-assertion", @@ -645,12 +646,14 @@ "unexported-naming", "unexported-return", "unhandled-error", + "unnecessary-format", "unnecessary-stmt", "unreachable-code", "unused-parameter", "unused-receiver", "use-any", "use-errors-new", + "use-fmt-print", "useless-break", "var-declaration", "var-naming", diff --git a/pkg/golinters/revive/revive.go b/pkg/golinters/revive/revive.go index 32b42ba8314d..01eccd537d9e 100644 --- a/pkg/golinters/revive/revive.go +++ b/pkg/golinters/revive/revive.go @@ -152,7 +152,7 @@ func (w *wrapper) toIssue(pass *analysis.Pass, failure *lint.Failure) goanalysis f := pass.Fset.File(token.Pos(failure.Position.Start.Offset)) // Skip cgo files because the positions are wrong. - if failure.GetFilename() == f.Name() { + if failure.Filename() == f.Name() { issue.SuggestedFixes = []analysis.SuggestedFix{{ TextEdits: []analysis.TextEdit{{ Pos: f.LineStart(failure.Position.Start.Line), @@ -269,7 +269,7 @@ func safeTomlSlice(r []any) []any { } // This element is not exported by revive, so we need copy the code. -// Extracted from https://github.com/mgechev/revive/blob/v1.6.0/config/config.go#L16 +// Extracted from https://github.com/mgechev/revive/blob/v1.10.0/config/config.go#L16 var defaultRules = []lint.Rule{ &rule.VarDeclarationsRule{}, &rule.PackageCommentsRule{}, @@ -297,66 +297,70 @@ var defaultRules = []lint.Rule{ } var allRules = append([]lint.Rule{ + &rule.AddConstantRule{}, &rule.ArgumentsLimitRule{}, - &rule.CyclomaticRule{}, - &rule.FileHeaderRule{}, + &rule.AtomicRule{}, + &rule.BannedCharsRule{}, + &rule.BareReturnRule{}, + &rule.BoolLiteralRule{}, + &rule.CallToGCRule{}, + &rule.CognitiveComplexityRule{}, + &rule.CommentsDensityRule{}, + &rule.CommentSpacingsRule{}, &rule.ConfusingNamingRule{}, - &rule.GetReturnRule{}, - &rule.ModifiesParamRule{}, &rule.ConfusingResultsRule{}, - &rule.DeepExitRule{}, - &rule.AddConstantRule{}, - &rule.FlagParamRule{}, - &rule.UnnecessaryStmtRule{}, - &rule.StructTagRule{}, - &rule.ModifiesValRecRule{}, &rule.ConstantLogicalExprRule{}, - &rule.BoolLiteralRule{}, - &rule.ImportsBlocklistRule{}, - &rule.FunctionResultsLimitRule{}, - &rule.MaxPublicStructsRule{}, - &rule.RangeValInClosureRule{}, - &rule.RangeValAddress{}, - &rule.WaitGroupByValueRule{}, - &rule.AtomicRule{}, - &rule.EmptyLinesRule{}, - &rule.LineLengthLimitRule{}, - &rule.CallToGCRule{}, + &rule.CyclomaticRule{}, + &rule.DataRaceRule{}, + &rule.DeepExitRule{}, + &rule.DeferRule{}, &rule.DuplicatedImportsRule{}, - &rule.ImportShadowingRule{}, - &rule.BareReturnRule{}, - &rule.UnusedReceiverRule{}, - &rule.UnhandledErrorRule{}, - &rule.CognitiveComplexityRule{}, - &rule.StringOfIntRule{}, - &rule.StringFormatRule{}, &rule.EarlyReturnRule{}, - &rule.UnconditionalRecursionRule{}, - &rule.IdenticalBranchesRule{}, - &rule.DeferRule{}, - &rule.UnexportedNamingRule{}, - &rule.FunctionLength{}, - &rule.NestedStructs{}, - &rule.UselessBreak{}, - &rule.UncheckedTypeAssertionRule{}, - &rule.TimeEqualRule{}, - &rule.BannedCharsRule{}, - &rule.OptimizeOperandsOrderRule{}, - &rule.UseAnyRule{}, - &rule.DataRaceRule{}, - &rule.CommentSpacingsRule{}, - &rule.IfReturnRule{}, - &rule.RedundantImportAlias{}, - &rule.ImportAliasNamingRule{}, + &rule.EmptyLinesRule{}, &rule.EnforceMapStyleRule{}, &rule.EnforceRepeatedArgTypeStyleRule{}, &rule.EnforceSliceStyleRule{}, - &rule.MaxControlNestingRule{}, - &rule.CommentsDensityRule{}, + &rule.FileHeaderRule{}, &rule.FileLengthLimitRule{}, &rule.FilenameFormatRule{}, + &rule.FlagParamRule{}, + &rule.FunctionLength{}, + &rule.FunctionResultsLimitRule{}, + &rule.GetReturnRule{}, + &rule.IdenticalBranchesRule{}, + &rule.IfReturnRule{}, + &rule.ImportAliasNamingRule{}, + &rule.ImportsBlocklistRule{}, + &rule.ImportShadowingRule{}, + &rule.LineLengthLimitRule{}, + &rule.MaxControlNestingRule{}, + &rule.MaxPublicStructsRule{}, + &rule.ModifiesParamRule{}, + &rule.ModifiesValRecRule{}, + &rule.NestedStructs{}, + &rule.OptimizeOperandsOrderRule{}, + &rule.RangeValAddress{}, + &rule.RangeValInClosureRule{}, &rule.RedundantBuildTagRule{}, + &rule.RedundantImportAlias{}, + &rule.RedundantTestMainExitRule{}, + &rule.StringFormatRule{}, + &rule.StringOfIntRule{}, + &rule.StructTagRule{}, + &rule.TimeDateRule{}, + &rule.TimeEqualRule{}, + &rule.UncheckedTypeAssertionRule{}, + &rule.UnconditionalRecursionRule{}, + &rule.UnexportedNamingRule{}, + &rule.UnhandledErrorRule{}, + &rule.UnnecessaryFormatRule{}, + &rule.UnnecessaryStmtRule{}, + &rule.UnusedReceiverRule{}, + &rule.UseAnyRule{}, &rule.UseErrorsNewRule{}, + &rule.UseFmtPrintRule{}, + &rule.UselessBreak{}, + &rule.WaitGroupByValueRule{}, }, defaultRules...) const defaultConfidence = 0.8 From 2a63ebc12fd4c8a31c281cffa31671c161461fb7 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 28 May 2025 15:25:32 +0200 Subject: [PATCH 81/96] build(deps): bump github.com/Abirdcfly/dupword from 0.1.4 to 0.1.5 (#5839) --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 20488af3e2eb..c6c93663922d 100644 --- a/go.mod +++ b/go.mod @@ -6,7 +6,7 @@ require ( 4d63.com/gocheckcompilerdirectives v1.3.0 4d63.com/gochecknoglobals v0.2.2 github.com/4meepo/tagalign v1.4.2 - github.com/Abirdcfly/dupword v0.1.4 + github.com/Abirdcfly/dupword v0.1.5 github.com/Antonboom/errname v1.1.0 github.com/Antonboom/nilnil v1.1.0 github.com/Antonboom/testifylint v1.6.1 diff --git a/go.sum b/go.sum index 732d7ef4d6af..20b0065770d8 100644 --- a/go.sum +++ b/go.sum @@ -39,8 +39,8 @@ codeberg.org/chavacava/garif v0.2.0/go.mod h1:P2BPbVbT4QcvLZrORc2T29szK3xEOlnl0G dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= github.com/4meepo/tagalign v1.4.2 h1:0hcLHPGMjDyM1gHG58cS73aQF8J4TdVR96TZViorO9E= github.com/4meepo/tagalign v1.4.2/go.mod h1:+p4aMyFM+ra7nb41CnFG6aSDXqRxU/w1VQqScKqDARI= -github.com/Abirdcfly/dupword v0.1.4 h1:jxqkdgO0L7FSwq4fMu3d+fAA1E3bBQAtl4utA3tcQZM= -github.com/Abirdcfly/dupword v0.1.4/go.mod h1:s+BFMuL/I4YSiFv29snqyjwzDp4b65W2Kvy+PKzZ6cw= +github.com/Abirdcfly/dupword v0.1.5 h1:beKz0j4wOOwehuExCSdJiN8yqBbzBfVDCrEPkiW6LK4= +github.com/Abirdcfly/dupword v0.1.5/go.mod h1:s+BFMuL/I4YSiFv29snqyjwzDp4b65W2Kvy+PKzZ6cw= github.com/Antonboom/errname v1.1.0 h1:A+ucvdpMwlo/myWrkHEUEBWc/xuXdud23S8tmTb/oAE= github.com/Antonboom/errname v1.1.0/go.mod h1:O1NMrzgUcVBGIfi3xlVuvX8Q/VP/73sseCaAppfjqZw= github.com/Antonboom/nilnil v1.1.0 h1:jGxJxjgYS3VUUtOTNk8Z1icwT5ESpLH/426fjmQG+ng= From f80cb324fc10936ee32ec1ea07154893b1ed9385 Mon Sep 17 00:00:00 2001 From: Fernandez Ludovic Date: Wed, 28 May 2025 15:47:59 +0200 Subject: [PATCH 82/96] chore: improve pull request template --- .github/PULL_REQUEST_TEMPLATE.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index be686a73c8c7..9bfa6efaef42 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -8,3 +8,12 @@ The updates happen at least automatically once a week (Sunday 11am UTC). No pull requests to update a linter will be accepted unless you are the author of the linter AND specific changes are required. --> + + From 0bcafa0850bd0ac1aeaa440f4684838e2fb5cf49 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 29 May 2025 17:09:22 +0200 Subject: [PATCH 83/96] build(deps): bump github.com/Abirdcfly/dupword from 0.1.5 to 0.1.6 (#5841) --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index c6c93663922d..cf3c581a5fba 100644 --- a/go.mod +++ b/go.mod @@ -6,7 +6,7 @@ require ( 4d63.com/gocheckcompilerdirectives v1.3.0 4d63.com/gochecknoglobals v0.2.2 github.com/4meepo/tagalign v1.4.2 - github.com/Abirdcfly/dupword v0.1.5 + github.com/Abirdcfly/dupword v0.1.6 github.com/Antonboom/errname v1.1.0 github.com/Antonboom/nilnil v1.1.0 github.com/Antonboom/testifylint v1.6.1 diff --git a/go.sum b/go.sum index 20b0065770d8..55ffdf91c2e4 100644 --- a/go.sum +++ b/go.sum @@ -39,8 +39,8 @@ codeberg.org/chavacava/garif v0.2.0/go.mod h1:P2BPbVbT4QcvLZrORc2T29szK3xEOlnl0G dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= github.com/4meepo/tagalign v1.4.2 h1:0hcLHPGMjDyM1gHG58cS73aQF8J4TdVR96TZViorO9E= github.com/4meepo/tagalign v1.4.2/go.mod h1:+p4aMyFM+ra7nb41CnFG6aSDXqRxU/w1VQqScKqDARI= -github.com/Abirdcfly/dupword v0.1.5 h1:beKz0j4wOOwehuExCSdJiN8yqBbzBfVDCrEPkiW6LK4= -github.com/Abirdcfly/dupword v0.1.5/go.mod h1:s+BFMuL/I4YSiFv29snqyjwzDp4b65W2Kvy+PKzZ6cw= +github.com/Abirdcfly/dupword v0.1.6 h1:qeL6u0442RPRe3mcaLcbaCi2/Y/hOcdtw6DE9odjz9c= +github.com/Abirdcfly/dupword v0.1.6/go.mod h1:s+BFMuL/I4YSiFv29snqyjwzDp4b65W2Kvy+PKzZ6cw= github.com/Antonboom/errname v1.1.0 h1:A+ucvdpMwlo/myWrkHEUEBWc/xuXdud23S8tmTb/oAE= github.com/Antonboom/errname v1.1.0/go.mod h1:O1NMrzgUcVBGIfi3xlVuvX8Q/VP/73sseCaAppfjqZw= github.com/Antonboom/nilnil v1.1.0 h1:jGxJxjgYS3VUUtOTNk8Z1icwT5ESpLH/426fjmQG+ng= From f54365bc92856d453f8c7c4684022b5d4efa0cb1 Mon Sep 17 00:00:00 2001 From: Alwx Date: Fri, 30 May 2025 00:08:39 +0300 Subject: [PATCH 84/96] Add noinlineerr linter (#5826) --- .golangci.next.reference.yml | 2 + go.mod | 1 + go.sum | 2 + jsonschema/golangci.next.jsonschema.json | 1 + pkg/golinters/noinlineerr/noinlineerr.go | 13 +++ .../noinlineerr_integration_test.go | 19 ++++ .../testdata/fix/in/noinlineerr.go | 59 +++++++++++++ .../testdata/fix/out/noinlineerr.go | 59 +++++++++++++ .../noinlineerr/testdata/noinlineerr.go | 87 +++++++++++++++++++ pkg/lint/lintersdb/builder_linter.go | 6 ++ 10 files changed, 249 insertions(+) create mode 100644 pkg/golinters/noinlineerr/noinlineerr.go create mode 100644 pkg/golinters/noinlineerr/noinlineerr_integration_test.go create mode 100644 pkg/golinters/noinlineerr/testdata/fix/in/noinlineerr.go create mode 100644 pkg/golinters/noinlineerr/testdata/fix/out/noinlineerr.go create mode 100644 pkg/golinters/noinlineerr/testdata/noinlineerr.go diff --git a/.golangci.next.reference.yml b/.golangci.next.reference.yml index 0e8609212c6b..abc9c060efbe 100644 --- a/.golangci.next.reference.yml +++ b/.golangci.next.reference.yml @@ -91,6 +91,7 @@ linters: - nilnil - nlreturn - noctx + - noinlineerr - nolintlint - nonamedreturns - nosprintfhostport @@ -200,6 +201,7 @@ linters: - nilnil - nlreturn - noctx + - noinlineerr - nolintlint - nonamedreturns - nosprintfhostport diff --git a/go.mod b/go.mod index cf3c581a5fba..6f084bed2675 100644 --- a/go.mod +++ b/go.mod @@ -7,6 +7,7 @@ require ( 4d63.com/gochecknoglobals v0.2.2 github.com/4meepo/tagalign v1.4.2 github.com/Abirdcfly/dupword v0.1.6 + github.com/AlwxSin/noinlineerr v1.0.3 github.com/Antonboom/errname v1.1.0 github.com/Antonboom/nilnil v1.1.0 github.com/Antonboom/testifylint v1.6.1 diff --git a/go.sum b/go.sum index 55ffdf91c2e4..0a4e0d2587b0 100644 --- a/go.sum +++ b/go.sum @@ -41,6 +41,8 @@ github.com/4meepo/tagalign v1.4.2 h1:0hcLHPGMjDyM1gHG58cS73aQF8J4TdVR96TZViorO9E github.com/4meepo/tagalign v1.4.2/go.mod h1:+p4aMyFM+ra7nb41CnFG6aSDXqRxU/w1VQqScKqDARI= github.com/Abirdcfly/dupword v0.1.6 h1:qeL6u0442RPRe3mcaLcbaCi2/Y/hOcdtw6DE9odjz9c= github.com/Abirdcfly/dupword v0.1.6/go.mod h1:s+BFMuL/I4YSiFv29snqyjwzDp4b65W2Kvy+PKzZ6cw= +github.com/AlwxSin/noinlineerr v1.0.3 h1:9b5edChzzwX30BuBci13LHVZHF5q7hW9qtrs+wJdDog= +github.com/AlwxSin/noinlineerr v1.0.3/go.mod h1:+QgkkoYrMH7RHvcdxdlI7vYYEdgeoFOVjU9sUhw/rQc= github.com/Antonboom/errname v1.1.0 h1:A+ucvdpMwlo/myWrkHEUEBWc/xuXdud23S8tmTb/oAE= github.com/Antonboom/errname v1.1.0/go.mod h1:O1NMrzgUcVBGIfi3xlVuvX8Q/VP/73sseCaAppfjqZw= github.com/Antonboom/nilnil v1.1.0 h1:jGxJxjgYS3VUUtOTNk8Z1icwT5ESpLH/426fjmQG+ng= diff --git a/jsonschema/golangci.next.jsonschema.json b/jsonschema/golangci.next.jsonschema.json index 70fa57bdad74..a12cb912b569 100644 --- a/jsonschema/golangci.next.jsonschema.json +++ b/jsonschema/golangci.next.jsonschema.json @@ -794,6 +794,7 @@ "nilnil", "nlreturn", "noctx", + "noinlineerr", "nolintlint", "nonamedreturns", "nosprintfhostport", diff --git a/pkg/golinters/noinlineerr/noinlineerr.go b/pkg/golinters/noinlineerr/noinlineerr.go new file mode 100644 index 000000000000..4f9f82eb4d0c --- /dev/null +++ b/pkg/golinters/noinlineerr/noinlineerr.go @@ -0,0 +1,13 @@ +package noinlineerr + +import ( + "github.com/AlwxSin/noinlineerr" + + "github.com/golangci/golangci-lint/v2/pkg/goanalysis" +) + +func New() *goanalysis.Linter { + return goanalysis. + NewLinterFromAnalyzer(noinlineerr.NewAnalyzer()). + WithLoadMode(goanalysis.LoadModeTypesInfo) +} diff --git a/pkg/golinters/noinlineerr/noinlineerr_integration_test.go b/pkg/golinters/noinlineerr/noinlineerr_integration_test.go new file mode 100644 index 000000000000..3b14450932a1 --- /dev/null +++ b/pkg/golinters/noinlineerr/noinlineerr_integration_test.go @@ -0,0 +1,19 @@ +package noinlineerr + +import ( + "testing" + + "github.com/golangci/golangci-lint/v2/test/testshared/integration" +) + +func TestFromTestdata(t *testing.T) { + integration.RunTestdata(t) +} + +func TestFix(t *testing.T) { + integration.RunFix(t) +} + +func TestFixPathPrefix(t *testing.T) { + integration.RunFixPathPrefix(t) +} diff --git a/pkg/golinters/noinlineerr/testdata/fix/in/noinlineerr.go b/pkg/golinters/noinlineerr/testdata/fix/in/noinlineerr.go new file mode 100644 index 000000000000..62c90bd98017 --- /dev/null +++ b/pkg/golinters/noinlineerr/testdata/fix/in/noinlineerr.go @@ -0,0 +1,59 @@ +//golangcitest:args -Enoinlineerr +//golangcitest:expected_exitcode 0 +package testdata + +type MyAliasErr error + +type MyCustomError struct{} + +func (mc *MyCustomError) Error() string { + return "error" +} + +func doSomething() error { + return nil +} + +func doSmthManyArgs(a, b, c, d int) error { + return nil +} + +func doSmthMultipleReturn() (bool, error) { + return false, nil +} + +func doMyAliasErr() MyAliasErr { + return nil +} + +func doMyCustomErr() *MyCustomError { + return &MyCustomError{} +} + +func invalid() error { + err := doSomething() + if err != nil { + return err + } + + err = doSmthManyArgs(0, + 0, + 0, + 0, + ) + if err != nil { + return err + } + + err = doMyAliasErr() + if err != nil { + return err + } + + err = doMyCustomErr() + if err != nil { + return err + } + + return nil +} diff --git a/pkg/golinters/noinlineerr/testdata/fix/out/noinlineerr.go b/pkg/golinters/noinlineerr/testdata/fix/out/noinlineerr.go new file mode 100644 index 000000000000..62c90bd98017 --- /dev/null +++ b/pkg/golinters/noinlineerr/testdata/fix/out/noinlineerr.go @@ -0,0 +1,59 @@ +//golangcitest:args -Enoinlineerr +//golangcitest:expected_exitcode 0 +package testdata + +type MyAliasErr error + +type MyCustomError struct{} + +func (mc *MyCustomError) Error() string { + return "error" +} + +func doSomething() error { + return nil +} + +func doSmthManyArgs(a, b, c, d int) error { + return nil +} + +func doSmthMultipleReturn() (bool, error) { + return false, nil +} + +func doMyAliasErr() MyAliasErr { + return nil +} + +func doMyCustomErr() *MyCustomError { + return &MyCustomError{} +} + +func invalid() error { + err := doSomething() + if err != nil { + return err + } + + err = doSmthManyArgs(0, + 0, + 0, + 0, + ) + if err != nil { + return err + } + + err = doMyAliasErr() + if err != nil { + return err + } + + err = doMyCustomErr() + if err != nil { + return err + } + + return nil +} diff --git a/pkg/golinters/noinlineerr/testdata/noinlineerr.go b/pkg/golinters/noinlineerr/testdata/noinlineerr.go new file mode 100644 index 000000000000..3bf739b7d1c3 --- /dev/null +++ b/pkg/golinters/noinlineerr/testdata/noinlineerr.go @@ -0,0 +1,87 @@ +//golangcitest:args -Enoinlineerr +package testdata + +import ( + "fmt" + "strconv" +) + +type MyAliasErr error + +type MyCustomError struct {} + +func (mc *MyCustomError) Error() string { + return "error" +} + +func doSomething() error { + return nil +} + +func doSmthManyArgs(a, b, c, d int) error { + return nil +} + +func doSmthMultipleReturn() (bool, error) { + return false, nil +} + +func doMyAliasErr() MyAliasErr { + return nil +} + +func doMyCustomErr() *MyCustomError { + return &MyCustomError{} +} + +func valid() error { + err := doSomething() // ok + if err != nil { + return err + } + + err = doSmthManyArgs(0, 0, 0, 0) // ok + if err != nil { + return err + } + + _, err = doSmthMultipleReturn() // ok + if err != nil { + return err + } + + if ok, _ := strconv.ParseBool("1"); ok { + fmt.Println("ok") + } + + return nil +} + +func invalid() error { + if err := doSomething(); err != nil { // want "avoid inline error handling using `if err := ...; err != nil`; use plain assignment `err := ...`" + return err + } + + if err := doSmthManyArgs(0, // want "avoid inline error handling using `if err := ...; err != nil`; use plain assignment `err := ...`" + 0, + 0, + 0, + ); err != nil { + return err + } + + if _, err := doSmthMultipleReturn(); err != nil { // want "avoid inline error handling using `if err := ...; err != nil`; use plain assignment `err := ...`" + _ = false + return err + } + + if err := doMyAliasErr(); err != nil { // want "avoid inline error handling using `if err := ...; err != nil`; use plain assignment `err := ...`" + return err + } + + if err := doMyCustomErr(); err != nil { // want "avoid inline error handling using `if err := ...; err != nil`; use plain assignment `err := ...`" + return err + } + + return nil +} diff --git a/pkg/lint/lintersdb/builder_linter.go b/pkg/lint/lintersdb/builder_linter.go index 48a64375f53c..734aab63cd1c 100644 --- a/pkg/lint/lintersdb/builder_linter.go +++ b/pkg/lint/lintersdb/builder_linter.go @@ -79,6 +79,7 @@ import ( "github.com/golangci/golangci-lint/v2/pkg/golinters/nilnil" "github.com/golangci/golangci-lint/v2/pkg/golinters/nlreturn" "github.com/golangci/golangci-lint/v2/pkg/golinters/noctx" + "github.com/golangci/golangci-lint/v2/pkg/golinters/noinlineerr" "github.com/golangci/golangci-lint/v2/pkg/golinters/nolintlint" "github.com/golangci/golangci-lint/v2/pkg/golinters/nonamedreturns" "github.com/golangci/golangci-lint/v2/pkg/golinters/nosprintfhostport" @@ -511,6 +512,11 @@ func (LinterBuilder) Build(cfg *config.Config) ([]*linter.Config, error) { WithLoadForGoAnalysis(). WithURL("https://github.com/sonatard/noctx"), + linter.NewConfig(noinlineerr.New()). + WithSince("v2.2.0"). + WithLoadForGoAnalysis(). + WithURL("https://github.com/AlwxSin/noinlineerr"), + linter.NewConfig(nonamedreturns.New(&cfg.Linters.Settings.NoNamedReturns)). WithSince("v1.46.0"). WithLoadForGoAnalysis(). From 026567f803379eaab587112aabbbdcaf49e6fb8d Mon Sep 17 00:00:00 2001 From: Oleksandr Redko Date: Sat, 31 May 2025 02:12:14 +0300 Subject: [PATCH 85/96] dev: some simplifications (#5843) --- .../internal/migrate/migrate_linter_names.go | 14 ++++---------- pkg/goformatters/internal/diff.go | 5 +---- pkg/golinters/govet/govet_test.go | 2 +- pkg/golinters/tagliatelle/tagliatelle.go | 6 +++--- pkg/report/log.go | 3 ++- pkg/result/processors/base_rule.go | 9 ++------- pkg/result/processors/nolint_filter.go | 3 +-- test/testshared/integration/run.go | 3 ++- test/testshared/runner.go | 7 +++---- 9 files changed, 19 insertions(+), 33 deletions(-) diff --git a/pkg/commands/internal/migrate/migrate_linter_names.go b/pkg/commands/internal/migrate/migrate_linter_names.go index da003e9af77d..bbb178ab3846 100644 --- a/pkg/commands/internal/migrate/migrate_linter_names.go +++ b/pkg/commands/internal/migrate/migrate_linter_names.go @@ -749,11 +749,8 @@ func allEnabled(old versionone.Linters, linters []LinterInfo) []LinterInfo { var results []LinterInfo for _, linter := range linters { - for _, name := range old.Enable { - if linter.isName(name) { - results = append(results, linter) - break - } + if slices.ContainsFunc(old.Enable, linter.isName) { + results = append(results, linter) } } @@ -764,11 +761,8 @@ func allDisabled(old versionone.Linters, linters []LinterInfo) []LinterInfo { var results []LinterInfo for _, linter := range linters { - for _, name := range old.Disable { - if linter.isName(name) { - results = append(results, linter) - break - } + if slices.ContainsFunc(old.Disable, linter.isName) { + results = append(results, linter) } } diff --git a/pkg/goformatters/internal/diff.go b/pkg/goformatters/internal/diff.go index 7b9f80bc4228..fcec87bb8bbd 100644 --- a/pkg/goformatters/internal/diff.go +++ b/pkg/goformatters/internal/diff.go @@ -250,10 +250,7 @@ func ExtractDiagnosticFromPatch( } func toDiagnostic(ft *token.File, change Change, adjLine int) analysis.Diagnostic { - from := change.From + adjLine - if from > ft.LineCount() { - from = ft.LineCount() - } + from := min(change.From+adjLine, ft.LineCount()) start := ft.LineStart(from) diff --git a/pkg/golinters/govet/govet_test.go b/pkg/golinters/govet/govet_test.go index ec7072795f74..794ef6ece9db 100644 --- a/pkg/golinters/govet/govet_test.go +++ b/pkg/golinters/govet/govet_test.go @@ -18,7 +18,7 @@ import ( func TestGovet(t *testing.T) { // Checking that every default analyzer is in "all analyzers" list. - checkList := append([]*analysis.Analyzer{}, defaultAnalyzers...) + checkList := slices.Clone(defaultAnalyzers) checkList = append(checkList, shadow.Analyzer) // special case, used in analyzersFromConfig for _, defaultAnalyzer := range checkList { diff --git a/pkg/golinters/tagliatelle/tagliatelle.go b/pkg/golinters/tagliatelle/tagliatelle.go index 89ebf6c2f4df..e12cc9e82062 100644 --- a/pkg/golinters/tagliatelle/tagliatelle.go +++ b/pkg/golinters/tagliatelle/tagliatelle.go @@ -1,6 +1,8 @@ package tagliatelle import ( + "maps" + "github.com/ldez/tagliatelle" "github.com/golangci/golangci-lint/v2/pkg/config" @@ -19,9 +21,7 @@ func New(settings *config.TagliatelleSettings) *goanalysis.Linter { } if settings != nil { - for k, v := range settings.Case.Rules { - cfg.Rules[k] = v - } + maps.Copy(cfg.Rules, settings.Case.Rules) cfg.ExtendedRules = toExtendedRules(settings.Case.ExtendedRules) cfg.UseFieldName = settings.Case.UseFieldName diff --git a/pkg/report/log.go b/pkg/report/log.go index ad096415123f..c964af559379 100644 --- a/pkg/report/log.go +++ b/pkg/report/log.go @@ -2,6 +2,7 @@ package report import ( "fmt" + "slices" "strings" "github.com/golangci/golangci-lint/v2/pkg/logutils" @@ -50,7 +51,7 @@ func (lw LogWrapper) Infof(format string, args ...any) { func (lw LogWrapper) Child(name string) logutils.Log { c := lw c.origLog = lw.origLog.Child(name) - c.tags = append([]string{}, lw.tags...) + c.tags = slices.Clone(lw.tags) c.tags = append(c.tags, name) return c } diff --git a/pkg/result/processors/base_rule.go b/pkg/result/processors/base_rule.go index 607886ef1f39..46886624848a 100644 --- a/pkg/result/processors/base_rule.go +++ b/pkg/result/processors/base_rule.go @@ -2,6 +2,7 @@ package processors import ( "regexp" + "slices" "github.com/golangci/golangci-lint/v2/pkg/config" "github.com/golangci/golangci-lint/v2/pkg/fsutils" @@ -73,13 +74,7 @@ func (r *baseRule) match(issue *result.Issue, lines *fsutils.LineCache, log logu } func (r *baseRule) matchLinter(issue *result.Issue) bool { - for _, linter := range r.linters { - if linter == issue.FromLinter { - return true - } - } - - return false + return slices.Contains(r.linters, issue.FromLinter) } func (r *baseRule) matchSource(issue *result.Issue, lineCache *fsutils.LineCache, log logutils.Log) bool { diff --git a/pkg/result/processors/nolint_filter.go b/pkg/result/processors/nolint_filter.go index 96fd6403ec45..e17fd7ad2521 100644 --- a/pkg/result/processors/nolint_filter.go +++ b/pkg/result/processors/nolint_filter.go @@ -185,8 +185,7 @@ func (p *NolintFilter) buildIgnoredRangesForFile(f *ast.File, fset *token.FileSe ast.Walk(&e, f) // TODO: merge all ranges: there are repeated ranges - allRanges := append([]ignoredRange{}, inlineRanges...) - allRanges = append(allRanges, e.expandedRanges...) + allRanges := slices.Concat(inlineRanges, e.expandedRanges) return allRanges } diff --git a/test/testshared/integration/run.go b/test/testshared/integration/run.go index cd0b4ca97076..f1add865fb54 100644 --- a/test/testshared/integration/run.go +++ b/test/testshared/integration/run.go @@ -4,6 +4,7 @@ import ( "os" "os/exec" "path/filepath" + "slices" "strings" "testing" "time" @@ -70,7 +71,7 @@ func testOneSource(t *testing.T, log *logutils.StderrLog, binPath, sourcePath st } for _, addArg := range []string{"", "-Etypecheck"} { - caseArgs := append([]string{}, args...) + caseArgs := slices.Clone(args) if addArg != "" { caseArgs = append(caseArgs, addArg) diff --git a/test/testshared/runner.go b/test/testshared/runner.go index c516ad9a181a..69bb8bac80a7 100644 --- a/test/testshared/runner.go +++ b/test/testshared/runner.go @@ -4,6 +4,7 @@ import ( "os" "os/exec" "path/filepath" + "slices" "strings" "sync" "syscall" @@ -286,10 +287,8 @@ func (r *RunnerResult) ExpectNoIssues() { func (r *RunnerResult) ExpectExitCode(possibleCodes ...int) *RunnerResult { r.tb.Helper() - for _, pc := range possibleCodes { - if pc == r.exitCode { - return r - } + if slices.Contains(possibleCodes, r.exitCode) { + return r } assert.Fail(r.tb, "invalid exit code", "exit code (%d) must be one of %v: %s", r.exitCode, possibleCodes, r.output) From a029aba99bd0f85a622492cfcbdeffc8b58740a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ville=20Skytt=C3=A4?= Date: Sun, 1 Jun 2025 11:47:57 +0300 Subject: [PATCH 86/96] dev: improve comments (#5846) --- pkg/goanalysis/pkgerrors/parse.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/goanalysis/pkgerrors/parse.go b/pkg/goanalysis/pkgerrors/parse.go index 8c49a55929ed..2fe1fb529fa4 100644 --- a/pkg/goanalysis/pkgerrors/parse.go +++ b/pkg/goanalysis/pkgerrors/parse.go @@ -26,7 +26,7 @@ func parseError(srcErr packages.Error) (*result.Issue, error) { } func parseErrorPosition(pos string) (*token.Position, error) { - // file:line(:colon) + // file:line(:column) parts := strings.Split(pos, ":") if len(parts) == 1 { return nil, errors.New("no colons") @@ -39,7 +39,7 @@ func parseErrorPosition(pos string) (*token.Position, error) { } var column int - if len(parts) == 3 { // no column + if len(parts) == 3 { // got column column, err = strconv.Atoi(parts[2]) if err != nil { return nil, fmt.Errorf("failed to parse column from %q: %w", parts[2], err) From a02b91e66f7ba7aaba3b4f22d7e9dc4aa44ab9ad Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sun, 1 Jun 2025 14:24:25 +0200 Subject: [PATCH 87/96] build(deps): bump github.com/shirou/gopsutil/v4 from 4.25.4 to 4.25.5 (#5849) --- go.mod | 4 ++-- go.sum | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/go.mod b/go.mod index 6f084bed2675..c4b63fa87ff7 100644 --- a/go.mod +++ b/go.mod @@ -100,7 +100,7 @@ require ( github.com/sashamelentyev/interfacebloat v1.1.0 github.com/sashamelentyev/usestdlibvars v1.29.0 github.com/securego/gosec/v2 v2.22.4 - github.com/shirou/gopsutil/v4 v4.25.4 + github.com/shirou/gopsutil/v4 v4.25.5 github.com/sirupsen/logrus v1.9.3 github.com/sivchari/containedctx v1.0.3 github.com/sonatard/noctx v0.3.3 @@ -155,7 +155,7 @@ require ( github.com/dave/dst v0.27.3 // indirect github.com/davecgh/go-spew v1.1.1 // indirect github.com/dlclark/regexp2 v1.11.5 // indirect - github.com/ebitengine/purego v0.8.2 // indirect + github.com/ebitengine/purego v0.8.4 // indirect github.com/ettle/strcase v0.2.0 // indirect github.com/fatih/structtag v1.2.0 // indirect github.com/fsnotify/fsnotify v1.5.4 // indirect diff --git a/go.sum b/go.sum index 0a4e0d2587b0..182e746f2b29 100644 --- a/go.sum +++ b/go.sum @@ -152,8 +152,8 @@ github.com/denis-tingaikin/go-header v0.5.0 h1:SRdnP5ZKvcO9KKRP1KJrhFR3RrlGuD+42 github.com/denis-tingaikin/go-header v0.5.0/go.mod h1:mMenU5bWrok6Wl2UsZjy+1okegmwQ3UgWl4V1D8gjlY= github.com/dlclark/regexp2 v1.11.5 h1:Q/sSnsKerHeCkc/jSTNq1oCm7KiVgUMZRDUoRu0JQZQ= github.com/dlclark/regexp2 v1.11.5/go.mod h1:DHkYz0B9wPfa6wondMfaivmHpzrQ3v9q8cnmRbL6yW8= -github.com/ebitengine/purego v0.8.2 h1:jPPGWs2sZ1UgOSgD2bClL0MJIqu58nOmIcBuXr62z1I= -github.com/ebitengine/purego v0.8.2/go.mod h1:iIjxzd6CiRiOG0UyXP+V1+jWqUXVjPKLAI0mRfJZTmQ= +github.com/ebitengine/purego v0.8.4 h1:CF7LEKg5FFOsASUj0+QwaXf8Ht6TlFxg09+S9wz0omw= +github.com/ebitengine/purego v0.8.4/go.mod h1:iIjxzd6CiRiOG0UyXP+V1+jWqUXVjPKLAI0mRfJZTmQ= github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98= @@ -522,8 +522,8 @@ github.com/securego/gosec/v2 v2.22.4 h1:21VdNGcKicFSv6rUDBc0cEtEl7lWyCKZxKIm0iwv github.com/securego/gosec/v2 v2.22.4/go.mod h1:ww5Yie7KJ3AH8XZQTletkW5zOmIse6FACs/Ys8VR3qE= github.com/sergi/go-diff v1.2.0 h1:XU+rvMAioB0UC3q1MFrIQy4Vo5/4VsRDQQXHsEya6xQ= github.com/sergi/go-diff v1.2.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM= -github.com/shirou/gopsutil/v4 v4.25.4 h1:cdtFO363VEOOFrUCjZRh4XVJkb548lyF0q0uTeMqYPw= -github.com/shirou/gopsutil/v4 v4.25.4/go.mod h1:xbuxyoZj+UsgnZrENu3lQivsngRR5BdjbJwf2fv4szA= +github.com/shirou/gopsutil/v4 v4.25.5 h1:rtd9piuSMGeU8g1RMXjZs9y9luK5BwtnG7dZaQUJAsc= +github.com/shirou/gopsutil/v4 v4.25.5/go.mod h1:PfybzyydfZcN+JMMjkF6Zb8Mq1A/VcogFFg7hj50W9c= github.com/shurcooL/go v0.0.0-20180423040247-9e1955d9fb6e/go.mod h1:TDJrrUr11Vxrven61rcy3hJMUqaf/CLWYhHNPmT14Lk= github.com/shurcooL/go-goon v0.0.0-20170922171312-37c2f522c041/go.mod h1:N5mDOmsrJOB+vfqUK+7DmDyjhSLIIBnXo9lvZJj3MWQ= github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= From 69479c6d0edbf16f6277fcecfcea79263d3a6f94 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sun, 1 Jun 2025 14:25:16 +0200 Subject: [PATCH 88/96] build(deps): bump the linter-testdata group across 4 directories with 4 updates (#5850) --- pkg/golinters/ginkgolinter/testdata/go.mod | 2 +- pkg/golinters/ginkgolinter/testdata/go.sum | 4 ++-- pkg/golinters/loggercheck/testdata/go.mod | 2 +- pkg/golinters/loggercheck/testdata/go.sum | 4 ++-- pkg/golinters/protogetter/testdata/go.mod | 2 +- pkg/golinters/protogetter/testdata/go.sum | 4 ++-- pkg/golinters/spancheck/testdata/go.mod | 8 ++++---- pkg/golinters/spancheck/testdata/go.sum | 16 ++++++++-------- 8 files changed, 21 insertions(+), 21 deletions(-) diff --git a/pkg/golinters/ginkgolinter/testdata/go.mod b/pkg/golinters/ginkgolinter/testdata/go.mod index ede5795987b6..078968acadbb 100644 --- a/pkg/golinters/ginkgolinter/testdata/go.mod +++ b/pkg/golinters/ginkgolinter/testdata/go.mod @@ -8,7 +8,7 @@ require ( ) require ( - github.com/go-logr/logr v1.4.2 // indirect + github.com/go-logr/logr v1.4.3 // indirect github.com/go-task/slim-sprig/v3 v3.0.0 // indirect github.com/google/go-cmp v0.7.0 // indirect github.com/google/pprof v0.0.0-20250403155104-27863c87afa6 // indirect diff --git a/pkg/golinters/ginkgolinter/testdata/go.sum b/pkg/golinters/ginkgolinter/testdata/go.sum index bbd84ab067c2..29f1ee9e9a59 100644 --- a/pkg/golinters/ginkgolinter/testdata/go.sum +++ b/pkg/golinters/ginkgolinter/testdata/go.sum @@ -1,7 +1,7 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/go-logr/logr v1.4.2 h1:6pFjapn8bFcIbiKo3XT4j/BhANplGihG6tvd+8rYgrY= -github.com/go-logr/logr v1.4.2/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= +github.com/go-logr/logr v1.4.3 h1:CjnDlHq8ikf6E492q6eKboGOC0T8CDaOvkHCIg8idEI= +github.com/go-logr/logr v1.4.3/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= github.com/go-task/slim-sprig/v3 v3.0.0 h1:sUs3vkvUymDpBKi3qH1YSqBQk9+9D/8M2mN1vB6EwHI= github.com/go-task/slim-sprig/v3 v3.0.0/go.mod h1:W848ghGpv3Qj3dhTPRyJypKRiqCdHZiAzKg9hl15HA8= github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8= diff --git a/pkg/golinters/loggercheck/testdata/go.mod b/pkg/golinters/loggercheck/testdata/go.mod index 985fff765d4b..0df788c08b62 100644 --- a/pkg/golinters/loggercheck/testdata/go.mod +++ b/pkg/golinters/loggercheck/testdata/go.mod @@ -4,7 +4,7 @@ go 1.21.0 require ( github.com/go-kit/log v0.2.1 - github.com/go-logr/logr v1.4.2 + github.com/go-logr/logr v1.4.3 go.uber.org/zap v1.27.0 k8s.io/klog/v2 v2.130.1 ) diff --git a/pkg/golinters/loggercheck/testdata/go.sum b/pkg/golinters/loggercheck/testdata/go.sum index 5a316ccca990..dd912496e496 100644 --- a/pkg/golinters/loggercheck/testdata/go.sum +++ b/pkg/golinters/loggercheck/testdata/go.sum @@ -4,8 +4,8 @@ github.com/go-kit/log v0.2.1 h1:MRVx0/zhvdseW+Gza6N9rVzU/IVzaeE1SFI4raAhmBU= github.com/go-kit/log v0.2.1/go.mod h1:NwTd00d/i8cPZ3xOwwiv2PO5MOcx78fFErGNcVmBjv0= github.com/go-logfmt/logfmt v0.6.0 h1:wGYYu3uicYdqXVgoYbvnkrPVXkuLM1p1ifugDMEdRi4= github.com/go-logfmt/logfmt v0.6.0/go.mod h1:WYhtIu8zTZfxdn5+rREduYbwxfcBr/Vr6KEVveWlfTs= -github.com/go-logr/logr v1.4.2 h1:6pFjapn8bFcIbiKo3XT4j/BhANplGihG6tvd+8rYgrY= -github.com/go-logr/logr v1.4.2/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= +github.com/go-logr/logr v1.4.3 h1:CjnDlHq8ikf6E492q6eKboGOC0T8CDaOvkHCIg8idEI= +github.com/go-logr/logr v1.4.3/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/stretchr/testify v1.8.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKsk= diff --git a/pkg/golinters/protogetter/testdata/go.mod b/pkg/golinters/protogetter/testdata/go.mod index 894a03ffa01e..ac7bf891a2f6 100644 --- a/pkg/golinters/protogetter/testdata/go.mod +++ b/pkg/golinters/protogetter/testdata/go.mod @@ -3,7 +3,7 @@ module protogetter go 1.23.0 require ( - google.golang.org/grpc v1.72.1 + google.golang.org/grpc v1.72.2 google.golang.org/protobuf v1.36.6 ) diff --git a/pkg/golinters/protogetter/testdata/go.sum b/pkg/golinters/protogetter/testdata/go.sum index 99952097dc15..88c148026714 100644 --- a/pkg/golinters/protogetter/testdata/go.sum +++ b/pkg/golinters/protogetter/testdata/go.sum @@ -28,7 +28,7 @@ golang.org/x/text v0.25.0 h1:qVyWApTSYLk/drJRO5mDlNYskwQznZmkpV2c8q9zls4= golang.org/x/text v0.25.0/go.mod h1:WEdwpYrmk1qmdHvhkSTNPm3app7v4rsT8F2UD6+VHIA= google.golang.org/genproto/googleapis/rpc v0.0.0-20250218202821-56aae31c358a h1:51aaUVRocpvUOSQKM6Q7VuoaktNIaMCLuhZB6DKksq4= google.golang.org/genproto/googleapis/rpc v0.0.0-20250218202821-56aae31c358a/go.mod h1:uRxBH1mhmO8PGhU89cMcHaXKZqO+OfakD8QQO0oYwlQ= -google.golang.org/grpc v1.72.1 h1:HR03wO6eyZ7lknl75XlxABNVLLFc2PAb6mHlYh756mA= -google.golang.org/grpc v1.72.1/go.mod h1:wH5Aktxcg25y1I3w7H69nHfXdOG3UiadoBtjh3izSDM= +google.golang.org/grpc v1.72.2 h1:TdbGzwb82ty4OusHWepvFWGLgIbNo1/SUynEN0ssqv8= +google.golang.org/grpc v1.72.2/go.mod h1:wH5Aktxcg25y1I3w7H69nHfXdOG3UiadoBtjh3izSDM= google.golang.org/protobuf v1.36.6 h1:z1NpPI8ku2WgiWnf+t9wTPsn6eP1L7ksHUlkfLvd9xY= google.golang.org/protobuf v1.36.6/go.mod h1:jduwjTPXsFjZGTmRluh+L6NjiWu7pchiJ2/5YcXBHnY= diff --git a/pkg/golinters/spancheck/testdata/go.mod b/pkg/golinters/spancheck/testdata/go.mod index df3444491ace..256ae9e1b2a9 100644 --- a/pkg/golinters/spancheck/testdata/go.mod +++ b/pkg/golinters/spancheck/testdata/go.mod @@ -3,13 +3,13 @@ module spancheck go 1.23.0 require ( - go.opentelemetry.io/otel v1.35.0 - go.opentelemetry.io/otel/trace v1.35.0 + go.opentelemetry.io/otel v1.36.0 + go.opentelemetry.io/otel/trace v1.36.0 ) require ( - github.com/go-logr/logr v1.4.2 // indirect + github.com/go-logr/logr v1.4.3 // indirect github.com/go-logr/stdr v1.2.2 // indirect go.opentelemetry.io/auto/sdk v1.1.0 // indirect - go.opentelemetry.io/otel/metric v1.35.0 // indirect + go.opentelemetry.io/otel/metric v1.36.0 // indirect ) diff --git a/pkg/golinters/spancheck/testdata/go.sum b/pkg/golinters/spancheck/testdata/go.sum index 98e72be93493..da8e1100881e 100644 --- a/pkg/golinters/spancheck/testdata/go.sum +++ b/pkg/golinters/spancheck/testdata/go.sum @@ -1,8 +1,8 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= -github.com/go-logr/logr v1.4.2 h1:6pFjapn8bFcIbiKo3XT4j/BhANplGihG6tvd+8rYgrY= -github.com/go-logr/logr v1.4.2/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= +github.com/go-logr/logr v1.4.3 h1:CjnDlHq8ikf6E492q6eKboGOC0T8CDaOvkHCIg8idEI= +github.com/go-logr/logr v1.4.3/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag= github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE= github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8= @@ -13,11 +13,11 @@ github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOf github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= go.opentelemetry.io/auto/sdk v1.1.0 h1:cH53jehLUN6UFLY71z+NDOiNJqDdPRaXzTel0sJySYA= go.opentelemetry.io/auto/sdk v1.1.0/go.mod h1:3wSPjt5PWp2RhlCcmmOial7AvC4DQqZb7a7wCow3W8A= -go.opentelemetry.io/otel v1.35.0 h1:xKWKPxrxB6OtMCbmMY021CqC45J+3Onta9MqjhnusiQ= -go.opentelemetry.io/otel v1.35.0/go.mod h1:UEqy8Zp11hpkUrL73gSlELM0DupHoiq72dR+Zqel/+Y= -go.opentelemetry.io/otel/metric v1.35.0 h1:0znxYu2SNyuMSQT4Y9WDWej0VpcsxkuklLa4/siN90M= -go.opentelemetry.io/otel/metric v1.35.0/go.mod h1:nKVFgxBZ2fReX6IlyW28MgZojkoAkJGaE8CpgeAU3oE= -go.opentelemetry.io/otel/trace v1.35.0 h1:dPpEfJu1sDIqruz7BHFG3c7528f6ddfSWfFDVt/xgMs= -go.opentelemetry.io/otel/trace v1.35.0/go.mod h1:WUk7DtFp1Aw2MkvqGdwiXYDZZNvA/1J8o6xRXLrIkyc= +go.opentelemetry.io/otel v1.36.0 h1:UumtzIklRBY6cI/lllNZlALOF5nNIzJVb16APdvgTXg= +go.opentelemetry.io/otel v1.36.0/go.mod h1:/TcFMXYjyRNh8khOAO9ybYkqaDBb/70aVwkNML4pP8E= +go.opentelemetry.io/otel/metric v1.36.0 h1:MoWPKVhQvJ+eeXWHFBOPoBOi20jh6Iq2CcCREuTYufE= +go.opentelemetry.io/otel/metric v1.36.0/go.mod h1:zC7Ks+yeyJt4xig9DEw9kuUFe5C3zLbVjV2PzT6qzbs= +go.opentelemetry.io/otel/trace v1.36.0 h1:ahxWNuqZjpdiFAyrIoQ4GIiAIhxAunQR6MUoKrsNd4w= +go.opentelemetry.io/otel/trace v1.36.0/go.mod h1:gQ+OnDZzrybY4k4seLzPAWNwVBBVlF2szhehOBB/tGA= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= From 59936083e6a18b8b1e539f0a3e100d12795c027b Mon Sep 17 00:00:00 2001 From: Ludovic Fernandez Date: Mon, 2 Jun 2025 11:04:10 +0200 Subject: [PATCH 89/96] docs: improve module plugin explanation (#5851) --- docs/src/docs/plugins/module-plugins.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/src/docs/plugins/module-plugins.mdx b/docs/src/docs/plugins/module-plugins.mdx index 9fa36766ebb6..f6e4ad77d2c1 100644 --- a/docs/src/docs/plugins/module-plugins.mdx +++ b/docs/src/docs/plugins/module-plugins.mdx @@ -9,7 +9,7 @@ An example linter can be found at [here](https://github.com/golangci/example-plu - Define your building configuration into `.custom-gcl.yml`. - Run the command `golangci-lint custom` (or `golangci-lint custom -v` to have logs). - Define the plugin inside the `linters.settings.custom` section with the type `module`. -- Run your custom version of golangci-lint. +- Run the resulting custom binary of golangci-lint (`./custom-gcl` by default). Requirements: - Go From aa988352ff5b86f88095d95f03c2223ff54a666f Mon Sep 17 00:00:00 2001 From: Oleksandr Redko Date: Mon, 2 Jun 2025 14:45:24 +0300 Subject: [PATCH 90/96] dev: display list of staticcheck checks in debug (#5853) --- pkg/golinters/staticcheck/staticcheck.go | 36 ++++++++++++++++++++---- pkg/logutils/logutils.go | 11 ++++---- 2 files changed, 36 insertions(+), 11 deletions(-) diff --git a/pkg/golinters/staticcheck/staticcheck.go b/pkg/golinters/staticcheck/staticcheck.go index 1ec39244c100..7aae52870cbb 100644 --- a/pkg/golinters/staticcheck/staticcheck.go +++ b/pkg/golinters/staticcheck/staticcheck.go @@ -15,6 +15,12 @@ import ( "github.com/golangci/golangci-lint/v2/pkg/config" "github.com/golangci/golangci-lint/v2/pkg/goanalysis" + "github.com/golangci/golangci-lint/v2/pkg/logutils" +) + +var ( + debugf = logutils.Debug(logutils.DebugKeyStaticcheck) + isDebug = logutils.HaveDebugTag(logutils.DebugKeyStaticcheck) ) func New(settings *config.StaticCheckSettings) *goanalysis.Linter { @@ -29,6 +35,21 @@ func New(settings *config.StaticCheckSettings) *goanalysis.Linter { analyzers := setupAnalyzers(allAnalyzers, cfg.Checks) + if isDebug { + allAnalyzerNames := extractAnalyzerNames(allAnalyzers) + slices.Sort(allAnalyzerNames) + debugf("All available checks (%d): %s", len(allAnalyzers), strings.Join(allAnalyzerNames, ",")) + + var cfgAnalyzerNames []string + for _, a := range analyzers { + cfgAnalyzerNames = append(cfgAnalyzerNames, a.Name) + } + slices.Sort(cfgAnalyzerNames) + debugf("Enabled by config checks (%d): %s", len(analyzers), strings.Join(cfgAnalyzerNames, ",")) + + debugf("staticcheck configuration: %#v", cfg) + } + return goanalysis.NewLinter( "staticcheck", "It's the set of rules from staticcheck.", @@ -107,12 +128,7 @@ func normalizeList(list []string) []string { } func setupAnalyzers(src []*lint.Analyzer, checks []string) []*analysis.Analyzer { - var names []string - for _, a := range src { - names = append(names, a.Analyzer.Name) - } - - filter := filterAnalyzerNames(names, checks) + filter := filterAnalyzerNames(extractAnalyzerNames(src), checks) var ret []*analysis.Analyzer for _, a := range src { @@ -124,6 +140,14 @@ func setupAnalyzers(src []*lint.Analyzer, checks []string) []*analysis.Analyzer return ret } +func extractAnalyzerNames(analyzers []*lint.Analyzer) []string { + var names []string + for _, a := range analyzers { + names = append(names, a.Analyzer.Name) + } + return names +} + // https://github.com/dominikh/go-tools/blob/9bf17c0388a65710524ba04c2d821469e639fdc2/lintcmd/lint.go#L437-L477 // //nolint:gocritic // Keep the original source code. diff --git a/pkg/logutils/logutils.go b/pkg/logutils/logutils.go index 0ee48a3664bd..e417ac4b738d 100644 --- a/pkg/logutils/logutils.go +++ b/pkg/logutils/logutils.go @@ -79,11 +79,12 @@ const ( // Linters. const ( - DebugKeyForbidigo = "forbidigo" // Debugs `forbidigo` linter. - DebugKeyGoCritic = "gocritic" // Debugs `gocritic` linter. - DebugKeyGovet = "govet" // Debugs `govet` linter. - DebugKeyLinter = "linter" - DebugKeyRevive = "revive" // Debugs `revive` linter. + DebugKeyForbidigo = "forbidigo" // Debugs `forbidigo` linter. + DebugKeyGoCritic = "gocritic" // Debugs `gocritic` linter. + DebugKeyGovet = "govet" // Debugs `govet` linter. + DebugKeyLinter = "linter" + DebugKeyRevive = "revive" // Debugs `revive` linter. + DebugKeyStaticcheck = "staticcheck" // Debugs `staticcheck` linter. ) func getEnabledDebugs() map[string]bool { From c24d5d16f0ce4f571606f6aa5617ddccedbd99a6 Mon Sep 17 00:00:00 2001 From: Oleksandr Redko Date: Mon, 2 Jun 2025 14:46:53 +0300 Subject: [PATCH 91/96] dev: correct debug log for default rules in revive (#5852) --- pkg/golinters/revive/revive.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/golinters/revive/revive.go b/pkg/golinters/revive/revive.go index 01eccd537d9e..b06b5de8aa28 100644 --- a/pkg/golinters/revive/revive.go +++ b/pkg/golinters/revive/revive.go @@ -436,7 +436,7 @@ func displayRules(conf *lint.Config) { slices.Sort(enabledRules) debugf("All available rules (%d): %s.", len(allRules), strings.Join(extractRulesName(allRules), ", ")) - debugf("Default rules (%d): %s.", len(allRules), strings.Join(extractRulesName(allRules), ", ")) + debugf("Default rules (%d): %s.", len(defaultRules), strings.Join(extractRulesName(defaultRules), ", ")) debugf("Enabled by config rules (%d): %s.", len(enabledRules), strings.Join(enabledRules, ", ")) debugf("revive configuration: %#v", conf) From f8514979dbc8f9e5192530f88f9a24351eec4614 Mon Sep 17 00:00:00 2001 From: Ludovic Fernandez Date: Mon, 2 Jun 2025 21:54:29 +0200 Subject: [PATCH 92/96] dev: use slice of pointers (#5854) --- docs/src/docs/contributing/architecture.mdx | 2 +- pkg/commands/run.go | 6 +-- pkg/goanalysis/issue.go | 8 +-- pkg/goanalysis/linter.go | 8 +-- pkg/goanalysis/metalinter.go | 6 +-- pkg/goanalysis/pkgerrors/errors.go | 6 +-- pkg/goanalysis/runner.go | 6 +-- pkg/goanalysis/runners.go | 35 ++++++------- pkg/goanalysis/runners_cache.go | 43 ++++++++-------- pkg/golinters/dupl/dupl.go | 8 +-- pkg/golinters/errcheck/errcheck.go | 8 +-- .../gochecksumtype/gochecksumtype.go | 8 +-- pkg/golinters/gocognit/gocognit.go | 8 +-- pkg/golinters/goconst/goconst.go | 8 +-- pkg/golinters/gocyclo/gocyclo.go | 8 +-- .../gomoddirectives/gomoddirectives.go | 4 +- pkg/golinters/gomodguard/gomodguard.go | 4 +- pkg/golinters/gosec/gosec.go | 8 +-- .../nolintlint/internal/nolintlint.go | 4 +- .../nolintlint/internal/nolintlint_test.go | 22 ++++---- pkg/golinters/nolintlint/nolintlint.go | 4 +- pkg/golinters/promlinter/promlinter.go | 8 +-- pkg/golinters/revive/revive.go | 10 ++-- pkg/golinters/unconvert/unconvert.go | 8 +-- pkg/golinters/unused/unused.go | 8 +-- pkg/lint/linter/linter.go | 4 +- pkg/lint/runner.go | 18 +++---- pkg/printers/checkstyle.go | 5 +- pkg/printers/checkstyle_test.go | 2 +- pkg/printers/codeclimate.go | 6 +-- pkg/printers/codeclimate_test.go | 2 +- pkg/printers/html.go | 16 +++--- pkg/printers/html_test.go | 2 +- pkg/printers/json.go | 6 +-- pkg/printers/json_test.go | 2 +- pkg/printers/junitxml.go | 23 ++++----- pkg/printers/junitxml_test.go | 2 +- pkg/printers/printer.go | 4 +- pkg/printers/printer_test.go | 8 +-- pkg/printers/sarif.go | 6 +-- pkg/printers/sarif_test.go | 2 +- pkg/printers/tab.go | 6 +-- pkg/printers/tab_test.go | 2 +- pkg/printers/teamcity.go | 6 +-- pkg/printers/teamcity_test.go | 2 +- pkg/printers/text.go | 10 ++-- pkg/printers/text_test.go | 2 +- pkg/result/issue.go | 4 +- pkg/result/processors/cgo.go | 2 +- pkg/result/processors/diff.go | 2 +- .../exclusion_generated_file_filter.go | 2 +- pkg/result/processors/exclusion_paths.go | 2 +- pkg/result/processors/exclusion_paths_test.go | 48 +++++++++--------- pkg/result/processors/exclusion_rules.go | 2 +- pkg/result/processors/exclusion_rules_test.go | 12 ++--- pkg/result/processors/filename_unadjuster.go | 2 +- pkg/result/processors/fixer.go | 10 ++-- pkg/result/processors/invalid_issue.go | 2 +- pkg/result/processors/invalid_issue_test.go | 28 +++++------ pkg/result/processors/issues.go | 50 +++++++++---------- pkg/result/processors/max_from_linter.go | 2 +- .../processors/max_per_file_from_linter.go | 2 +- .../max_per_file_from_linter_test.go | 4 +- pkg/result/processors/max_same_issues.go | 2 +- pkg/result/processors/max_same_issues_test.go | 4 +- pkg/result/processors/nolint_filter.go | 4 +- pkg/result/processors/nolint_filter_test.go | 20 ++++---- pkg/result/processors/path_absoluter.go | 2 +- pkg/result/processors/path_prettifier.go | 2 +- pkg/result/processors/path_prettifier_test.go | 14 +++--- pkg/result/processors/path_relativity.go | 2 +- pkg/result/processors/path_shortener.go | 2 +- pkg/result/processors/processor.go | 2 +- pkg/result/processors/processor_test.go | 14 +++--- pkg/result/processors/severity.go | 2 +- pkg/result/processors/severity_test.go | 10 ++-- pkg/result/processors/sort_results.go | 6 +-- pkg/result/processors/sort_results_test.go | 14 +++--- pkg/result/processors/source_code.go | 2 +- pkg/result/processors/uniq_by_line.go | 2 +- pkg/result/processors/uniq_by_line_test.go | 4 +- .../website/expand_templates/thanks_test.go | 2 +- 82 files changed, 329 insertions(+), 339 deletions(-) diff --git a/docs/src/docs/contributing/architecture.mdx b/docs/src/docs/contributing/architecture.mdx index e9df647556da..e398db57e4e8 100644 --- a/docs/src/docs/contributing/architecture.mdx +++ b/docs/src/docs/contributing/architecture.mdx @@ -222,7 +222,7 @@ The abstraction is simple: ```go title=pkg/result/processors/processor.go type Processor interface { - Process(issues []result.Issue) ([]result.Issue, error) + Process(issues []*result.Issue) ([]*result.Issue, error) Name() string Finish() } diff --git a/pkg/commands/run.go b/pkg/commands/run.go index 53902eafac24..4e2d3b1b984a 100644 --- a/pkg/commands/run.go +++ b/pkg/commands/run.go @@ -376,7 +376,7 @@ func (c *runCommand) runAndPrint(ctx context.Context) error { } // runAnalysis executes the linters that have been enabled in the configuration. -func (c *runCommand) runAnalysis(ctx context.Context) ([]result.Issue, error) { +func (c *runCommand) runAnalysis(ctx context.Context) ([]*result.Issue, error) { lintersToRun, err := c.dbManager.GetOptimizedLinters() if err != nil { return nil, err @@ -408,7 +408,7 @@ func (c *runCommand) setOutputToDevNull() (savedStdout, savedStderr *os.File) { return } -func (c *runCommand) setExitCodeIfIssuesFound(issues []result.Issue) { +func (c *runCommand) setExitCodeIfIssuesFound(issues []*result.Issue) { if len(issues) != 0 { c.exitCode = c.cfg.Run.ExitCodeIfIssuesFound } @@ -433,7 +433,7 @@ func (c *runCommand) printDeprecatedLinterMessages(enabledLinters map[string]*li } } -func (c *runCommand) printStats(issues []result.Issue) { +func (c *runCommand) printStats(issues []*result.Issue) { if !c.cfg.Output.ShowStats { return } diff --git a/pkg/goanalysis/issue.go b/pkg/goanalysis/issue.go index c41702595c55..88a59e53dbc9 100644 --- a/pkg/goanalysis/issue.go +++ b/pkg/goanalysis/issue.go @@ -9,13 +9,13 @@ import ( ) type Issue struct { - result.Issue + *result.Issue Pass *analysis.Pass } -func NewIssue(issue *result.Issue, pass *analysis.Pass) Issue { - return Issue{ - Issue: *issue, +func NewIssue(issue *result.Issue, pass *analysis.Pass) *Issue { + return &Issue{ + Issue: issue, Pass: pass, } } diff --git a/pkg/goanalysis/linter.go b/pkg/goanalysis/linter.go index 53f5b7bae455..29bd841a85c6 100644 --- a/pkg/goanalysis/linter.go +++ b/pkg/goanalysis/linter.go @@ -40,7 +40,7 @@ type Linter struct { name, desc string analyzers []*analysis.Analyzer cfg map[string]map[string]any - issuesReporter func(*linter.Context) []Issue + issuesReporter func(*linter.Context) []*Issue contextSetter func(*linter.Context) loadMode LoadMode needUseOriginalPackages bool @@ -54,7 +54,7 @@ func NewLinterFromAnalyzer(analyzer *analysis.Analyzer) *Linter { return NewLinter(analyzer.Name, analyzer.Doc, []*analysis.Analyzer{analyzer}, nil) } -func (lnt *Linter) Run(_ context.Context, lintCtx *linter.Context) ([]result.Issue, error) { +func (lnt *Linter) Run(_ context.Context, lintCtx *linter.Context) ([]*result.Issue, error) { if err := lnt.preRun(lintCtx); err != nil { return nil, err } @@ -93,7 +93,7 @@ func (lnt *Linter) WithLoadMode(loadMode LoadMode) *Linter { return lnt } -func (lnt *Linter) WithIssuesReporter(r func(*linter.Context) []Issue) *Linter { +func (lnt *Linter) WithIssuesReporter(r func(*linter.Context) []*Issue) *Linter { lnt.issuesReporter = r return lnt } @@ -193,7 +193,7 @@ func (lnt *Linter) useOriginalPackages() bool { return lnt.needUseOriginalPackages } -func (lnt *Linter) reportIssues(lintCtx *linter.Context) []Issue { +func (lnt *Linter) reportIssues(lintCtx *linter.Context) []*Issue { if lnt.issuesReporter != nil { return lnt.issuesReporter(lintCtx) } diff --git a/pkg/goanalysis/metalinter.go b/pkg/goanalysis/metalinter.go index 4db143baddb3..b9a210a66fc8 100644 --- a/pkg/goanalysis/metalinter.go +++ b/pkg/goanalysis/metalinter.go @@ -21,7 +21,7 @@ func NewMetaLinter(linters []*Linter) *MetaLinter { return ml } -func (ml MetaLinter) Run(_ context.Context, lintCtx *linter.Context) ([]result.Issue, error) { +func (ml MetaLinter) Run(_ context.Context, lintCtx *linter.Context) ([]*result.Issue, error) { for _, l := range ml.linters { if err := l.preRun(lintCtx); err != nil { return nil, fmt.Errorf("failed to pre-run %s: %w", l.Name(), err) @@ -65,8 +65,8 @@ func (MetaLinter) useOriginalPackages() bool { return false // `unused` can't be run by this metalinter } -func (ml MetaLinter) reportIssues(lintCtx *linter.Context) []Issue { - var ret []Issue +func (ml MetaLinter) reportIssues(lintCtx *linter.Context) []*Issue { + var ret []*Issue for _, lnt := range ml.linters { if lnt.issuesReporter != nil { ret = append(ret, lnt.issuesReporter(lintCtx)...) diff --git a/pkg/goanalysis/pkgerrors/errors.go b/pkg/goanalysis/pkgerrors/errors.go index 587e72720e98..062a8f43aeff 100644 --- a/pkg/goanalysis/pkgerrors/errors.go +++ b/pkg/goanalysis/pkgerrors/errors.go @@ -18,8 +18,8 @@ func (e *IllTypedError) Error() string { return fmt.Sprintf("IllTypedError: errors in package: %v", e.Pkg.Errors) } -func BuildIssuesFromIllTypedError(errs []error, lintCtx *linter.Context) ([]result.Issue, error) { - var issues []result.Issue +func BuildIssuesFromIllTypedError(errs []error, lintCtx *linter.Context) ([]*result.Issue, error) { + var issues []*result.Issue uniqReportedIssues := map[string]bool{} var other error @@ -43,7 +43,7 @@ func BuildIssuesFromIllTypedError(errs []error, lintCtx *linter.Context) ([]resu lintCtx.Log.Errorf("typechecking error: %s", err.Msg) } else { issue.Pkg = ill.Pkg // to save to cache later - issues = append(issues, *issue) + issues = append(issues, issue) } } } diff --git a/pkg/goanalysis/runner.go b/pkg/goanalysis/runner.go index 808c9d2ad68c..6cc0a7077109 100644 --- a/pkg/goanalysis/runner.go +++ b/pkg/goanalysis/runner.go @@ -76,7 +76,7 @@ func newRunner(prefix string, logger logutils.Log, pkgCache *cache.Cache, loadGu // It provides most of the logic for the main functions of both the // singlechecker and the multi-analysis commands. // It returns the appropriate exit code. -func (r *runner) run(analyzers []*analysis.Analyzer, initialPackages []*packages.Package) ([]Diagnostic, +func (r *runner) run(analyzers []*analysis.Analyzer, initialPackages []*packages.Package) ([]*Diagnostic, []error, map[*analysis.Pass]*packages.Package, ) { debugf("Analyzing %d packages on load mode %s", len(initialPackages), r.loadMode) @@ -275,7 +275,7 @@ func (r *runner) analyze(pkgs []*packages.Package, analyzers []*analysis.Analyze return rootActions } -func extractDiagnostics(roots []*action) (retDiags []Diagnostic, retErrors []error) { +func extractDiagnostics(roots []*action) (retDiags []*Diagnostic, retErrors []error) { extracted := make(map[*action]bool) var extract func(*action) var visitAll func(actions []*action) @@ -322,7 +322,7 @@ func extractDiagnostics(roots []*action) (retDiags []Diagnostic, retErrors []err } seen[k] = true - retDiag := Diagnostic{ + retDiag := &Diagnostic{ File: file, Diagnostic: diag, Analyzer: act.Analyzer, diff --git a/pkg/goanalysis/runners.go b/pkg/goanalysis/runners.go index fe8d8fe854d3..bcbc0033ef9a 100644 --- a/pkg/goanalysis/runners.go +++ b/pkg/goanalysis/runners.go @@ -3,6 +3,7 @@ package goanalysis import ( "fmt" "go/token" + "slices" "strings" "golang.org/x/tools/go/analysis" @@ -20,11 +21,11 @@ type runAnalyzersConfig interface { getLinterNameForDiagnostic(*Diagnostic) string getAnalyzers() []*analysis.Analyzer useOriginalPackages() bool - reportIssues(*linter.Context) []Issue + reportIssues(*linter.Context) []*Issue getLoadMode() LoadMode } -func runAnalyzers(cfg runAnalyzersConfig, lintCtx *linter.Context) ([]result.Issue, error) { +func runAnalyzers(cfg runAnalyzersConfig, lintCtx *linter.Context) ([]*result.Issue, error) { log := lintCtx.Log.Child(logutils.DebugKeyGoAnalysis) sw := timeutils.NewStopwatch("analyzers", log) @@ -56,18 +57,19 @@ func runAnalyzers(cfg runAnalyzersConfig, lintCtx *linter.Context) ([]result.Iss } }() - buildAllIssues := func() []result.Issue { - var retIssues []result.Issue + buildAllIssues := func() []*result.Issue { + var retIssues []*result.Issue + reportedIssues := cfg.reportIssues(lintCtx) - for i := range reportedIssues { - issue := &reportedIssues[i].Issue - if issue.Pkg == nil { - issue.Pkg = passToPkg[reportedIssues[i].Pass] + for _, reportedIssue := range reportedIssues { + if reportedIssue.Pkg == nil { + reportedIssue.Pkg = passToPkg[reportedIssue.Pass] } - retIssues = append(retIssues, *issue) + + retIssues = append(retIssues, reportedIssue.Issue) } - retIssues = append(retIssues, buildIssues(diags, cfg.getLinterNameForDiagnostic)...) - return retIssues + + return slices.Concat(retIssues, buildIssues(diags, cfg.getLinterNameForDiagnostic)) } errIssues, err := pkgerrors.BuildIssuesFromIllTypedError(errs, lintCtx) @@ -81,11 +83,10 @@ func runAnalyzers(cfg runAnalyzersConfig, lintCtx *linter.Context) ([]result.Iss return issues, nil } -func buildIssues(diags []Diagnostic, linterNameBuilder func(diag *Diagnostic) string) []result.Issue { - var issues []result.Issue +func buildIssues(diags []*Diagnostic, linterNameBuilder func(diag *Diagnostic) string) []*result.Issue { + var issues []*result.Issue - for i := range diags { - diag := &diags[i] + for _, diag := range diags { linterName := linterNameBuilder(diag) var text string @@ -126,7 +127,7 @@ func buildIssues(diags []Diagnostic, linterNameBuilder func(diag *Diagnostic) st suggestedFixes = append(suggestedFixes, nsf) } - issues = append(issues, result.Issue{ + issues = append(issues, &result.Issue{ FromLinter: linterName, Text: text, Pos: diag.Position, @@ -142,7 +143,7 @@ func buildIssues(diags []Diagnostic, linterNameBuilder func(diag *Diagnostic) st relatedPos = diag.Position } - issues = append(issues, result.Issue{ + issues = append(issues, &result.Issue{ FromLinter: linterName, Text: fmt.Sprintf("%s(related information): %s", diag.Analyzer.Name, info.Message), Pos: relatedPos, diff --git a/pkg/goanalysis/runners_cache.go b/pkg/goanalysis/runners_cache.go index 9673197c9ec9..5cd8a6b1ccd4 100644 --- a/pkg/goanalysis/runners_cache.go +++ b/pkg/goanalysis/runners_cache.go @@ -17,13 +17,12 @@ import ( ) func saveIssuesToCache(allPkgs []*packages.Package, pkgsFromCache map[*packages.Package]bool, - issues []result.Issue, lintCtx *linter.Context, analyzers []*analysis.Analyzer, + issues []*result.Issue, lintCtx *linter.Context, analyzers []*analysis.Analyzer, ) { startedAt := time.Now() - perPkgIssues := map[*packages.Package][]result.Issue{} - for ind := range issues { - i := &issues[ind] - perPkgIssues[i.Pkg] = append(perPkgIssues[i.Pkg], *i) + perPkgIssues := map[*packages.Package][]*result.Issue{} + for _, issue := range issues { + perPkgIssues[issue.Pkg] = append(perPkgIssues[issue.Pkg], issue) } var savedIssuesCount int64 = 0 @@ -34,23 +33,22 @@ func saveIssuesToCache(allPkgs []*packages.Package, pkgsFromCache map[*packages. wg.Add(workerCount) pkgCh := make(chan *packages.Package, len(allPkgs)) - for i := 0; i < workerCount; i++ { + for range workerCount { go func() { defer wg.Done() for pkg := range pkgCh { pkgIssues := perPkgIssues[pkg] encodedIssues := make([]EncodingIssue, 0, len(pkgIssues)) - for ind := range pkgIssues { - i := &pkgIssues[ind] + for _, issue := range pkgIssues { encodedIssues = append(encodedIssues, EncodingIssue{ - FromLinter: i.FromLinter, - Text: i.Text, - Severity: i.Severity, - Pos: i.Pos, - LineRange: i.LineRange, - SuggestedFixes: i.SuggestedFixes, - ExpectNoLint: i.ExpectNoLint, - ExpectedNoLintLinter: i.ExpectedNoLintLinter, + FromLinter: issue.FromLinter, + Text: issue.Text, + Severity: issue.Severity, + Pos: issue.Pos, + LineRange: issue.LineRange, + SuggestedFixes: issue.SuggestedFixes, + ExpectNoLint: issue.ExpectNoLint, + ExpectedNoLintLinter: issue.ExpectedNoLintLinter, }) } @@ -81,12 +79,12 @@ func saveIssuesToCache(allPkgs []*packages.Package, pkgsFromCache map[*packages. func loadIssuesFromCache(pkgs []*packages.Package, lintCtx *linter.Context, analyzers []*analysis.Analyzer, -) (issuesFromCache []result.Issue, pkgsFromCache map[*packages.Package]bool) { +) (issuesFromCache []*result.Issue, pkgsFromCache map[*packages.Package]bool) { startedAt := time.Now() lintResKey := getIssuesCacheKey(analyzers) type cacheRes struct { - issues []result.Issue + issues []*result.Issue loadErr error } pkgToCacheRes := make(map[*packages.Package]*cacheRes, len(pkgs)) @@ -103,7 +101,7 @@ func loadIssuesFromCache(pkgs []*packages.Package, lintCtx *linter.Context, go func() { defer wg.Done() for pkg := range pkgCh { - var pkgIssues []EncodingIssue + var pkgIssues []*EncodingIssue err := lintCtx.PkgCache.Get(pkg, cache.HashModeNeedAllDeps, lintResKey, &pkgIssues) cacheRes := pkgToCacheRes[pkg] cacheRes.loadErr = err @@ -114,10 +112,9 @@ func loadIssuesFromCache(pkgs []*packages.Package, lintCtx *linter.Context, continue } - issues := make([]result.Issue, 0, len(pkgIssues)) - for i := range pkgIssues { - issue := &pkgIssues[i] - issues = append(issues, result.Issue{ + issues := make([]*result.Issue, 0, len(pkgIssues)) + for _, issue := range pkgIssues { + issues = append(issues, &result.Issue{ FromLinter: issue.FromLinter, Text: issue.Text, Severity: issue.Severity, diff --git a/pkg/golinters/dupl/dupl.go b/pkg/golinters/dupl/dupl.go index 6d5323a8bad4..0b6b3a162c2e 100644 --- a/pkg/golinters/dupl/dupl.go +++ b/pkg/golinters/dupl/dupl.go @@ -20,7 +20,7 @@ const linterName = "dupl" func New(settings *config.DuplSettings) *goanalysis.Linter { var mu sync.Mutex - var resIssues []goanalysis.Issue + var resIssues []*goanalysis.Issue return goanalysis. NewLinterFromAnalyzer(&analysis.Analyzer{ @@ -43,13 +43,13 @@ func New(settings *config.DuplSettings) *goanalysis.Linter { return nil, nil }, }). - WithIssuesReporter(func(*linter.Context) []goanalysis.Issue { + WithIssuesReporter(func(*linter.Context) []*goanalysis.Issue { return resIssues }). WithLoadMode(goanalysis.LoadModeSyntax) } -func runDupl(pass *analysis.Pass, settings *config.DuplSettings) ([]goanalysis.Issue, error) { +func runDupl(pass *analysis.Pass, settings *config.DuplSettings) ([]*goanalysis.Issue, error) { issues, err := duplAPI.Run(internal.GetGoFileNames(pass), settings.Threshold) if err != nil { return nil, err @@ -59,7 +59,7 @@ func runDupl(pass *analysis.Pass, settings *config.DuplSettings) ([]goanalysis.I return nil, nil } - res := make([]goanalysis.Issue, 0, len(issues)) + res := make([]*goanalysis.Issue, 0, len(issues)) for _, i := range issues { toFilename, err := fsutils.ShortestRelPath(i.To.Filename(), "") diff --git a/pkg/golinters/errcheck/errcheck.go b/pkg/golinters/errcheck/errcheck.go index ae34a53ef62c..6bd473845c3f 100644 --- a/pkg/golinters/errcheck/errcheck.go +++ b/pkg/golinters/errcheck/errcheck.go @@ -21,7 +21,7 @@ const linterName = "errcheck" func New(settings *config.ErrcheckSettings) *goanalysis.Linter { var mu sync.Mutex - var resIssues []goanalysis.Issue + var resIssues []*goanalysis.Issue analyzer := &analysis.Analyzer{ Name: linterName, @@ -50,13 +50,13 @@ func New(settings *config.ErrcheckSettings) *goanalysis.Linter { return nil, nil } }). - WithIssuesReporter(func(*linter.Context) []goanalysis.Issue { + WithIssuesReporter(func(*linter.Context) []*goanalysis.Issue { return resIssues }). WithLoadMode(goanalysis.LoadModeTypesInfo) } -func runErrCheck(pass *analysis.Pass, checker *errcheck.Checker, verbose bool) []goanalysis.Issue { +func runErrCheck(pass *analysis.Pass, checker *errcheck.Checker, verbose bool) []*goanalysis.Issue { pkg := &packages.Package{ Fset: pass.Fset, Syntax: pass.Files, @@ -69,7 +69,7 @@ func runErrCheck(pass *analysis.Pass, checker *errcheck.Checker, verbose bool) [ return nil } - issues := make([]goanalysis.Issue, len(lintIssues.UncheckedErrors)) + issues := make([]*goanalysis.Issue, len(lintIssues.UncheckedErrors)) for i, err := range lintIssues.UncheckedErrors { text := "Error return value is not checked" diff --git a/pkg/golinters/gochecksumtype/gochecksumtype.go b/pkg/golinters/gochecksumtype/gochecksumtype.go index 85be045dfa8a..825975f14570 100644 --- a/pkg/golinters/gochecksumtype/gochecksumtype.go +++ b/pkg/golinters/gochecksumtype/gochecksumtype.go @@ -18,7 +18,7 @@ const linterName = "gochecksumtype" func New(settings *config.GoChecksumTypeSettings) *goanalysis.Linter { var mu sync.Mutex - var resIssues []goanalysis.Issue + var resIssues []*goanalysis.Issue return goanalysis. NewLinterFromAnalyzer(&analysis.Analyzer{ @@ -41,14 +41,14 @@ func New(settings *config.GoChecksumTypeSettings) *goanalysis.Linter { return nil, nil }, }). - WithIssuesReporter(func(_ *linter.Context) []goanalysis.Issue { + WithIssuesReporter(func(_ *linter.Context) []*goanalysis.Issue { return resIssues }). WithLoadMode(goanalysis.LoadModeTypesInfo) } -func runGoCheckSumType(pass *analysis.Pass, settings *config.GoChecksumTypeSettings) ([]goanalysis.Issue, error) { - var resIssues []goanalysis.Issue +func runGoCheckSumType(pass *analysis.Pass, settings *config.GoChecksumTypeSettings) ([]*goanalysis.Issue, error) { + var resIssues []*goanalysis.Issue pkg := &packages.Package{ Fset: pass.Fset, diff --git a/pkg/golinters/gocognit/gocognit.go b/pkg/golinters/gocognit/gocognit.go index e72a9bdfe67a..b17912c0a649 100644 --- a/pkg/golinters/gocognit/gocognit.go +++ b/pkg/golinters/gocognit/gocognit.go @@ -19,7 +19,7 @@ const linterName = "gocognit" func New(settings *config.GocognitSettings) *goanalysis.Linter { var mu sync.Mutex - var resIssues []goanalysis.Issue + var resIssues []*goanalysis.Issue return goanalysis. NewLinterFromAnalyzer(&analysis.Analyzer{ @@ -39,13 +39,13 @@ func New(settings *config.GocognitSettings) *goanalysis.Linter { return nil, nil }, }). - WithIssuesReporter(func(*linter.Context) []goanalysis.Issue { + WithIssuesReporter(func(*linter.Context) []*goanalysis.Issue { return resIssues }). WithLoadMode(goanalysis.LoadModeSyntax) } -func runGocognit(pass *analysis.Pass, settings *config.GocognitSettings) []goanalysis.Issue { +func runGocognit(pass *analysis.Pass, settings *config.GocognitSettings) []*goanalysis.Issue { var stats []gocognit.Stat for _, f := range pass.Files { stats = gocognit.ComplexityStats(f, pass.Fset, stats) @@ -58,7 +58,7 @@ func runGocognit(pass *analysis.Pass, settings *config.GocognitSettings) []goana return stats[i].Complexity > stats[j].Complexity }) - issues := make([]goanalysis.Issue, 0, len(stats)) + issues := make([]*goanalysis.Issue, 0, len(stats)) for _, s := range stats { if s.Complexity <= settings.MinComplexity { break // Break as the stats is already sorted from greatest to least diff --git a/pkg/golinters/goconst/goconst.go b/pkg/golinters/goconst/goconst.go index 5a44d4a5ce3a..b58d860c6eda 100644 --- a/pkg/golinters/goconst/goconst.go +++ b/pkg/golinters/goconst/goconst.go @@ -18,7 +18,7 @@ const linterName = "goconst" func New(settings *config.GoConstSettings) *goanalysis.Linter { var mu sync.Mutex - var resIssues []goanalysis.Issue + var resIssues []*goanalysis.Issue return goanalysis. NewLinterFromAnalyzer(&analysis.Analyzer{ @@ -41,13 +41,13 @@ func New(settings *config.GoConstSettings) *goanalysis.Linter { return nil, nil }, }). - WithIssuesReporter(func(*linter.Context) []goanalysis.Issue { + WithIssuesReporter(func(*linter.Context) []*goanalysis.Issue { return resIssues }). WithLoadMode(goanalysis.LoadModeTypesInfo) } -func runGoconst(pass *analysis.Pass, settings *config.GoConstSettings) ([]goanalysis.Issue, error) { +func runGoconst(pass *analysis.Pass, settings *config.GoConstSettings) ([]*goanalysis.Issue, error) { cfg := goconstAPI.Config{ IgnoreStrings: settings.IgnoreStringValues, MatchWithConstants: settings.MatchWithConstants, @@ -77,7 +77,7 @@ func runGoconst(pass *analysis.Pass, settings *config.GoConstSettings) ([]goanal return nil, nil } - res := make([]goanalysis.Issue, 0, len(lintIssues)) + res := make([]*goanalysis.Issue, 0, len(lintIssues)) for i := range lintIssues { issue := &lintIssues[i] diff --git a/pkg/golinters/gocyclo/gocyclo.go b/pkg/golinters/gocyclo/gocyclo.go index 17b868d4972a..de0374607c06 100644 --- a/pkg/golinters/gocyclo/gocyclo.go +++ b/pkg/golinters/gocyclo/gocyclo.go @@ -18,7 +18,7 @@ const linterName = "gocyclo" func New(settings *config.GoCycloSettings) *goanalysis.Linter { var mu sync.Mutex - var resIssues []goanalysis.Issue + var resIssues []*goanalysis.Issue return goanalysis. NewLinterFromAnalyzer(&analysis.Analyzer{ @@ -38,13 +38,13 @@ func New(settings *config.GoCycloSettings) *goanalysis.Linter { return nil, nil }, }). - WithIssuesReporter(func(*linter.Context) []goanalysis.Issue { + WithIssuesReporter(func(*linter.Context) []*goanalysis.Issue { return resIssues }). WithLoadMode(goanalysis.LoadModeSyntax) } -func runGoCyclo(pass *analysis.Pass, settings *config.GoCycloSettings) []goanalysis.Issue { +func runGoCyclo(pass *analysis.Pass, settings *config.GoCycloSettings) []*goanalysis.Issue { var stats gocyclo.Stats for _, f := range pass.Files { stats = gocyclo.AnalyzeASTFile(f, pass.Fset, stats) @@ -55,7 +55,7 @@ func runGoCyclo(pass *analysis.Pass, settings *config.GoCycloSettings) []goanaly stats = stats.SortAndFilter(-1, settings.MinComplexity) - issues := make([]goanalysis.Issue, 0, len(stats)) + issues := make([]*goanalysis.Issue, 0, len(stats)) for _, s := range stats { text := fmt.Sprintf("cyclomatic complexity %d of func %s is high (> %d)", diff --git a/pkg/golinters/gomoddirectives/gomoddirectives.go b/pkg/golinters/gomoddirectives/gomoddirectives.go index e11313a62b9c..dd6656fb6cb6 100644 --- a/pkg/golinters/gomoddirectives/gomoddirectives.go +++ b/pkg/golinters/gomoddirectives/gomoddirectives.go @@ -17,7 +17,7 @@ import ( const linterName = "gomoddirectives" func New(settings *config.GoModDirectivesSettings) *goanalysis.Linter { - var issues []goanalysis.Issue + var issues []*goanalysis.Issue var once sync.Once var opts gomoddirectives.Options @@ -79,7 +79,7 @@ func New(settings *config.GoModDirectivesSettings) *goanalysis.Linter { return nil, nil } }). - WithIssuesReporter(func(*linter.Context) []goanalysis.Issue { + WithIssuesReporter(func(*linter.Context) []*goanalysis.Issue { return issues }). WithLoadMode(goanalysis.LoadModeSyntax) diff --git a/pkg/golinters/gomodguard/gomodguard.go b/pkg/golinters/gomodguard/gomodguard.go index 502610341342..7d16f57b3a5c 100644 --- a/pkg/golinters/gomodguard/gomodguard.go +++ b/pkg/golinters/gomodguard/gomodguard.go @@ -16,7 +16,7 @@ import ( const linterName = "gomodguard" func New(settings *config.GoModGuardSettings) *goanalysis.Linter { - var issues []goanalysis.Issue + var issues []*goanalysis.Issue var mu sync.Mutex processorCfg := &gomodguard.Configuration{} @@ -82,7 +82,7 @@ func New(settings *config.GoModGuardSettings) *goanalysis.Linter { return nil, nil } }). - WithIssuesReporter(func(*linter.Context) []goanalysis.Issue { + WithIssuesReporter(func(*linter.Context) []*goanalysis.Issue { return issues }). WithLoadMode(goanalysis.LoadModeSyntax) diff --git a/pkg/golinters/gosec/gosec.go b/pkg/golinters/gosec/gosec.go index e38de1ee20e5..66d229295a3f 100644 --- a/pkg/golinters/gosec/gosec.go +++ b/pkg/golinters/gosec/gosec.go @@ -26,7 +26,7 @@ const linterName = "gosec" func New(settings *config.GoSecSettings) *goanalysis.Linter { var mu sync.Mutex - var resIssues []goanalysis.Issue + var resIssues []*goanalysis.Issue conf := gosec.NewConfig() @@ -73,13 +73,13 @@ func New(settings *config.GoSecSettings) *goanalysis.Linter { return nil, nil } }). - WithIssuesReporter(func(*linter.Context) []goanalysis.Issue { + WithIssuesReporter(func(*linter.Context) []*goanalysis.Issue { return resIssues }). WithLoadMode(goanalysis.LoadModeTypesInfo) } -func runGoSec(lintCtx *linter.Context, pass *analysis.Pass, settings *config.GoSecSettings, analyzer *gosec.Analyzer) []goanalysis.Issue { +func runGoSec(lintCtx *linter.Context, pass *analysis.Pass, settings *config.GoSecSettings, analyzer *gosec.Analyzer) []*goanalysis.Issue { pkg := &packages.Package{ Fset: pass.Fset, Syntax: pass.Files, @@ -107,7 +107,7 @@ func runGoSec(lintCtx *linter.Context, pass *analysis.Pass, settings *config.GoS secIssues = filterIssues(secIssues, severity, confidence) - issues := make([]goanalysis.Issue, 0, len(secIssues)) + issues := make([]*goanalysis.Issue, 0, len(secIssues)) for _, i := range secIssues { text := fmt.Sprintf("%s: %s", i.RuleID, i.What) diff --git a/pkg/golinters/nolintlint/internal/nolintlint.go b/pkg/golinters/nolintlint/internal/nolintlint.go index 2be7c5c144ea..a20161405f1c 100644 --- a/pkg/golinters/nolintlint/internal/nolintlint.go +++ b/pkg/golinters/nolintlint/internal/nolintlint.go @@ -55,8 +55,8 @@ var ( ) //nolint:funlen,gocyclo // the function is going to be refactored in the future -func (l Linter) Run(pass *analysis.Pass) ([]goanalysis.Issue, error) { - var issues []goanalysis.Issue +func (l Linter) Run(pass *analysis.Pass) ([]*goanalysis.Issue, error) { + var issues []*goanalysis.Issue for _, file := range pass.Files { for _, c := range file.Comments { diff --git a/pkg/golinters/nolintlint/internal/nolintlint_test.go b/pkg/golinters/nolintlint/internal/nolintlint_test.go index 788d6b5a84dd..b534fbf89511 100644 --- a/pkg/golinters/nolintlint/internal/nolintlint_test.go +++ b/pkg/golinters/nolintlint/internal/nolintlint_test.go @@ -19,7 +19,7 @@ func TestLinter_Run(t *testing.T) { needs Needs excludes []string contents string - expected []result.Issue + expected []*result.Issue }{ { desc: "when no explanation is provided", @@ -36,7 +36,7 @@ func foo() { other() //nolintother } `, - expected: []result.Issue{ + expected: []*result.Issue{ { FromLinter: "nolintlint", Text: "directive `//nolint` should provide explanation such as `//nolint // this is why`", @@ -69,7 +69,7 @@ func foo() { //nolint:dupl func foo() {} `, - expected: []result.Issue{{ + expected: []*result.Issue{{ FromLinter: "nolintlint", Text: "directive `//nolint:dupl` should provide explanation such as `//nolint:dupl // this is why`", Pos: token.Position{Filename: "testing.go", Offset: 47, Line: 5, Column: 1}, @@ -97,7 +97,7 @@ func foo() { bad() //nolint // because } `, - expected: []result.Issue{ + expected: []*result.Issue{ { FromLinter: "nolintlint", Text: "directive `//nolint` should mention specific linter such as `//nolint:my-linter`", @@ -120,7 +120,7 @@ func foo() { good() //nolint } `, - expected: []result.Issue{ + expected: []*result.Issue{ { FromLinter: "nolintlint", Text: "directive `// nolint` should be written without leading space as `//nolint`", @@ -158,7 +158,7 @@ func foo() { good() //nolint: linter1, linter2 } `, - expected: []result.Issue{{ + expected: []*result.Issue{{ FromLinter: "nolintlint", Text: "directive `//nolint:linter1 linter2` should match `//nolint[:] [// ]`", Pos: token.Position{Filename: "testing.go", Offset: 71, Line: 5, Column: 9}, @@ -183,7 +183,7 @@ func foo() { bad() //nolint } `, - expected: []result.Issue{{ + expected: []*result.Issue{{ FromLinter: "nolintlint", Text: "directive `//nolint` is unused", Pos: token.Position{Filename: "testing.go", Offset: 34, Line: 4, Column: 9}, @@ -205,7 +205,7 @@ func foo() { bad() //nolint:somelinter } `, - expected: []result.Issue{{ + expected: []*result.Issue{{ FromLinter: "nolintlint", Text: "directive `//nolint:somelinter` is unused for linter \"somelinter\"", Pos: token.Position{Filename: "testing.go", Offset: 34, Line: 4, Column: 9}, @@ -229,7 +229,7 @@ func foo() { bad() } `, - expected: []result.Issue{{ + expected: []*result.Issue{{ FromLinter: "nolintlint", Text: "directive `//nolint:somelinter` is unused for linter \"somelinter\"", Pos: token.Position{Filename: "testing.go", Offset: 13, Line: 3, Column: 1}, @@ -252,7 +252,7 @@ func foo() { bad() //nolint:linter1,linter2 } `, - expected: []result.Issue{ + expected: []*result.Issue{ { FromLinter: "nolintlint", Text: "directive `//nolint:linter1,linter2` is unused for linter \"linter1\"", @@ -289,7 +289,7 @@ func foo() { analysisIssues, err := linter.Run(pass) require.NoError(t, err) - var issues []result.Issue + var issues []*result.Issue for _, i := range analysisIssues { issues = append(issues, i.Issue) } diff --git a/pkg/golinters/nolintlint/nolintlint.go b/pkg/golinters/nolintlint/nolintlint.go index 37f9cb96aac7..6f3d373063f8 100644 --- a/pkg/golinters/nolintlint/nolintlint.go +++ b/pkg/golinters/nolintlint/nolintlint.go @@ -17,7 +17,7 @@ const LinterName = nolintlint.LinterName func New(settings *config.NoLintLintSettings) *goanalysis.Linter { var mu sync.Mutex - var resIssues []goanalysis.Issue + var resIssues []*goanalysis.Issue var needs nolintlint.Needs if settings.RequireExplanation { @@ -56,7 +56,7 @@ func New(settings *config.NoLintLintSettings) *goanalysis.Linter { return nil, nil }, }). - WithIssuesReporter(func(*linter.Context) []goanalysis.Issue { + WithIssuesReporter(func(*linter.Context) []*goanalysis.Issue { return resIssues }). WithLoadMode(goanalysis.LoadModeSyntax) diff --git a/pkg/golinters/promlinter/promlinter.go b/pkg/golinters/promlinter/promlinter.go index 2cb59cbe6f1a..491409f4ef7a 100644 --- a/pkg/golinters/promlinter/promlinter.go +++ b/pkg/golinters/promlinter/promlinter.go @@ -17,7 +17,7 @@ const linterName = "promlinter" func New(settings *config.PromlinterSettings) *goanalysis.Linter { var mu sync.Mutex - var resIssues []goanalysis.Issue + var resIssues []*goanalysis.Issue var promSettings promlinter.Setting if settings != nil { @@ -45,20 +45,20 @@ func New(settings *config.PromlinterSettings) *goanalysis.Linter { return nil, nil }, }). - WithIssuesReporter(func(*linter.Context) []goanalysis.Issue { + WithIssuesReporter(func(*linter.Context) []*goanalysis.Issue { return resIssues }). WithLoadMode(goanalysis.LoadModeSyntax) } -func runPromLinter(pass *analysis.Pass, promSettings promlinter.Setting) []goanalysis.Issue { +func runPromLinter(pass *analysis.Pass, promSettings promlinter.Setting) []*goanalysis.Issue { lintIssues := promlinter.RunLint(pass.Fset, pass.Files, promSettings) if len(lintIssues) == 0 { return nil } - issues := make([]goanalysis.Issue, len(lintIssues)) + issues := make([]*goanalysis.Issue, len(lintIssues)) for k, i := range lintIssues { issue := result.Issue{ Pos: i.Pos, diff --git a/pkg/golinters/revive/revive.go b/pkg/golinters/revive/revive.go index b06b5de8aa28..3e13c516fa12 100644 --- a/pkg/golinters/revive/revive.go +++ b/pkg/golinters/revive/revive.go @@ -35,7 +35,7 @@ var ( func New(settings *config.ReviveSettings) *goanalysis.Linter { var mu sync.Mutex - var resIssues []goanalysis.Issue + var resIssues []*goanalysis.Issue analyzer := &analysis.Analyzer{ Name: linterName, @@ -69,7 +69,7 @@ func New(settings *config.ReviveSettings) *goanalysis.Linter { return nil, nil } }). - WithIssuesReporter(func(*linter.Context) []goanalysis.Issue { + WithIssuesReporter(func(*linter.Context) []*goanalysis.Issue { return resIssues }). WithLoadMode(goanalysis.LoadModeSyntax) @@ -106,7 +106,7 @@ func newWrapper(settings *config.ReviveSettings) (*wrapper, error) { }, nil } -func (w *wrapper) run(pass *analysis.Pass) ([]goanalysis.Issue, error) { +func (w *wrapper) run(pass *analysis.Pass) ([]*goanalysis.Issue, error) { packages := [][]string{internal.GetGoFileNames(pass)} failures, err := w.revive.Lint(packages, w.lintingRules, *w.conf) @@ -114,7 +114,7 @@ func (w *wrapper) run(pass *analysis.Pass) ([]goanalysis.Issue, error) { return nil, err } - var issues []goanalysis.Issue + var issues []*goanalysis.Issue for failure := range failures { if failure.Confidence < w.conf.Confidence { continue @@ -126,7 +126,7 @@ func (w *wrapper) run(pass *analysis.Pass) ([]goanalysis.Issue, error) { return issues, nil } -func (w *wrapper) toIssue(pass *analysis.Pass, failure *lint.Failure) goanalysis.Issue { +func (w *wrapper) toIssue(pass *analysis.Pass, failure *lint.Failure) *goanalysis.Issue { lineRangeTo := failure.Position.End.Line if failure.RuleName == (&rule.ExportedRule{}).Name() { lineRangeTo = failure.Position.Start.Line diff --git a/pkg/golinters/unconvert/unconvert.go b/pkg/golinters/unconvert/unconvert.go index c9b3f75dd169..593dfbe96e63 100644 --- a/pkg/golinters/unconvert/unconvert.go +++ b/pkg/golinters/unconvert/unconvert.go @@ -16,7 +16,7 @@ const linterName = "unconvert" func New(settings *config.UnconvertSettings) *goanalysis.Linter { var mu sync.Mutex - var resIssues []goanalysis.Issue + var resIssues []*goanalysis.Issue unconvert.SetFastMath(settings.FastMath) unconvert.SetSafe(settings.Safe) @@ -39,16 +39,16 @@ func New(settings *config.UnconvertSettings) *goanalysis.Linter { return nil, nil }, }). - WithIssuesReporter(func(*linter.Context) []goanalysis.Issue { + WithIssuesReporter(func(*linter.Context) []*goanalysis.Issue { return resIssues }). WithLoadMode(goanalysis.LoadModeTypesInfo) } -func runUnconvert(pass *analysis.Pass) []goanalysis.Issue { +func runUnconvert(pass *analysis.Pass) []*goanalysis.Issue { positions := unconvert.Run(pass) - var issues []goanalysis.Issue + var issues []*goanalysis.Issue for _, position := range positions { issues = append(issues, goanalysis.NewIssue(&result.Issue{ Pos: position, diff --git a/pkg/golinters/unused/unused.go b/pkg/golinters/unused/unused.go index 375962259676..c0f4657dcc26 100644 --- a/pkg/golinters/unused/unused.go +++ b/pkg/golinters/unused/unused.go @@ -20,7 +20,7 @@ const linterName = "unused" func New(settings *config.UnusedSettings) *goanalysis.Linter { var mu sync.Mutex - var resIssues []goanalysis.Issue + var resIssues []*goanalysis.Issue analyzer := &analysis.Analyzer{ Name: linterName, @@ -45,12 +45,12 @@ func New(settings *config.UnusedSettings) *goanalysis.Linter { "Checks Go code for unused constants, variables, functions and types", []*analysis.Analyzer{analyzer}, nil, - ).WithIssuesReporter(func(_ *linter.Context) []goanalysis.Issue { + ).WithIssuesReporter(func(_ *linter.Context) []*goanalysis.Issue { return resIssues }).WithLoadMode(goanalysis.LoadModeTypesInfo) } -func runUnused(pass *analysis.Pass, cfg *config.UnusedSettings) []goanalysis.Issue { +func runUnused(pass *analysis.Pass, cfg *config.UnusedSettings) []*goanalysis.Issue { res := getUnusedResults(pass, cfg) used := make(map[string]bool) @@ -58,7 +58,7 @@ func runUnused(pass *analysis.Pass, cfg *config.UnusedSettings) []goanalysis.Iss used[fmt.Sprintf("%s %d %s", obj.Position.Filename, obj.Position.Line, obj.Name)] = true } - var issues []goanalysis.Issue + var issues []*goanalysis.Issue // Inspired by https://github.com/dominikh/go-tools/blob/d694aadcb1f50c2d8ac0a1dd06217ebb9f654764/lintcmd/lint.go#L177-L197 for _, object := range res.Unused { diff --git a/pkg/lint/linter/linter.go b/pkg/lint/linter/linter.go index 7f68545cf159..e6b484efbb05 100644 --- a/pkg/lint/linter/linter.go +++ b/pkg/lint/linter/linter.go @@ -8,7 +8,7 @@ import ( ) type Linter interface { - Run(ctx context.Context, lintCtx *Context) ([]result.Issue, error) + Run(ctx context.Context, lintCtx *Context) ([]*result.Issue, error) Name() string Desc() string } @@ -43,7 +43,7 @@ func NewNoopDeprecated(name string, cfg *config.Config, level DeprecationLevel) return noop } -func (n Noop) Run(_ context.Context, lintCtx *Context) ([]result.Issue, error) { +func (n Noop) Run(_ context.Context, lintCtx *Context) ([]*result.Issue, error) { if n.reason == "" { return nil, nil } diff --git a/pkg/lint/runner.go b/pkg/lint/runner.go index 5ede9b24dae5..5cc46feb101d 100644 --- a/pkg/lint/runner.go +++ b/pkg/lint/runner.go @@ -118,17 +118,17 @@ func NewRunner(log logutils.Log, cfg *config.Config, goenv *goutil.Env, }, nil } -func (r *Runner) Run(ctx context.Context, linters []*linter.Config) ([]result.Issue, error) { +func (r *Runner) Run(ctx context.Context, linters []*linter.Config) ([]*result.Issue, error) { sw := timeutils.NewStopwatch("linters", r.Log) defer sw.Print() var ( lintErrors error - issues []result.Issue + issues []*result.Issue ) for _, lc := range linters { - linterIssues, err := timeutils.TrackStage(sw, lc.Name(), func() ([]result.Issue, error) { + linterIssues, err := timeutils.TrackStage(sw, lc.Name(), func() ([]*result.Issue, error) { return r.runLinterSafe(ctx, r.lintCtx, lc) }) if err != nil { @@ -146,7 +146,7 @@ func (r *Runner) Run(ctx context.Context, linters []*linter.Config) ([]result.Is func (r *Runner) runLinterSafe(ctx context.Context, lintCtx *linter.Context, lc *linter.Config, -) (ret []result.Issue, err error) { +) (ret []*result.Issue, err error) { defer func() { if panicData := recover(); panicData != nil { if pe, ok := panicData.(*errorutil.PanicError); ok { @@ -185,13 +185,13 @@ func (r *Runner) runLinterSafe(ctx context.Context, lintCtx *linter.Context, return issues, nil } -func (r *Runner) processLintResults(inIssues []result.Issue) []result.Issue { +func (r *Runner) processLintResults(inIssues []*result.Issue) []*result.Issue { sw := timeutils.NewStopwatch("processing", r.Log) var issuesBefore, issuesAfter int statPerProcessor := map[string]processorStat{} - var outIssues []result.Issue + var outIssues []*result.Issue if len(inIssues) != 0 { issuesBefore += len(inIssues) outIssues = r.processIssues(inIssues, sw, statPerProcessor) @@ -225,9 +225,9 @@ func (r *Runner) printPerProcessorStat(stat map[string]processorStat) { } } -func (r *Runner) processIssues(issues []result.Issue, sw *timeutils.Stopwatch, statPerProcessor map[string]processorStat) []result.Issue { +func (r *Runner) processIssues(issues []*result.Issue, sw *timeutils.Stopwatch, statPerProcessor map[string]processorStat) []*result.Issue { for _, p := range r.Processors { - newIssues, err := timeutils.TrackStage(sw, p.Name(), func() ([]result.Issue, error) { + newIssues, err := timeutils.TrackStage(sw, p.Name(), func() ([]*result.Issue, error) { return p.Process(issues) }) @@ -243,7 +243,7 @@ func (r *Runner) processIssues(issues []result.Issue, sw *timeutils.Stopwatch, s // This is required by JSON serialization if issues == nil { - issues = []result.Issue{} + issues = []*result.Issue{} } } diff --git a/pkg/printers/checkstyle.go b/pkg/printers/checkstyle.go index 5a60554bdb62..c3869bd39d9d 100644 --- a/pkg/printers/checkstyle.go +++ b/pkg/printers/checkstyle.go @@ -37,15 +37,14 @@ func NewCheckstyle(log logutils.Log, w io.Writer) *Checkstyle { } } -func (p *Checkstyle) Print(issues []result.Issue) error { +func (p *Checkstyle) Print(issues []*result.Issue) error { out := checkstyleOutput{ Version: "5.0", } files := map[string]*checkstyleFile{} - for i := range issues { - issue := &issues[i] + for _, issue := range issues { file, ok := files[issue.FilePath()] if !ok { file = &checkstyleFile{ diff --git a/pkg/printers/checkstyle_test.go b/pkg/printers/checkstyle_test.go index f087a79b83b0..5c8781e388fb 100644 --- a/pkg/printers/checkstyle_test.go +++ b/pkg/printers/checkstyle_test.go @@ -14,7 +14,7 @@ import ( ) func TestCheckstyle_Print(t *testing.T) { - issues := []result.Issue{ + issues := []*result.Issue{ { FromLinter: "linter-a", Severity: "warning", diff --git a/pkg/printers/codeclimate.go b/pkg/printers/codeclimate.go index 872d860d3ba4..e2eded608fb9 100644 --- a/pkg/printers/codeclimate.go +++ b/pkg/printers/codeclimate.go @@ -30,12 +30,10 @@ func NewCodeClimate(log logutils.Log, w io.Writer) *CodeClimate { } } -func (p *CodeClimate) Print(issues []result.Issue) error { +func (p *CodeClimate) Print(issues []*result.Issue) error { ccIssues := make([]codeClimateIssue, 0, len(issues)) - for i := range issues { - issue := issues[i] - + for _, issue := range issues { ccIssue := codeClimateIssue{ Description: issue.Description(), CheckName: issue.FromLinter, diff --git a/pkg/printers/codeclimate_test.go b/pkg/printers/codeclimate_test.go index 28fd281c4548..159dd86e37ae 100644 --- a/pkg/printers/codeclimate_test.go +++ b/pkg/printers/codeclimate_test.go @@ -13,7 +13,7 @@ import ( ) func TestCodeClimate_Print(t *testing.T) { - issues := []result.Issue{ + issues := []*result.Issue{ { FromLinter: "linter-a", Severity: "minor", diff --git a/pkg/printers/html.go b/pkg/printers/html.go index 0f99bb7ff8ce..1f6ed18344b0 100644 --- a/pkg/printers/html.go +++ b/pkg/printers/html.go @@ -132,20 +132,20 @@ func NewHTML(w io.Writer) *HTML { return &HTML{w: w} } -func (p HTML) Print(issues []result.Issue) error { +func (p HTML) Print(issues []*result.Issue) error { var htmlIssues []htmlIssue - for i := range issues { - pos := fmt.Sprintf("%s:%d", issues[i].FilePath(), issues[i].Line()) - if issues[i].Pos.Column != 0 { - pos += fmt.Sprintf(":%d", issues[i].Pos.Column) + for _, issue := range issues { + pos := fmt.Sprintf("%s:%d", issue.FilePath(), issue.Line()) + if issue.Pos.Column != 0 { + pos += fmt.Sprintf(":%d", issue.Pos.Column) } htmlIssues = append(htmlIssues, htmlIssue{ - Title: strings.TrimSpace(issues[i].Text), + Title: strings.TrimSpace(issue.Text), Pos: pos, - Linter: issues[i].FromLinter, - Code: strings.Join(issues[i].SourceLines, "\n"), + Linter: issue.FromLinter, + Code: strings.Join(issue.SourceLines, "\n"), }) } diff --git a/pkg/printers/html_test.go b/pkg/printers/html_test.go index 3964d81ddeaf..17db307509c2 100644 --- a/pkg/printers/html_test.go +++ b/pkg/printers/html_test.go @@ -118,7 +118,7 @@ const expectedHTML = ` ` func TestHTML_Print(t *testing.T) { - issues := []result.Issue{ + issues := []*result.Issue{ { FromLinter: "linter-a", Severity: "warning", diff --git a/pkg/printers/json.go b/pkg/printers/json.go index 64fd33c7bae5..97354081c903 100644 --- a/pkg/printers/json.go +++ b/pkg/printers/json.go @@ -22,17 +22,17 @@ func NewJSON(w io.Writer, rd *report.Data) *JSON { } type JSONResult struct { - Issues []result.Issue + Issues []*result.Issue Report *report.Data } -func (p JSON) Print(issues []result.Issue) error { +func (p JSON) Print(issues []*result.Issue) error { res := JSONResult{ Issues: issues, Report: p.rd, } if res.Issues == nil { - res.Issues = []result.Issue{} + res.Issues = []*result.Issue{} } return json.NewEncoder(p.w).Encode(res) diff --git a/pkg/printers/json_test.go b/pkg/printers/json_test.go index 001c283ee611..50c67f995fe1 100644 --- a/pkg/printers/json_test.go +++ b/pkg/printers/json_test.go @@ -12,7 +12,7 @@ import ( ) func TestJSON_Print(t *testing.T) { - issues := []result.Issue{ + issues := []*result.Issue{ { FromLinter: "linter-a", Severity: "warning", diff --git a/pkg/printers/junitxml.go b/pkg/printers/junitxml.go index 708f83e5a860..b040e746703c 100644 --- a/pkg/printers/junitxml.go +++ b/pkg/printers/junitxml.go @@ -27,31 +27,30 @@ func NewJUnitXML(w io.Writer, extended bool) *JUnitXML { } } -func (p JUnitXML) Print(issues []result.Issue) error { +func (p JUnitXML) Print(issues []*result.Issue) error { suites := make(map[string]testSuiteXML) // use a map to group by file - for ind := range issues { - i := &issues[ind] - suiteName := i.FilePath() + for _, issue := range issues { + suiteName := issue.FilePath() testSuite := suites[suiteName] - testSuite.Suite = i.FilePath() + testSuite.Suite = issue.FilePath() testSuite.Tests++ testSuite.Failures++ tc := testCaseXML{ - Name: i.FromLinter, - ClassName: i.Pos.String(), + Name: issue.FromLinter, + ClassName: issue.Pos.String(), Failure: failureXML{ - Type: i.Severity, - Message: i.Pos.String() + ": " + i.Text, + Type: issue.Severity, + Message: issue.Pos.String() + ": " + issue.Text, Content: fmt.Sprintf("%s: %s\nCategory: %s\nFile: %s\nLine: %d\nDetails: %s", - i.Severity, i.Text, i.FromLinter, i.Pos.Filename, i.Pos.Line, strings.Join(i.SourceLines, "\n")), + issue.Severity, issue.Text, issue.FromLinter, issue.Pos.Filename, issue.Pos.Line, strings.Join(issue.SourceLines, "\n")), }, } if p.extended { - tc.File = i.Pos.Filename - tc.Line = i.Pos.Line + tc.File = issue.Pos.Filename + tc.Line = issue.Pos.Line } testSuite.TestCases = append(testSuite.TestCases, tc) diff --git a/pkg/printers/junitxml_test.go b/pkg/printers/junitxml_test.go index 7a429e546f46..90a365e79870 100644 --- a/pkg/printers/junitxml_test.go +++ b/pkg/printers/junitxml_test.go @@ -12,7 +12,7 @@ import ( ) func TestJUnitXML_Print(t *testing.T) { - issues := []result.Issue{ + issues := []*result.Issue{ { FromLinter: "linter-a", Severity: "warning", diff --git a/pkg/printers/printer.go b/pkg/printers/printer.go index 575bba75f1d5..bb3eab6205e8 100644 --- a/pkg/printers/printer.go +++ b/pkg/printers/printer.go @@ -23,7 +23,7 @@ const ( const defaultFileMode = 0o644 type issuePrinter interface { - Print(issues []result.Issue) error + Print(issues []*result.Issue) error } // Printer prints issues. @@ -63,7 +63,7 @@ func NewPrinter(log logutils.Log, cfg *config.Formats, reportData *report.Data, // Print prints issues based on the formats defined. // //nolint:gocyclo,funlen // the complexity is related to the number of formats. -func (c *Printer) Print(issues []result.Issue) error { +func (c *Printer) Print(issues []*result.Issue) error { if c.cfg.IsEmpty() { c.cfg.Text.Path = outputStdOut } diff --git a/pkg/printers/printer_test.go b/pkg/printers/printer_test.go index 850ee94a097b..6b3737f16688 100644 --- a/pkg/printers/printer_test.go +++ b/pkg/printers/printer_test.go @@ -29,7 +29,7 @@ func unmarshalFile(t *testing.T, filename string, v any) { func TestPrinter_Print_stdout(t *testing.T) { logger := logutils.NewStderrLog("skip") - var issues []result.Issue + var issues []*result.Issue unmarshalFile(t, "in-issues.json", &issues) data := &report.Data{} @@ -86,7 +86,7 @@ func TestPrinter_Print_stdout(t *testing.T) { func TestPrinter_Print_stderr(t *testing.T) { logger := logutils.NewStderrLog("skip") - var issues []result.Issue + var issues []*result.Issue unmarshalFile(t, "in-issues.json", &issues) data := &report.Data{} @@ -122,7 +122,7 @@ func TestPrinter_Print_stderr(t *testing.T) { func TestPrinter_Print_file(t *testing.T) { logger := logutils.NewStderrLog("skip") - var issues []result.Issue + var issues []*result.Issue unmarshalFile(t, "in-issues.json", &issues) data := &report.Data{} @@ -165,7 +165,7 @@ func TestPrinter_Print_file(t *testing.T) { func TestPrinter_Print_multiple(t *testing.T) { logger := logutils.NewStderrLog("skip") - var issues []result.Issue + var issues []*result.Issue unmarshalFile(t, "in-issues.json", &issues) data := &report.Data{} diff --git a/pkg/printers/sarif.go b/pkg/printers/sarif.go index e8d8c64f7da3..e1caf179a821 100644 --- a/pkg/printers/sarif.go +++ b/pkg/printers/sarif.go @@ -36,14 +36,12 @@ func NewSarif(log logutils.Log, w io.Writer) *Sarif { } } -func (p *Sarif) Print(issues []result.Issue) error { +func (p *Sarif) Print(issues []*result.Issue) error { run := sarifRun{} run.Tool.Driver.Name = "golangci-lint" run.Results = make([]sarifResult, 0) - for i := range issues { - issue := issues[i] - + for _, issue := range issues { sr := sarifResult{ RuleID: issue.FromLinter, Level: p.sanitizer.Sanitize(issue.Severity), diff --git a/pkg/printers/sarif_test.go b/pkg/printers/sarif_test.go index f6ddf4d81f07..400bb25bed37 100644 --- a/pkg/printers/sarif_test.go +++ b/pkg/printers/sarif_test.go @@ -13,7 +13,7 @@ import ( ) func TestSarif_Print(t *testing.T) { - issues := []result.Issue{ + issues := []*result.Issue{ { FromLinter: "linter-a", Severity: "warning", diff --git a/pkg/printers/tab.go b/pkg/printers/tab.go index 0d14593e5950..8edbb05e11fe 100644 --- a/pkg/printers/tab.go +++ b/pkg/printers/tab.go @@ -40,11 +40,11 @@ func (p *Tab) SprintfColored(ca color.Attribute, format string, args ...any) str return c.Sprintf(format, args...) } -func (p *Tab) Print(issues []result.Issue) error { +func (p *Tab) Print(issues []*result.Issue) error { w := tabwriter.NewWriter(p.w, 0, 0, 2, ' ', 0) - for i := range issues { - p.printIssue(&issues[i], w) + for _, issue := range issues { + p.printIssue(issue, w) } if err := w.Flush(); err != nil { diff --git a/pkg/printers/tab_test.go b/pkg/printers/tab_test.go index f8e47f84b2b1..1920334753e8 100644 --- a/pkg/printers/tab_test.go +++ b/pkg/printers/tab_test.go @@ -22,7 +22,7 @@ func TestTab_Print(t *testing.T) { }) color.NoColor = false - issues := []result.Issue{ + issues := []*result.Issue{ { FromLinter: "linter-a", Severity: "warning", diff --git a/pkg/printers/teamcity.go b/pkg/printers/teamcity.go index a85307729d05..36114fedfc57 100644 --- a/pkg/printers/teamcity.go +++ b/pkg/printers/teamcity.go @@ -48,12 +48,10 @@ func NewTeamCity(log logutils.Log, w io.Writer) *TeamCity { } } -func (p *TeamCity) Print(issues []result.Issue) error { +func (p *TeamCity) Print(issues []*result.Issue) error { uniqLinters := map[string]struct{}{} - for i := range issues { - issue := issues[i] - + for _, issue := range issues { _, ok := uniqLinters[issue.FromLinter] if !ok { inspectionType := InspectionType{ diff --git a/pkg/printers/teamcity_test.go b/pkg/printers/teamcity_test.go index eda415670273..121a0519eb48 100644 --- a/pkg/printers/teamcity_test.go +++ b/pkg/printers/teamcity_test.go @@ -13,7 +13,7 @@ import ( ) func TestTeamCity_Print(t *testing.T) { - issues := []result.Issue{ + issues := []*result.Issue{ { FromLinter: "linter-a", Severity: "WARNING", diff --git a/pkg/printers/text.go b/pkg/printers/text.go index 545679fb7b45..eb9297615be2 100644 --- a/pkg/printers/text.go +++ b/pkg/printers/text.go @@ -42,16 +42,16 @@ func (p *Text) SprintfColored(ca color.Attribute, format string, args ...any) st return c.Sprintf(format, args...) } -func (p *Text) Print(issues []result.Issue) error { - for i := range issues { - p.printIssue(&issues[i]) +func (p *Text) Print(issues []*result.Issue) error { + for _, issue := range issues { + p.printIssue(issue) if !p.printIssuedLine { continue } - p.printSourceCode(&issues[i]) - p.printUnderLinePointer(&issues[i]) + p.printSourceCode(issue) + p.printUnderLinePointer(issue) } return nil diff --git a/pkg/printers/text_test.go b/pkg/printers/text_test.go index 4a1c39483526..4aa784ee4457 100644 --- a/pkg/printers/text_test.go +++ b/pkg/printers/text_test.go @@ -22,7 +22,7 @@ func TestText_Print(t *testing.T) { }) color.NoColor = false - issues := []result.Issue{ + issues := []*result.Issue{ { FromLinter: "linter-a", Severity: "warning", diff --git a/pkg/result/issue.go b/pkg/result/issue.go index 86a4ef3b7369..2587ffff2cc7 100644 --- a/pkg/result/issue.go +++ b/pkg/result/issue.go @@ -32,7 +32,7 @@ type Issue struct { // HunkPos is used only when golangci-lint is run over a diff HunkPos int `json:",omitempty"` - // If we know how to fix the issue we can provide replacement lines + // If we know how to fix the issue, we can provide replacement lines SuggestedFixes []analysis.SuggestedFix `json:",omitempty"` // If we are expecting a nolint (because this is from nolintlint), record the expected linter @@ -42,7 +42,7 @@ type Issue struct { // Only for Diff processor needs. WorkingDirectoryRelativePath string `json:"-"` - // Only for processor that need relative paths evaluation. + // Only for processors that need relative paths evaluation. RelativePath string `json:"-"` } diff --git a/pkg/result/processors/cgo.go b/pkg/result/processors/cgo.go index dea3801e2c8a..4cc7b57dbf05 100644 --- a/pkg/result/processors/cgo.go +++ b/pkg/result/processors/cgo.go @@ -31,7 +31,7 @@ func (*Cgo) Name() string { return "cgo" } -func (p *Cgo) Process(issues []result.Issue) ([]result.Issue, error) { +func (p *Cgo) Process(issues []*result.Issue) ([]*result.Issue, error) { return filterIssuesErr(issues, p.shouldPassIssue) } diff --git a/pkg/result/processors/diff.go b/pkg/result/processors/diff.go index a84caf7b686a..15574ff0d374 100644 --- a/pkg/result/processors/diff.go +++ b/pkg/result/processors/diff.go @@ -48,7 +48,7 @@ func (*Diff) Name() string { return "diff" } -func (p *Diff) Process(issues []result.Issue) ([]result.Issue, error) { +func (p *Diff) Process(issues []*result.Issue) ([]*result.Issue, error) { if !p.onlyNew && p.fromRev == "" && p.fromMergeBase == "" && p.patchFilePath == "" && p.patch == "" { return issues, nil } diff --git a/pkg/result/processors/exclusion_generated_file_filter.go b/pkg/result/processors/exclusion_generated_file_filter.go index 6cbde3aedf58..d76ec3184f86 100644 --- a/pkg/result/processors/exclusion_generated_file_filter.go +++ b/pkg/result/processors/exclusion_generated_file_filter.go @@ -40,7 +40,7 @@ func (*GeneratedFileFilter) Name() string { return "generated_file_filter" } -func (p *GeneratedFileFilter) Process(issues []result.Issue) ([]result.Issue, error) { +func (p *GeneratedFileFilter) Process(issues []*result.Issue) ([]*result.Issue, error) { if p.mode == config.GeneratedModeDisable { return issues, nil } diff --git a/pkg/result/processors/exclusion_paths.go b/pkg/result/processors/exclusion_paths.go index 90c5f522f8bd..acf13edd0797 100644 --- a/pkg/result/processors/exclusion_paths.go +++ b/pkg/result/processors/exclusion_paths.go @@ -68,7 +68,7 @@ func (*ExclusionPaths) Name() string { return "exclusion_paths" } -func (p *ExclusionPaths) Process(issues []result.Issue) ([]result.Issue, error) { +func (p *ExclusionPaths) Process(issues []*result.Issue) ([]*result.Issue, error) { if len(p.pathPatterns) == 0 && len(p.pathExceptPatterns) == 0 { return issues, nil } diff --git a/pkg/result/processors/exclusion_paths_test.go b/pkg/result/processors/exclusion_paths_test.go index deac410ab366..bfd19af13e65 100644 --- a/pkg/result/processors/exclusion_paths_test.go +++ b/pkg/result/processors/exclusion_paths_test.go @@ -19,22 +19,22 @@ func TestExclusionPaths_Process(t *testing.T) { testCases := []struct { desc string cfg *config.LinterExclusions - issues []result.Issue - expected []result.Issue + issues []*result.Issue + expected []*result.Issue }{ { desc: "paths: word", cfg: &config.LinterExclusions{ Paths: []string{"foo"}, }, - issues: []result.Issue{ + issues: []*result.Issue{ {RelativePath: "foo.go"}, {RelativePath: "foo/foo.go"}, {RelativePath: "foo/bar.go"}, {RelativePath: "bar/foo.go"}, {RelativePath: "bar/bar.go"}, }, - expected: []result.Issue{ + expected: []*result.Issue{ {RelativePath: "bar/bar.go"}, }, }, @@ -43,14 +43,14 @@ func TestExclusionPaths_Process(t *testing.T) { cfg: &config.LinterExclusions{ Paths: []string{"^foo"}, }, - issues: []result.Issue{ + issues: []*result.Issue{ {RelativePath: filepath.FromSlash("foo.go")}, {RelativePath: filepath.FromSlash("foo/foo.go")}, {RelativePath: filepath.FromSlash("foo/bar.go")}, {RelativePath: filepath.FromSlash("bar/foo.go")}, {RelativePath: filepath.FromSlash("bar/bar.go")}, }, - expected: []result.Issue{ + expected: []*result.Issue{ {RelativePath: filepath.FromSlash("bar/foo.go")}, {RelativePath: filepath.FromSlash("bar/bar.go")}, }, @@ -60,14 +60,14 @@ func TestExclusionPaths_Process(t *testing.T) { cfg: &config.LinterExclusions{ Paths: []string{"^foo/"}, }, - issues: []result.Issue{ + issues: []*result.Issue{ {RelativePath: filepath.FromSlash("foo.go")}, {RelativePath: filepath.FromSlash("foo/foo.go")}, {RelativePath: filepath.FromSlash("foo/bar.go")}, {RelativePath: filepath.FromSlash("bar/foo.go")}, {RelativePath: filepath.FromSlash("bar/bar.go")}, }, - expected: []result.Issue{ + expected: []*result.Issue{ {RelativePath: filepath.FromSlash("foo.go")}, {RelativePath: filepath.FromSlash("bar/foo.go")}, {RelativePath: filepath.FromSlash("bar/bar.go")}, @@ -78,22 +78,22 @@ func TestExclusionPaths_Process(t *testing.T) { cfg: &config.LinterExclusions{ Paths: []string{"c/d.go"}, }, - issues: []result.Issue{ + issues: []*result.Issue{ {RelativePath: filepath.FromSlash("a/b/c/d.go")}, {RelativePath: filepath.FromSlash("c/d.go")}, }, - expected: []result.Issue{}, + expected: []*result.Issue{}, }, { desc: "paths: same suffix with constrained expression", cfg: &config.LinterExclusions{ Paths: []string{"^c/d.go"}, }, - issues: []result.Issue{ + issues: []*result.Issue{ {RelativePath: filepath.FromSlash("a/b/c/d.go")}, {RelativePath: filepath.FromSlash("c/d.go")}, }, - expected: []result.Issue{ + expected: []*result.Issue{ {RelativePath: filepath.FromSlash("a/b/c/d.go")}, }, }, @@ -106,11 +106,11 @@ func TestExclusionPaths_Process(t *testing.T) { `^c/d.go`, }, }, - issues: []result.Issue{ + issues: []*result.Issue{ {RelativePath: filepath.FromSlash("a/b/c/d.go")}, {RelativePath: filepath.FromSlash("c/d.go")}, }, - expected: []result.Issue{ + expected: []*result.Issue{ {RelativePath: filepath.FromSlash("a/b/c/d.go")}, }, }, @@ -119,7 +119,7 @@ func TestExclusionPaths_Process(t *testing.T) { cfg: &config.LinterExclusions{ PathsExcept: []string{`^base/c/.*$`}, }, - issues: []result.Issue{ + issues: []*result.Issue{ {RelativePath: filepath.FromSlash("base/a/file.go")}, {RelativePath: filepath.FromSlash("base/b/file.go")}, {RelativePath: filepath.FromSlash("base/c/file.go")}, @@ -127,7 +127,7 @@ func TestExclusionPaths_Process(t *testing.T) { {RelativePath: filepath.FromSlash("base/c/b/file.go")}, {RelativePath: filepath.FromSlash("base/d/file.go")}, }, - expected: []result.Issue{ + expected: []*result.Issue{ {RelativePath: filepath.FromSlash("base/c/file.go")}, {RelativePath: filepath.FromSlash("base/c/a/file.go")}, {RelativePath: filepath.FromSlash("base/c/b/file.go")}, @@ -142,7 +142,7 @@ func TestExclusionPaths_Process(t *testing.T) { `^base/c/.*$`, }, }, - issues: []result.Issue{ + issues: []*result.Issue{ {RelativePath: filepath.FromSlash("base/a/file.go")}, {RelativePath: filepath.FromSlash("base/b/file.go")}, {RelativePath: filepath.FromSlash("base/c/file.go")}, @@ -150,7 +150,7 @@ func TestExclusionPaths_Process(t *testing.T) { {RelativePath: filepath.FromSlash("base/c/b/file.go")}, {RelativePath: filepath.FromSlash("base/d/file.go")}, }, - expected: []result.Issue{ + expected: []*result.Issue{ {RelativePath: filepath.FromSlash("base/c/file.go")}, {RelativePath: filepath.FromSlash("base/c/a/file.go")}, {RelativePath: filepath.FromSlash("base/c/b/file.go")}, @@ -164,7 +164,7 @@ func TestExclusionPaths_Process(t *testing.T) { `^base/c/.*$`, }, }, - issues: []result.Issue{ + issues: []*result.Issue{ {RelativePath: filepath.FromSlash("base/a/file.go")}, {RelativePath: filepath.FromSlash("base/b/file.go")}, {RelativePath: filepath.FromSlash("base/c/file.go")}, @@ -173,7 +173,7 @@ func TestExclusionPaths_Process(t *testing.T) { {RelativePath: filepath.FromSlash("base/d/file.go")}, {RelativePath: filepath.FromSlash("base/e/file.go")}, }, - expected: []result.Issue{ + expected: []*result.Issue{ {RelativePath: filepath.FromSlash("base/c/file.go")}, {RelativePath: filepath.FromSlash("base/c/a/file.go")}, {RelativePath: filepath.FromSlash("base/c/b/file.go")}, @@ -186,7 +186,7 @@ func TestExclusionPaths_Process(t *testing.T) { Paths: []string{"^base/b/"}, PathsExcept: []string{`^base/c/.*$`}, }, - issues: []result.Issue{ + issues: []*result.Issue{ {RelativePath: filepath.FromSlash("base/a/file.go")}, {RelativePath: filepath.FromSlash("base/b/file.go")}, {RelativePath: filepath.FromSlash("base/c/file.go")}, @@ -194,7 +194,7 @@ func TestExclusionPaths_Process(t *testing.T) { {RelativePath: filepath.FromSlash("base/c/b/file.go")}, {RelativePath: filepath.FromSlash("base/d/file.go")}, }, - expected: []result.Issue{ + expected: []*result.Issue{ {RelativePath: filepath.FromSlash("base/c/file.go")}, {RelativePath: filepath.FromSlash("base/c/a/file.go")}, {RelativePath: filepath.FromSlash("base/c/b/file.go")}, @@ -206,7 +206,7 @@ func TestExclusionPaths_Process(t *testing.T) { Paths: []string{"^base/c/a/"}, PathsExcept: []string{`^base/c/.*$`}, }, - issues: []result.Issue{ + issues: []*result.Issue{ {RelativePath: filepath.FromSlash("base/a/file.go")}, {RelativePath: filepath.FromSlash("base/b/file.go")}, {RelativePath: filepath.FromSlash("base/c/file.go")}, @@ -214,7 +214,7 @@ func TestExclusionPaths_Process(t *testing.T) { {RelativePath: filepath.FromSlash("base/c/b/file.go")}, {RelativePath: filepath.FromSlash("base/d/file.go")}, }, - expected: []result.Issue{ + expected: []*result.Issue{ {RelativePath: filepath.FromSlash("base/c/file.go")}, {RelativePath: filepath.FromSlash("base/c/b/file.go")}, }, diff --git a/pkg/result/processors/exclusion_rules.go b/pkg/result/processors/exclusion_rules.go index 064921ae607a..2b5221a89085 100644 --- a/pkg/result/processors/exclusion_rules.go +++ b/pkg/result/processors/exclusion_rules.go @@ -49,7 +49,7 @@ func (*ExclusionRules) Name() string { return "exclusion_rules" } -func (p *ExclusionRules) Process(issues []result.Issue) ([]result.Issue, error) { +func (p *ExclusionRules) Process(issues []*result.Issue) ([]*result.Issue, error) { if len(p.rules) == 0 { return issues, nil } diff --git a/pkg/result/processors/exclusion_rules_test.go b/pkg/result/processors/exclusion_rules_test.go index 5657f45ed7a3..6f78ee2d2b3e 100644 --- a/pkg/result/processors/exclusion_rules_test.go +++ b/pkg/result/processors/exclusion_rules_test.go @@ -63,7 +63,7 @@ func TestExclusionRules_Process_multiple(t *testing.T) { {Path: filepath.FromSlash("testdata/exclusion_rules/exclusion_rules.go"), Line: 3, Linter: "lll"}, } - var issues []result.Issue + var issues []*result.Issue for _, c := range cases { issues = append(issues, newIssueFromIssueTestCase(c)) } @@ -105,9 +105,9 @@ func TestExclusionRules_Process_text(t *testing.T) { p := NewExclusionRules(nil, lines, cfg) texts := []string{"exclude", "1", "", "exclud", "notexclude"} - var issues []result.Issue + var issues []*result.Issue for _, t := range texts { - issues = append(issues, result.Issue{ + issues = append(issues, &result.Issue{ Text: t, FromLinter: "linter", }) @@ -178,7 +178,7 @@ func TestExclusionRules_Process_caseSensitive_multiple(t *testing.T) { {Path: filepath.FromSlash("testdata/exclusion_rules/case_sensitive.go"), Line: 3, Linter: "lll"}, } - var issues []result.Issue + var issues []*result.Issue for _, c := range cases { issues = append(issues, newIssueFromIssueTestCase(c)) } @@ -225,9 +225,9 @@ func TestExclusionRules_Process_caseSensitive_text(t *testing.T) { texts := []string{"exclude", "excLude", "1", "", "exclud", "notexclude"} - var issues []result.Issue + var issues []*result.Issue for _, t := range texts { - issues = append(issues, result.Issue{ + issues = append(issues, &result.Issue{ Text: t, FromLinter: "linter", }) diff --git a/pkg/result/processors/filename_unadjuster.go b/pkg/result/processors/filename_unadjuster.go index a3cdd8e6ed7c..e39601d5a4a4 100644 --- a/pkg/result/processors/filename_unadjuster.go +++ b/pkg/result/processors/filename_unadjuster.go @@ -66,7 +66,7 @@ func (*FilenameUnadjuster) Name() string { return "filename_unadjuster" } -func (p *FilenameUnadjuster) Process(issues []result.Issue) ([]result.Issue, error) { +func (p *FilenameUnadjuster) Process(issues []*result.Issue) ([]*result.Issue, error) { return transformIssues(issues, func(issue *result.Issue) *result.Issue { mapper := p.m[issue.FilePath()] if mapper == nil { diff --git a/pkg/result/processors/fixer.go b/pkg/result/processors/fixer.go index d2beaa0ebafe..ce33b27fb276 100644 --- a/pkg/result/processors/fixer.go +++ b/pkg/result/processors/fixer.go @@ -56,14 +56,14 @@ func (Fixer) Name() string { return "fixer" } -func (p Fixer) Process(issues []result.Issue) ([]result.Issue, error) { +func (p Fixer) Process(issues []*result.Issue) ([]*result.Issue, error) { if !p.cfg.Issues.NeedFix { return issues, nil } p.log.Infof("Applying suggested fixes") - notFixableIssues, err := timeutils.TrackStage(p.sw, "all", func() ([]result.Issue, error) { + notFixableIssues, err := timeutils.TrackStage(p.sw, "all", func() ([]*result.Issue, error) { return p.process(issues) }) if err != nil { @@ -76,13 +76,13 @@ func (p Fixer) Process(issues []result.Issue) ([]result.Issue, error) { } //nolint:funlen,gocyclo // This function should not be split. -func (p Fixer) process(issues []result.Issue) ([]result.Issue, error) { +func (p Fixer) process(issues []*result.Issue) ([]*result.Issue, error) { // filenames / linters / edits editsByLinter := make(map[string]map[string][]diff.Edit) formatters := []string{gofumpt.Name, goimports.Name, gofmt.Name, gci.Name, golines.Name, swaggo.Name} - var notFixableIssues []result.Issue + var notFixableIssues []*result.Issue toBeFormattedFiles := make(map[string]struct{}) @@ -94,7 +94,7 @@ func (p Fixer) process(issues []result.Issue) ([]result.Issue, error) { continue } - if issue.SuggestedFixes == nil || skipNoTextEdit(&issue) { + if issue.SuggestedFixes == nil || skipNoTextEdit(issue) { notFixableIssues = append(notFixableIssues, issue) continue } diff --git a/pkg/result/processors/invalid_issue.go b/pkg/result/processors/invalid_issue.go index a7f45d408333..fa1b19e82c17 100644 --- a/pkg/result/processors/invalid_issue.go +++ b/pkg/result/processors/invalid_issue.go @@ -24,7 +24,7 @@ func (InvalidIssue) Name() string { return "invalid_issue" } -func (p InvalidIssue) Process(issues []result.Issue) ([]result.Issue, error) { +func (p InvalidIssue) Process(issues []*result.Issue) ([]*result.Issue, error) { tcIssues := filterIssuesUnsafe(issues, func(issue *result.Issue) bool { return issue.FromLinter == typeCheckName }) diff --git a/pkg/result/processors/invalid_issue_test.go b/pkg/result/processors/invalid_issue_test.go index 32628c336d31..c685551a9673 100644 --- a/pkg/result/processors/invalid_issue_test.go +++ b/pkg/result/processors/invalid_issue_test.go @@ -19,21 +19,21 @@ func TestInvalidIssue_Process(t *testing.T) { testCases := []struct { desc string - issues []result.Issue - expected []result.Issue + issues []*result.Issue + expected []*result.Issue }{ { desc: "typecheck", - issues: []result.Issue{ + issues: []*result.Issue{ {FromLinter: "typecheck"}, }, - expected: []result.Issue{ + expected: []*result.Issue{ {FromLinter: "typecheck"}, }, }, { desc: "keep only typecheck issues if any exist", - issues: []result.Issue{ + issues: []*result.Issue{ {FromLinter: "typecheck"}, { FromLinter: "example", @@ -42,13 +42,13 @@ func TestInvalidIssue_Process(t *testing.T) { }, }, }, - expected: []result.Issue{ + expected: []*result.Issue{ {FromLinter: "typecheck"}, }, }, { desc: "Go file", - issues: []result.Issue{ + issues: []*result.Issue{ { FromLinter: "example", Pos: token.Position{ @@ -56,7 +56,7 @@ func TestInvalidIssue_Process(t *testing.T) { }, }, }, - expected: []result.Issue{ + expected: []*result.Issue{ { FromLinter: "example", Pos: token.Position{ @@ -67,7 +67,7 @@ func TestInvalidIssue_Process(t *testing.T) { }, { desc: "go.mod", - issues: []result.Issue{ + issues: []*result.Issue{ { FromLinter: "example", Pos: token.Position{ @@ -75,7 +75,7 @@ func TestInvalidIssue_Process(t *testing.T) { }, }, }, - expected: []result.Issue{ + expected: []*result.Issue{ { FromLinter: "example", Pos: token.Position{ @@ -86,7 +86,7 @@ func TestInvalidIssue_Process(t *testing.T) { }, { desc: "non Go file", - issues: []result.Issue{ + issues: []*result.Issue{ { FromLinter: "example", Pos: token.Position{ @@ -94,11 +94,11 @@ func TestInvalidIssue_Process(t *testing.T) { }, }, }, - expected: []result.Issue{}, + expected: []*result.Issue{}, }, { desc: "no filename", - issues: []result.Issue{ + issues: []*result.Issue{ { FromLinter: "example", Pos: token.Position{ @@ -106,7 +106,7 @@ func TestInvalidIssue_Process(t *testing.T) { }, }, }, - expected: []result.Issue{}, + expected: []*result.Issue{}, }, } diff --git a/pkg/result/processors/issues.go b/pkg/result/processors/issues.go index 1e76291c77a1..cc4deeb5267e 100644 --- a/pkg/result/processors/issues.go +++ b/pkg/result/processors/issues.go @@ -6,62 +6,62 @@ import ( "github.com/golangci/golangci-lint/v2/pkg/result" ) -func filterIssues(issues []result.Issue, filter func(issue *result.Issue) bool) []result.Issue { - retIssues := make([]result.Issue, 0, len(issues)) - for i := range issues { - if issues[i].FromLinter == typeCheckName { +func filterIssues(issues []*result.Issue, filter func(issue *result.Issue) bool) []*result.Issue { + retIssues := make([]*result.Issue, 0, len(issues)) + for _, issue := range issues { + if issue.FromLinter == typeCheckName { // don't hide typechecking errors in generated files: users expect to see why the project isn't compiling - retIssues = append(retIssues, issues[i]) + retIssues = append(retIssues, issue) continue } - if filter(&issues[i]) { - retIssues = append(retIssues, issues[i]) + if filter(issue) { + retIssues = append(retIssues, issue) } } return retIssues } -func filterIssuesUnsafe(issues []result.Issue, filter func(issue *result.Issue) bool) []result.Issue { - retIssues := make([]result.Issue, 0, len(issues)) - for i := range issues { - if filter(&issues[i]) { - retIssues = append(retIssues, issues[i]) +func filterIssuesUnsafe(issues []*result.Issue, filter func(issue *result.Issue) bool) []*result.Issue { + retIssues := make([]*result.Issue, 0, len(issues)) + for _, issue := range issues { + if filter(issue) { + retIssues = append(retIssues, issue) } } return retIssues } -func filterIssuesErr(issues []result.Issue, filter func(issue *result.Issue) (bool, error)) ([]result.Issue, error) { - retIssues := make([]result.Issue, 0, len(issues)) - for i := range issues { - if issues[i].FromLinter == typeCheckName { +func filterIssuesErr(issues []*result.Issue, filter func(issue *result.Issue) (bool, error)) ([]*result.Issue, error) { + retIssues := make([]*result.Issue, 0, len(issues)) + for _, issue := range issues { + if issue.FromLinter == typeCheckName { // don't hide typechecking errors in generated files: users expect to see why the project isn't compiling - retIssues = append(retIssues, issues[i]) + retIssues = append(retIssues, issue) continue } - ok, err := filter(&issues[i]) + ok, err := filter(issue) if err != nil { - return nil, fmt.Errorf("can't filter issue %#v: %w", issues[i], err) + return nil, fmt.Errorf("can't filter issue %#v: %w", issue, err) } if ok { - retIssues = append(retIssues, issues[i]) + retIssues = append(retIssues, issue) } } return retIssues, nil } -func transformIssues(issues []result.Issue, transform func(issue *result.Issue) *result.Issue) []result.Issue { - retIssues := make([]result.Issue, 0, len(issues)) - for i := range issues { - newIssue := transform(&issues[i]) +func transformIssues(issues []*result.Issue, transform func(issue *result.Issue) *result.Issue) []*result.Issue { + retIssues := make([]*result.Issue, 0, len(issues)) + for _, issue := range issues { + newIssue := transform(issue) if newIssue != nil { - retIssues = append(retIssues, *newIssue) + retIssues = append(retIssues, newIssue) } } diff --git a/pkg/result/processors/max_from_linter.go b/pkg/result/processors/max_from_linter.go index dec9f3e7f13a..bc7572f2ccaf 100644 --- a/pkg/result/processors/max_from_linter.go +++ b/pkg/result/processors/max_from_linter.go @@ -29,7 +29,7 @@ func (*MaxFromLinter) Name() string { return "max_from_linter" } -func (p *MaxFromLinter) Process(issues []result.Issue) ([]result.Issue, error) { +func (p *MaxFromLinter) Process(issues []*result.Issue) ([]*result.Issue, error) { if p.limit <= 0 { // no limit return issues, nil } diff --git a/pkg/result/processors/max_per_file_from_linter.go b/pkg/result/processors/max_per_file_from_linter.go index 2608c22e22ab..b04b92ea7a7f 100644 --- a/pkg/result/processors/max_per_file_from_linter.go +++ b/pkg/result/processors/max_per_file_from_linter.go @@ -40,7 +40,7 @@ func (*MaxPerFileFromLinter) Name() string { return "max_per_file_from_linter" } -func (p *MaxPerFileFromLinter) Process(issues []result.Issue) ([]result.Issue, error) { +func (p *MaxPerFileFromLinter) Process(issues []*result.Issue) ([]*result.Issue, error) { return filterIssuesUnsafe(issues, func(issue *result.Issue) bool { limit := p.maxPerFileFromLinterConfig[issue.FromLinter] if limit == 0 { diff --git a/pkg/result/processors/max_per_file_from_linter_test.go b/pkg/result/processors/max_per_file_from_linter_test.go index c5bc7ebc1e8b..a886b47c75f0 100644 --- a/pkg/result/processors/max_per_file_from_linter_test.go +++ b/pkg/result/processors/max_per_file_from_linter_test.go @@ -7,8 +7,8 @@ import ( "github.com/golangci/golangci-lint/v2/pkg/result" ) -func newFromLinterIssue(linterName string) result.Issue { - return result.Issue{ +func newFromLinterIssue(linterName string) *result.Issue { + return &result.Issue{ FromLinter: linterName, } } diff --git a/pkg/result/processors/max_same_issues.go b/pkg/result/processors/max_same_issues.go index 06e87586e171..ba22cf31fb62 100644 --- a/pkg/result/processors/max_same_issues.go +++ b/pkg/result/processors/max_same_issues.go @@ -31,7 +31,7 @@ func (*MaxSameIssues) Name() string { return "max_same_issues" } -func (p *MaxSameIssues) Process(issues []result.Issue) ([]result.Issue, error) { +func (p *MaxSameIssues) Process(issues []*result.Issue) ([]*result.Issue, error) { if p.limit <= 0 { // no limit return issues, nil } diff --git a/pkg/result/processors/max_same_issues_test.go b/pkg/result/processors/max_same_issues_test.go index 574059ebbb41..8eb7de0e39a8 100644 --- a/pkg/result/processors/max_same_issues_test.go +++ b/pkg/result/processors/max_same_issues_test.go @@ -10,10 +10,10 @@ import ( func TestMaxSameIssues(t *testing.T) { p := NewMaxSameIssues(1, logutils.NewStderrLog(logutils.DebugKeyEmpty), &config.Config{}) - i1 := result.Issue{ + i1 := &result.Issue{ Text: "1", } - i2 := result.Issue{ + i2 := &result.Issue{ Text: "2", } diff --git a/pkg/result/processors/nolint_filter.go b/pkg/result/processors/nolint_filter.go index e17fd7ad2521..bd2a09abea43 100644 --- a/pkg/result/processors/nolint_filter.go +++ b/pkg/result/processors/nolint_filter.go @@ -91,7 +91,7 @@ func (*NolintFilter) Name() string { return "nolint_filter" } -func (p *NolintFilter) Process(issues []result.Issue) ([]result.Issue, error) { +func (p *NolintFilter) Process(issues []*result.Issue) ([]*result.Issue, error) { // put nolintlint issues last because we process other issues first to determine which nolint directives are unused sort.Stable(sortWithNolintlintLast(issues)) return filterIssuesErr(issues, p.shouldPassIssue) @@ -299,7 +299,7 @@ func (e *rangeExpander) Visit(node ast.Node) ast.Visitor { } // put nolintlint last -type sortWithNolintlintLast []result.Issue +type sortWithNolintlintLast []*result.Issue func (issues sortWithNolintlintLast) Len() int { return len(issues) diff --git a/pkg/result/processors/nolint_filter_test.go b/pkg/result/processors/nolint_filter_test.go index 79dc6c1ce4bb..c620875aba98 100644 --- a/pkg/result/processors/nolint_filter_test.go +++ b/pkg/result/processors/nolint_filter_test.go @@ -16,8 +16,8 @@ import ( "github.com/golangci/golangci-lint/v2/pkg/result" ) -func newNolintFileIssue(line int, fromLinter string) result.Issue { - return result.Issue{ +func newNolintFileIssue(line int, fromLinter string) *result.Issue { + return &result.Issue{ Pos: token.Position{ Filename: filepath.FromSlash("testdata/nolint_filter/nolint.go"), Line: line, @@ -26,7 +26,7 @@ func newNolintFileIssue(line int, fromLinter string) result.Issue { } } -func newNolint2FileIssue(line int) result.Issue { +func newNolint2FileIssue(line int) *result.Issue { i := newNolintFileIssue(line, "errcheck") i.Pos.Filename = filepath.FromSlash("testdata/nolint_filter/nolint2.go") return i @@ -126,7 +126,7 @@ func TestTestNolintFilter_Process(t *testing.T) { func TestNolintFilter_Process_invalidLinterName(t *testing.T) { fileName := filepath.FromSlash("testdata/nolint_filter/bad_names.go") - issues := []result.Issue{ + issues := []*result.Issue{ { Pos: token.Position{ Filename: fileName, @@ -161,7 +161,7 @@ func TestNolintFilter_Process_invalidLinterName(t *testing.T) { func TestNolintFilter_Process_invalidLinterNameWithViolationOnTheSameLine(t *testing.T) { log := getMockLog() log.On("Warnf", "Found unknown linters in //nolint directives: %s", "foobar") - issues := []result.Issue{ + issues := []*result.Issue{ { Pos: token.Position{ Filename: filepath.FromSlash("testdata/nolint_filter/apply_to_unknown.go"), @@ -246,14 +246,14 @@ func TestNolintFilter_Process_wholeFile(t *testing.T) { p := newTestNolintFilter(getMockLog()) defer p.Finish() - processAssertEmpty(t, p, result.Issue{ + processAssertEmpty(t, p, &result.Issue{ Pos: token.Position{ Filename: fileName, Line: 9, }, FromLinter: "errcheck", }) - processAssertSame(t, p, result.Issue{ + processAssertSame(t, p, &result.Issue{ Pos: token.Position{ Filename: fileName, Line: 14, @@ -284,7 +284,7 @@ func TestNolintFilter_Process_unused(t *testing.T) { } // the issue below is the nolintlint issue that would be generated for the test file - nolintlintIssueMisspell := result.Issue{ + nolintlintIssueMisspell := &result.Issue{ Pos: token.Position{ Filename: fileName, Line: 3, @@ -295,7 +295,7 @@ func TestNolintFilter_Process_unused(t *testing.T) { } // the issue below is another nolintlint issue that would be generated for the test file - nolintlintIssueMisspellUnusedOK := result.Issue{ + nolintlintIssueMisspellUnusedOK := &result.Issue{ Pos: token.Position{ Filename: fileName, Line: 5, @@ -323,7 +323,7 @@ func TestNolintFilter_Process_unused(t *testing.T) { p := createProcessor(t, log, []string{"misspell", "nolintlint"}) defer p.Finish() - processAssertEmpty(t, p, []result.Issue{{ + processAssertEmpty(t, p, []*result.Issue{{ Pos: token.Position{ Filename: fileName, Line: 3, diff --git a/pkg/result/processors/path_absoluter.go b/pkg/result/processors/path_absoluter.go index 99f3de42a2cd..240cedf8eaf4 100644 --- a/pkg/result/processors/path_absoluter.go +++ b/pkg/result/processors/path_absoluter.go @@ -22,7 +22,7 @@ func (*PathAbsoluter) Name() string { return "path_absoluter" } -func (p *PathAbsoluter) Process(issues []result.Issue) ([]result.Issue, error) { +func (p *PathAbsoluter) Process(issues []*result.Issue) ([]*result.Issue, error) { return transformIssues(issues, func(issue *result.Issue) *result.Issue { if filepath.IsAbs(issue.FilePath()) { return issue diff --git a/pkg/result/processors/path_prettifier.go b/pkg/result/processors/path_prettifier.go index cb6ef8ebc27d..94dfbab370ab 100644 --- a/pkg/result/processors/path_prettifier.go +++ b/pkg/result/processors/path_prettifier.go @@ -30,7 +30,7 @@ func (*PathPrettifier) Name() string { return "path_prettifier" } -func (p *PathPrettifier) Process(issues []result.Issue) ([]result.Issue, error) { +func (p *PathPrettifier) Process(issues []*result.Issue) ([]*result.Issue, error) { if p.cfg.PathMode == fsutils.OutputPathModeAbsolute { return issues, nil } diff --git a/pkg/result/processors/path_prettifier_test.go b/pkg/result/processors/path_prettifier_test.go index 824509712ef7..2f403d46a327 100644 --- a/pkg/result/processors/path_prettifier_test.go +++ b/pkg/result/processors/path_prettifier_test.go @@ -13,15 +13,15 @@ import ( "github.com/golangci/golangci-lint/v2/pkg/result" ) -func newPPIssue(fn, rp string) result.Issue { - return result.Issue{ +func newPPIssue(fn, rp string) *result.Issue { + return &result.Issue{ Pos: token.Position{Filename: filepath.FromSlash(fn)}, RelativePath: filepath.FromSlash(rp), } } func TestPathPrettifier_Process(t *testing.T) { - paths := func(ps ...string) (issues []result.Issue) { + paths := func(ps ...string) (issues []*result.Issue) { for _, p := range ps { issues = append(issues, newPPIssue("test", p)) } @@ -30,12 +30,12 @@ func TestPathPrettifier_Process(t *testing.T) { for _, tt := range []struct { name, prefix string - issues, want []result.Issue + issues, want []*result.Issue }{ { name: "empty prefix", issues: paths("some/path", "cool"), - want: []result.Issue{ + want: []*result.Issue{ newPPIssue("some/path", "some/path"), newPPIssue("cool", "cool"), }, @@ -44,7 +44,7 @@ func TestPathPrettifier_Process(t *testing.T) { name: "prefix", prefix: "ok", issues: paths("some/path", "cool"), - want: []result.Issue{ + want: []*result.Issue{ newPPIssue("ok/some/path", "some/path"), newPPIssue("ok/cool", "cool"), }, @@ -53,7 +53,7 @@ func TestPathPrettifier_Process(t *testing.T) { name: "prefix slashed", prefix: "ok/", issues: paths("some/path", "cool"), - want: []result.Issue{ + want: []*result.Issue{ newPPIssue("ok/some/path", "some/path"), newPPIssue("ok/cool", "cool"), }, diff --git a/pkg/result/processors/path_relativity.go b/pkg/result/processors/path_relativity.go index 8b2958a4a308..c68662c7bb1f 100644 --- a/pkg/result/processors/path_relativity.go +++ b/pkg/result/processors/path_relativity.go @@ -36,7 +36,7 @@ func (*PathRelativity) Name() string { return "path_relativity" } -func (p *PathRelativity) Process(issues []result.Issue) ([]result.Issue, error) { +func (p *PathRelativity) Process(issues []*result.Issue) ([]*result.Issue, error) { return transformIssues(issues, func(issue *result.Issue) *result.Issue { newIssue := *issue diff --git a/pkg/result/processors/path_shortener.go b/pkg/result/processors/path_shortener.go index 7a14c39c972e..23df4f02cc20 100644 --- a/pkg/result/processors/path_shortener.go +++ b/pkg/result/processors/path_shortener.go @@ -29,7 +29,7 @@ func (PathShortener) Name() string { return "path_shortener" } -func (p PathShortener) Process(issues []result.Issue) ([]result.Issue, error) { +func (p PathShortener) Process(issues []*result.Issue) ([]*result.Issue, error) { return transformIssues(issues, func(issue *result.Issue) *result.Issue { newIssue := issue newIssue.Text = strings.ReplaceAll(newIssue.Text, p.wd+"/", "") diff --git a/pkg/result/processors/processor.go b/pkg/result/processors/processor.go index 1976d6e44ad9..f5603c94dc75 100644 --- a/pkg/result/processors/processor.go +++ b/pkg/result/processors/processor.go @@ -7,7 +7,7 @@ import ( const typeCheckName = "typecheck" type Processor interface { - Process(issues []result.Issue) ([]result.Issue, error) + Process(issues []*result.Issue) ([]*result.Issue, error) Name() string Finish() } diff --git a/pkg/result/processors/processor_test.go b/pkg/result/processors/processor_test.go index 41bb78a7b3ae..95fdb5f81445 100644 --- a/pkg/result/processors/processor_test.go +++ b/pkg/result/processors/processor_test.go @@ -18,8 +18,8 @@ type issueTestCase struct { Severity string } -func newIssueFromIssueTestCase(c issueTestCase) result.Issue { - return result.Issue{ +func newIssueFromIssueTestCase(c issueTestCase) *result.Issue { + return &result.Issue{ Text: c.Text, FromLinter: c.Linter, Severity: c.Severity, @@ -31,13 +31,13 @@ func newIssueFromIssueTestCase(c issueTestCase) result.Issue { } } -func newIssueFromTextTestCase(text string) result.Issue { - return result.Issue{ +func newIssueFromTextTestCase(text string) *result.Issue { + return &result.Issue{ Text: text, } } -func process(t *testing.T, p Processor, issues ...result.Issue) []result.Issue { +func process(t *testing.T, p Processor, issues ...*result.Issue) []*result.Issue { t.Helper() processedIssues, err := p.Process(issues) @@ -45,14 +45,14 @@ func process(t *testing.T, p Processor, issues ...result.Issue) []result.Issue { return processedIssues } -func processAssertSame(t *testing.T, p Processor, issues ...result.Issue) { +func processAssertSame(t *testing.T, p Processor, issues ...*result.Issue) { t.Helper() processedIssues := process(t, p, issues...) assert.Equal(t, issues, processedIssues) } -func processAssertEmpty(t *testing.T, p Processor, issues ...result.Issue) { +func processAssertEmpty(t *testing.T, p Processor, issues ...*result.Issue) { t.Helper() processedIssues := process(t, p, issues...) diff --git a/pkg/result/processors/severity.go b/pkg/result/processors/severity.go index 035ca80c4e1d..33c3997f8889 100644 --- a/pkg/result/processors/severity.go +++ b/pkg/result/processors/severity.go @@ -43,7 +43,7 @@ func NewSeverity(log logutils.Log, lines *fsutils.LineCache, cfg *config.Severit func (p *Severity) Name() string { return p.name } -func (p *Severity) Process(issues []result.Issue) ([]result.Issue, error) { +func (p *Severity) Process(issues []*result.Issue) ([]*result.Issue, error) { if len(p.rules) == 0 && p.defaultSeverity == "" { return issues, nil } diff --git a/pkg/result/processors/severity_test.go b/pkg/result/processors/severity_test.go index 0774f0b1d517..a5c50d0011cc 100644 --- a/pkg/result/processors/severity_test.go +++ b/pkg/result/processors/severity_test.go @@ -92,7 +92,7 @@ func TestSeverity_multiple(t *testing.T) { {Path: "empty.go", Text: "empty", Linter: "empty"}, } - var issues []result.Issue + var issues []*result.Issue for _, c := range cases { issues = append(issues, newIssueFromIssueTestCase(c)) } @@ -141,9 +141,9 @@ func TestSeverity_text(t *testing.T) { p := NewSeverity(nil, nil, opts) texts := []string{"seveRity", "1", "", "serverit", "notseverity"} - var issues []result.Issue + var issues []*result.Issue for _, t := range texts { - issues = append(issues, result.Issue{ + issues = append(issues, &result.Issue{ Text: t, FromLinter: "linter", }) @@ -176,7 +176,7 @@ func TestSeverity_onlyDefault(t *testing.T) { {Path: "empty.go", Text: "empty", Linter: "empty"}, } - var issues []result.Issue + var issues []*result.Issue for _, c := range cases { issues = append(issues, newIssueFromIssueTestCase(c)) } @@ -230,7 +230,7 @@ func TestSeverity_caseSensitive(t *testing.T) { {Path: "e.go", Text: "ssL", Linter: "gosec"}, } - var issues []result.Issue + var issues []*result.Issue for _, c := range cases { issues = append(issues, newIssueFromIssueTestCase(c)) } diff --git a/pkg/result/processors/sort_results.go b/pkg/result/processors/sort_results.go index 033eca9a4374..8ba06bccfd10 100644 --- a/pkg/result/processors/sort_results.go +++ b/pkg/result/processors/sort_results.go @@ -54,7 +54,7 @@ func NewSortResults(cfg *config.Output) *SortResults { func (SortResults) Name() string { return "sort_results" } // Process is performing sorting of the result issues. -func (p SortResults) Process(issues []result.Issue) ([]result.Issue, error) { +func (p SortResults) Process(issues []*result.Issue) ([]*result.Issue, error) { if len(p.cfg.SortOrder) == 0 { p.cfg.SortOrder = []string{orderNameLinter, orderNameFile} } @@ -72,8 +72,8 @@ func (p SortResults) Process(issues []result.Issue) ([]result.Issue, error) { comp := mergeComparators(cmps...) - slices.SortFunc(issues, func(a, b result.Issue) int { - return comp(&a, &b) + slices.SortFunc(issues, func(a, b *result.Issue) int { + return comp(a, b) }) return issues, nil diff --git a/pkg/result/processors/sort_results_test.go b/pkg/result/processors/sort_results_test.go index fcfd824c8eb1..dc097cc967de 100644 --- a/pkg/result/processors/sort_results_test.go +++ b/pkg/result/processors/sort_results_test.go @@ -12,7 +12,7 @@ import ( "github.com/golangci/golangci-lint/v2/pkg/result" ) -var issues = []result.Issue{ +var issues = []*result.Issue{ { FromLinter: "b", Severity: "medium", @@ -50,7 +50,7 @@ var issues = []result.Issue{ }, } -var extraSeverityIssues = []result.Issue{ +var extraSeverityIssues = []*result.Issue{ { FromLinter: "c", Severity: "error", @@ -72,16 +72,16 @@ var extraSeverityIssues = []result.Issue{ } type compareTestCase struct { - a, b result.Issue + a, b *result.Issue expected int } func testCompareValues(t *testing.T, cmp issueComparator, name string, tests []compareTestCase) { - for i, test := range tests { //nolint:gocritic // To ignore rangeValCopy rule + for i, test := range tests { t.Run(fmt.Sprintf("%s(%d)", name, i), func(t *testing.T) { t.Parallel() - res := cmp(&test.a, &test.b) + res := cmp(test.a, test.b) assert.Equal(t, compToString(test.expected), compToString(res)) }) @@ -210,7 +210,7 @@ func Test_numericCompare(t *testing.T) { } func TestSortResults_Process(t *testing.T) { - tests := make([]result.Issue, len(issues)) + tests := make([]*result.Issue, len(issues)) copy(tests, issues) cfg := &config.Output{} @@ -219,7 +219,7 @@ func TestSortResults_Process(t *testing.T) { results, err := sr.Process(tests) require.NoError(t, err) - assert.Equal(t, []result.Issue{issues[1], issues[0], issues[3], issues[2]}, results) + assert.Equal(t, []*result.Issue{issues[1], issues[0], issues[3], issues[2]}, results) } func compToString(c int) string { diff --git a/pkg/result/processors/source_code.go b/pkg/result/processors/source_code.go index 1096269c8176..d4e82643c0d9 100644 --- a/pkg/result/processors/source_code.go +++ b/pkg/result/processors/source_code.go @@ -31,7 +31,7 @@ func (SourceCode) Name() string { return "source_code" } -func (p SourceCode) Process(issues []result.Issue) ([]result.Issue, error) { +func (p SourceCode) Process(issues []*result.Issue) ([]*result.Issue, error) { return transformIssues(issues, p.transform), nil } diff --git a/pkg/result/processors/uniq_by_line.go b/pkg/result/processors/uniq_by_line.go index 113b5814ad16..953496355b09 100644 --- a/pkg/result/processors/uniq_by_line.go +++ b/pkg/result/processors/uniq_by_line.go @@ -25,7 +25,7 @@ func (*UniqByLine) Name() string { return "uniq_by_line" } -func (p *UniqByLine) Process(issues []result.Issue) ([]result.Issue, error) { +func (p *UniqByLine) Process(issues []*result.Issue) ([]*result.Issue, error) { if !p.enabled { return issues, nil } diff --git a/pkg/result/processors/uniq_by_line_test.go b/pkg/result/processors/uniq_by_line_test.go index dadca6a9afa1..d623c2e62569 100644 --- a/pkg/result/processors/uniq_by_line_test.go +++ b/pkg/result/processors/uniq_by_line_test.go @@ -7,8 +7,8 @@ import ( "github.com/golangci/golangci-lint/v2/pkg/result" ) -func newULIssue(file string, line int) result.Issue { - return result.Issue{ +func newULIssue(file string, line int) *result.Issue { + return &result.Issue{ Pos: token.Position{ Filename: file, Line: line, diff --git a/scripts/website/expand_templates/thanks_test.go b/scripts/website/expand_templates/thanks_test.go index 6af152336e99..7caa7e28c49f 100644 --- a/scripts/website/expand_templates/thanks_test.go +++ b/scripts/website/expand_templates/thanks_test.go @@ -14,7 +14,7 @@ type FakeLinter struct { name string } -func (*FakeLinter) Run(_ context.Context, _ *linter.Context) ([]result.Issue, error) { +func (*FakeLinter) Run(_ context.Context, _ *linter.Context) ([]*result.Issue, error) { return nil, nil } From 6cd10a9c28ba3deb731901b5b5293263ff5ff650 Mon Sep 17 00:00:00 2001 From: Ludovic Fernandez Date: Mon, 2 Jun 2025 21:54:51 +0200 Subject: [PATCH 93/96] dev: handle linter major versions (#5848) --- pkg/goanalysis/linter.go | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/pkg/goanalysis/linter.go b/pkg/goanalysis/linter.go index 29bd841a85c6..153e538b5820 100644 --- a/pkg/goanalysis/linter.go +++ b/pkg/goanalysis/linter.go @@ -76,6 +76,25 @@ func (lnt *Linter) WithDesc(desc string) *Linter { return lnt } +func (lnt *Linter) WithVersion(v int) *Linter { + if v == 0 { + return lnt + } + + for _, analyzer := range lnt.analyzers { + if lnt.name != analyzer.Name { + continue + } + + // The analyzer name should be the same as the linter name to avoid displaying the name inside the reports. + analyzer.Name = fmt.Sprintf("%s_v%d", analyzer.Name, v) + } + + lnt.name = fmt.Sprintf("%s_v%d", lnt.name, v) + + return lnt +} + func (lnt *Linter) WithConfig(cfg map[string]any) *Linter { if len(cfg) == 0 { return lnt From 75b18f9695e8c882d3a6401d84dfae5239407604 Mon Sep 17 00:00:00 2001 From: Ludovic Fernandez Date: Wed, 4 Jun 2025 11:37:56 +0200 Subject: [PATCH 94/96] feat: deprecate print-resources-usage flag (#5860) --- pkg/commands/run.go | 1 + 1 file changed, 1 insertion(+) diff --git a/pkg/commands/run.go b/pkg/commands/run.go index 4e2d3b1b984a..1864559f9fc3 100644 --- a/pkg/commands/run.go +++ b/pkg/commands/run.go @@ -584,6 +584,7 @@ func setupConfigFileFlagSet(fs *pflag.FlagSet, cfg *config.LoaderOptions) { func setupRunPersistentFlags(fs *pflag.FlagSet, opts *runOptions) { fs.BoolVar(&opts.PrintResourcesUsage, "print-resources-usage", false, color.GreenString("Print avg and max memory usage of golangci-lint and total time")) + _ = fs.MarkDeprecated("print-resources-usage", "use --verbose instead") fs.StringVar(&opts.CPUProfilePath, "cpu-profile-path", "", color.GreenString("Path to CPU profile output file")) fs.StringVar(&opts.MemProfilePath, "mem-profile-path", "", color.GreenString("Path to memory profile output file")) From a25cd63879d2252bcee283c5aca0c737ff6ff801 Mon Sep 17 00:00:00 2001 From: Oleksandr Redko Date: Wed, 4 Jun 2025 13:29:30 +0300 Subject: [PATCH 95/96] docs: add a note about `GL_DEBUG=staticcheck` (#5861) --- .golangci.next.reference.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.golangci.next.reference.yml b/.golangci.next.reference.yml index abc9c060efbe..96559b4ec4e1 100644 --- a/.golangci.next.reference.yml +++ b/.golangci.next.reference.yml @@ -2850,6 +2850,7 @@ linters: http-status-code-whitelist: [ "200", "400", "404", "500" ] # SAxxxx checks in https://staticcheck.dev/docs/configuration/options/#checks # Example (to disable some checks): [ "all", "-SA1000", "-SA1001"] + # Run `GL_DEBUG=staticcheck golangci-lint run --enable=staticcheck` to see all available checks and enabled by config checks. # Default: ["all", "-ST1000", "-ST1003", "-ST1016", "-ST1020", "-ST1021", "-ST1022"] checks: # Invalid regular expression. From 65c85df747e7da862b7fefd2c2f2ffdceafe5c8b Mon Sep 17 00:00:00 2001 From: Ludovic Fernandez Date: Thu, 5 Jun 2025 21:16:27 +0200 Subject: [PATCH 96/96] fix: deduplicate typecheck errors (#5864) --- pkg/goanalysis/pkgerrors/errors.go | 9 +++++++++ pkg/lint/runner.go | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/pkg/goanalysis/pkgerrors/errors.go b/pkg/goanalysis/pkgerrors/errors.go index 062a8f43aeff..5d2b816ac6cf 100644 --- a/pkg/goanalysis/pkgerrors/errors.go +++ b/pkg/goanalysis/pkgerrors/errors.go @@ -20,6 +20,7 @@ func (e *IllTypedError) Error() string { func BuildIssuesFromIllTypedError(errs []error, lintCtx *linter.Context) ([]*result.Issue, error) { var issues []*result.Issue + uniqReportedIssues := map[string]bool{} var other error @@ -39,9 +40,17 @@ func BuildIssuesFromIllTypedError(errs []error, lintCtx *linter.Context) ([]*res if uniqReportedIssues[err.Msg] { continue } + uniqReportedIssues[err.Msg] = true lintCtx.Log.Errorf("typechecking error: %s", err.Msg) } else { + key := fmt.Sprintf("%s.%d.%d.%s", issue.FilePath(), issue.Line(), issue.Column(), issue.Text) + if uniqReportedIssues[key] { + continue + } + + uniqReportedIssues[key] = true + issue.Pkg = ill.Pkg // to save to cache later issues = append(issues, issue) } diff --git a/pkg/lint/runner.go b/pkg/lint/runner.go index 5cc46feb101d..ba7750f28577 100644 --- a/pkg/lint/runner.go +++ b/pkg/lint/runner.go @@ -232,7 +232,7 @@ func (r *Runner) processIssues(issues []*result.Issue, sw *timeutils.Stopwatch, }) if err != nil { - r.Log.Warnf("Can't process result by %s processor: %s", p.Name(), err) + r.Log.Warnf("Can't process results by %s processor: %s", p.Name(), err) } else { stat := statPerProcessor[p.Name()] stat.inCount += len(issues)