From 624dcab7c553a9944df93e8aaf1dc24f077e3540 Mon Sep 17 00:00:00 2001 From: golangci-releaser <65486276+golangci-releaser@users.noreply.github.com> Date: Fri, 3 May 2024 18:23:00 +0000 Subject: [PATCH] [create-pull-request] automated change --- .golangci.reference.yml | 145 ++++++------ assets/cli-help.json | 4 +- assets/default-exclusions.json | 46 ++-- assets/linters-info.json | 220 ++++------------- jsonschema/golangci.jsonschema.json | 353 ++++++++++++++++++++-------- 5 files changed, 397 insertions(+), 371 deletions(-) diff --git a/.golangci.reference.yml b/.golangci.reference.yml index c4e23bb0cbd6..2995ca5d3423 100644 --- a/.golangci.reference.yml +++ b/.golangci.reference.yml @@ -154,9 +154,9 @@ linters-settings: pop-directional-isolate: false copyloopvar: - # If true, ignore aliasing of loop variables. + # Check all assigning the loop variable to another variable. # Default: false - ignore-alias: true + check-alias: true cyclop: # The maximal code complexity to report. @@ -279,23 +279,11 @@ linters-settings: # Default: false check-blank: true - # DEPRECATED comma-separated list of pairs of the form pkg:regex - # - # the regex is used to ignore names within pkg. (default "fmt:.*"). - # see https://github.com/kisielk/errcheck#the-deprecated-method for details - ignore: fmt:.*,io/ioutil:^Read.* - # To disable the errcheck built-in exclude list. # See `-excludeonly` option in https://github.com/kisielk/errcheck#excluding-functions for details. # Default: false disable-default-exclusions: true - # DEPRECATED use exclude-functions instead. - # - # Path to a file containing a list of functions to exclude from checking. - # See https://github.com/kisielk/errcheck#excluding-functions for details. - exclude: /path/to/file.txt - # List of functions to exclude from checking, where each entry is a single function to exclude. # See https://github.com/kisielk/errcheck#excluding-functions for details. exclude-functions: @@ -338,6 +326,16 @@ linters-settings: # Check for plain error comparisons. # Default: true comparison: false + # Allowed errors. + # Default: [] + allowed-errors: + - err: "io.EOF" + fun: "example.com/pkg.Read" + # Allowed error "wildcards". + # Default: [] + allowed-errors-wildcard: + - err: "example.com/pkg.ErrMagic" + fun: "example.com/pkg.Magic" exhaustive: # Program elements to check for exhaustiveness. @@ -431,12 +429,9 @@ linters-settings: ignore-comments: true gci: - # DEPRECATED: use `sections` and `prefix(github.com/org/project)` instead. - local-prefixes: github.com/org/project - # 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`, + # 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: @@ -446,6 +441,7 @@ linters-settings: - blank # Blank section: contains all blank imports. This section is not present unless explicitly enabled. - dot # Dot section: contains all dot imports. This section is not present unless explicitly enabled. - alias # Alias section: contains all alias imports. This section is not present unless explicitly enabled. + - localmodule # Local module section: contains all local packages. This section is not present unless explicitly enabled. # Skip generated files. # Default: true @@ -636,9 +632,6 @@ linters-settings: # The option is passed to the ruleguard 'debug-group' argument. # Default: "" debug: 'emptyDecl' - # Deprecated, use 'failOn' param. - # If set to true, identical to failOn='all', otherwise failOn='' - failOnError: false # Determines the behavior when an error occurs while parsing ruleguard files. # If flag is not set, log error and skip rule files that contain an error. # If flag is set, the value must be a comma-separated list of error conditions. @@ -646,7 +639,7 @@ linters-settings: # - 'import': ruleguard rule imports a package that cannot be found. # - 'dsl': gorule file does not comply with the ruleguard DSL. # Default: "" - failOn: dsl + failOn: dsl,import # Comma-separated list of file paths containing ruleguard rules. # If a path is relative, it is relative to the directory where the golangci-lint command is executed. # The special '${configDir}' variable is substituted with the absolute directory containing the golangci config file. @@ -723,9 +716,6 @@ linters-settings: replacement: 'a[b:]' gofumpt: - # Deprecated: use the global `run.go` instead. - lang-version: "1.17" - # Module path which contains the source code being formatted. # Default: "" module-path: github.com/org/project @@ -779,38 +769,6 @@ linters-settings: # Default: "" local-prefixes: github.com/org/project - gomnd: - # List of enabled checks, see https://github.com/tommy-muehle/go-mnd/#checks for description. - # Default: ["argument", "case", "condition", "operation", "return", "assign"] - checks: - - argument - - case - - condition - - operation - - return - - 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" - # Default: [] - ignored-numbers: - - '0666' - - '0755' - - '42' - # List of file patterns to exclude from analysis. - # Values always ignored: `.+_test.go` - # Default: [] - ignored-files: - - 'magic1_.+\.go$' - # List of function patterns to exclude from analysis. - # Following functions are always ignored: `time.Date`, - # `strconv.FormatInt`, `strconv.FormatUint`, `strconv.FormatFloat`, - # `strconv.ParseInt`, `strconv.ParseUint`, `strconv.ParseFloat`. - # Default: [] - ignored-functions: - - '^math\.' - - '^http\.StatusText$' - gomoddirectives: # Allow local `replace` directives. # Default: false @@ -861,8 +819,6 @@ linters-settings: local_replace_directives: false gosimple: - # Deprecated: use the global `run.go` instead. - go: "1.15" # Sxxxx checks in https://staticcheck.io/docs/configuration/options/#checks # Default: ["*"] checks: [ "all" ] @@ -1367,6 +1323,38 @@ linters-settings: # Default: "" mode: restricted + mnd: + # List of enabled checks, see https://github.com/tommy-muehle/go-mnd/#checks for description. + # Default: ["argument", "case", "condition", "operation", "return", "assign"] + checks: + - argument + - case + - condition + - operation + - return + - 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" + # Default: [] + ignored-numbers: + - '0666' + - '0755' + - '42' + # List of file patterns to exclude from analysis. + # Values always ignored: `.+_test.go` + # Default: [] + ignored-files: + - 'magic1_.+\.go$' + # List of function patterns to exclude from analysis. + # Following functions are always ignored: `time.Date`, + # `strconv.FormatInt`, `strconv.FormatUint`, `strconv.FormatFloat`, + # `strconv.ParseInt`, `strconv.ParseUint`, `strconv.ParseFloat`. + # Default: [] + ignored-functions: + - '^math\.' + - '^http\.StatusText$' + musttag: # A set of custom functions to check in addition to the builtin ones. # Default: json, xml, gopkg.in/yaml.v3, BurntSushi/toml, mitchellh/mapstructure, jmoiron/sqlx @@ -2013,8 +2001,12 @@ linters-settings: # Default: "" no-global: "all" # Enforce using methods that accept a context. - # Default: false - context-only: true + # Values: + # - "": disabled + # - "all": report all contextless calls + # - "scope": report only if a context exists in the scope of the outermost function + # Default: "" + context: "all" # Enforce using static values for log messages. # Default: false static-msg: true @@ -2046,17 +2038,19 @@ linters-settings: # Default: [] ignore-check-signatures: - "telemetry.RecordError" - + # A list of regexes for additional function signatures that create spans. + # This is useful if you have a utility method to create spans. + # Each entry should be of the form `:`, where `telemetry-type` can be `opentelemetry` or `opencensus`. + # https://github.com/jjti/go-spancheck#extra-start-span-signatures + # Default: [] + extra-start-span-signatures: + - "github.com/user/repo/telemetry/trace.Start:opentelemetry" staticcheck: - # Deprecated: use the global `run.go` instead. - go: "1.15" # SAxxxx checks in https://staticcheck.io/docs/configuration/options/#checks # Default: ["*"] checks: [ "all" ] stylecheck: - # Deprecated: use the global `run.go` instead. - go: "1.15" # STxxxx checks in https://staticcheck.io/docs/configuration/options/#checks # Default: ["*"] checks: [ "all", "-ST1000", "-ST1003", "-ST1016", "-ST1020", "-ST1021", "-ST1022" ] @@ -2280,9 +2274,6 @@ linters-settings: # Suggest the use of rpc.DefaultXXPath. # Default: false default-rpc-path: true - # DEPRECATED Suggest the use of os.DevNull. - # Default: false - os-dev-null: true # Suggest the use of sql.LevelXX.String(). # Default: false sql-isolation-level: true @@ -2292,9 +2283,6 @@ linters-settings: # Suggest the use of constant.Kind.String(). # Default: false constant-kind: true - # DEPRECATED Suggest the use of syslog.Priority. - # Default: false - syslog-priority: true unconvert: # Remove conversions that force intermediate rounding. @@ -2514,6 +2502,7 @@ linters: - asciicheck - bidichk - bodyclose + - canonicalheader - containedctx - contextcheck - copyloopvar @@ -2524,6 +2513,7 @@ linters: - dupl - dupword - durationcheck + - err113 - errcheck - errchkjson - errname @@ -2532,6 +2522,7 @@ linters: - exhaustive - exhaustruct - exportloopref + - fatcontext - forbidigo - forcetypeassert - funlen @@ -2547,12 +2538,10 @@ linters: - gocyclo - godot - godox - - goerr113 - gofmt - gofumpt - goheader - goimports - - gomnd - gomoddirectives - gomodguard - goprintffuncname @@ -2573,6 +2562,7 @@ linters: - makezero - mirror - misspell + - mnd - musttag - nakedret - nestif @@ -2627,6 +2617,7 @@ linters: - asciicheck - bidichk - bodyclose + - canonicalheader - containedctx - contextcheck - copyloopvar @@ -2637,6 +2628,7 @@ linters: - dupl - dupword - durationcheck + - err113 - errcheck - errchkjson - errname @@ -2645,6 +2637,7 @@ linters: - exhaustive - exhaustruct - exportloopref + - fatcontext - forbidigo - forcetypeassert - funlen @@ -2660,12 +2653,10 @@ linters: - gocyclo - godot - godox - - goerr113 - gofmt - gofumpt - goheader - goimports - - gomnd - gomoddirectives - gomodguard - goprintffuncname @@ -2686,6 +2677,7 @@ linters: - makezero - mirror - misspell + - mnd - musttag - nakedret - nestif @@ -2735,6 +2727,7 @@ linters: - ifshort # Deprecated - interfacer # Deprecated - maligned # Deprecated + - gomnd # Deprecated - nosnakecase # Deprecated - scopelint # Deprecated - structcheck # Deprecated diff --git a/assets/cli-help.json b/assets/cli-help.json index ffa45225a4ab..1d6c0bda340f 100644 --- a/assets/cli-help.json +++ b/assets/cli-help.json @@ -1,4 +1,4 @@ { - "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 [fast: false, auto-fix: false]\ngosimple (megacheck): Linter for Go source code that specializes in simplifying code [fast: false, auto-fix: false]\ngovet (vet, vetshadow): Vet examines Go source code and reports suspicious constructs. It is roughly the same as 'go vet' and uses its passes. [fast: false, auto-fix: false]\nineffassign: Detects when assignments to existing variables are not used [fast: true, auto-fix: false]\nstaticcheck (megacheck): It's a set of rules from staticcheck. It's not the same thing as the staticcheck binary. The author of staticcheck doesn't support or approve the use of staticcheck as a library inside golangci-lint. [fast: false, auto-fix: false]\nunused (megacheck): Checks Go code for unused constants, variables, functions and types [fast: false, auto-fix: false]", - "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 -D, --disable strings Disable specific linter\n --disable-all Disable all linters\n -E, --enable strings Enable specific linter\n --enable-all Enable all linters\n --fast Enable only fast linters from enabled linters set (first run won't be fast)\n -p, --presets strings Enable presets (bugs|comment|complexity|error|format|import|metalinter|module|performance|sql|style|test|unused) of linters. Run 'golangci-lint help linters' to see them. This option implies option --disable-all\n --enable-only strings Override linters configuration section to only run the specific linter(s)\n -j, --concurrency int Number of CPUs to use (Default: number of logical CPUs) (default 8)\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 --go string Targeted Go version\n --build-tags strings Build tags\n --timeout duration Timeout for total work (default 1m0s)\n --tests Analyze tests (*_test.go) (default true)\n --allow-parallel-runners Allow multiple parallel golangci-lint instances running. 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. If false (default) - golangci-lint exits with an error if it fails to acquire file lock on start.\n --out-format string Formats of output: json|line-number|colored-line-number|tab|colored-tab|checkstyle|code-climate|html|junit-xml|github-actions|teamcity (default \"colored-line-number\")\n --print-issued-lines Print lines of code with issue (default true)\n --print-linter-name Print linter name in issue line (default true)\n --uniq-by-line Make issues output unique by line (default true)\n --sort-results Sort linter results\n --sort-order strings Sort order of linter results\n --path-prefix string Path prefix to add to output\n --show-stats Show statistics per linter\n -e, --exclude strings Exclude issue by regexp\n --exclude-use-default Use or not use default excludes:\n # EXC0001 errcheck: Almost all programs ignore errors on these functions and in most cases it's ok\n - Error return value of .((os\\.)?std(out|err)\\..*|.*Close|.*Flush|os\\.Remove(All)?|.*print(f|ln)?|os\\.(Un)?Setenv). is not checked\n \n # EXC0002 golint: Annoying issue about not having a comment. The rare codebase has such comments\n - (comment on exported (method|function|type|const)|should have( a package)? comment|comment should be of the form)\n \n # EXC0003 golint: False positive when tests are defined in package 'test'\n - func name will be used as test\\.Test.* by other packages, and that stutters; consider calling this\n \n # EXC0004 govet: Common false positives\n - (possible misuse of unsafe.Pointer|should have signature)\n \n # EXC0005 staticcheck: Developers tend to write in C-style with an explicit 'break' in a 'switch', so it's ok to ignore\n - ineffective break statement. Did you mean to break out of the outer loop\n \n # EXC0006 gosec: Too many false-positives on 'unsafe' usage\n - Use of unsafe calls should be audited\n \n # EXC0007 gosec: Too many false-positives for parametrized shell calls\n - Subprocess launch(ed with variable|ing should be audited)\n \n # EXC0008 gosec: Duplicated errcheck checks\n - (G104)\n \n # EXC0009 gosec: Too many issues in popular repos\n - (Expect directory permissions to be 0750 or less|Expect file permissions to be 0600 or less)\n \n # EXC0010 gosec: False positive is triggered by 'src, err := ioutil.ReadFile(filename)'\n - Potential file inclusion via variable\n \n # EXC0011 stylecheck: Annoying issue about not having a comment. The rare codebase has such comments\n - (comment on exported (method|function|type|const)|should have( a package)? comment|comment should be of the form)\n \n # EXC0012 revive: Annoying issue about not having a comment. The rare codebase has such comments\n - exported (.+) should have comment( \\(or a comment on this block\\))? or be unexported\n \n # EXC0013 revive: Annoying issue about not having a comment. The rare codebase has such comments\n - package comment should be of the form \"(.+)...\n \n # EXC0014 revive: Annoying issue about not having a comment. The rare codebase has such comments\n - comment on exported (.+) should be of the form \"(.+)...\"\n \n # EXC0015 revive: Annoying issue about not having a comment. The rare codebase has such comments\n - should have a package comment\n (default true)\n --exclude-case-sensitive If set to true exclude and exclude rules regular expressions are case-sensitive\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 --exclude-files strings Regexps of files to exclude\n --exclude-dirs strings Regexps of directories to exclude\n --exclude-dirs-use-default Use or not use default excluded directories:\n - (^|/)vendor($|/)\n - (^|/)third_party($|/)\n - (^|/)testdata($|/)\n - (^|/)examples($|/)\n - (^|/)Godeps($|/)\n - (^|/)builtin($|/)\n (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 --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" + "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 [fast: false, auto-fix: false]\ngosimple: Linter for Go source code that specializes in simplifying code [fast: false, auto-fix: false]\ngovet: Vet examines Go source code and reports suspicious constructs. It is roughly the same as 'go vet' and uses its passes. [fast: false, auto-fix: false]\nineffassign: Detects when assignments to existing variables are not used [fast: true, auto-fix: false]\nstaticcheck: It's a set of rules from staticcheck. It's not the same thing as the staticcheck binary. The author of staticcheck doesn't support or approve the use of staticcheck as a library inside golangci-lint. [fast: false, auto-fix: false]\nunused: Checks Go code for unused constants, variables, functions and types [fast: false, auto-fix: false]", + "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 -D, --disable strings Disable specific linter\n --disable-all Disable all linters\n -E, --enable strings Enable specific linter\n --enable-all Enable all linters\n --fast Enable only fast linters from enabled linters set (first run won't be fast)\n -p, --presets strings Enable presets (bugs|comment|complexity|error|format|import|metalinter|module|performance|sql|style|test|unused) of linters.\n Run 'golangci-lint help linters' to see them.\n This option implies option --disable-all\n --enable-only strings Override linters configuration section to only run the specific linter(s)\n -j, --concurrency int Number of CPUs to use (Default: number of logical CPUs) (default 8)\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 --go string Targeted Go version\n --build-tags strings Build tags\n --timeout duration Timeout for total work (default 1m0s)\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 --out-format string Formats of output: json|line-number|colored-line-number|tab|colored-tab|checkstyle|code-climate|html|junit-xml|github-actions|teamcity (default \"colored-line-number\")\n --print-issued-lines Print lines of code with issue (default true)\n --print-linter-name Print linter name in issue line (default true)\n --uniq-by-line Make issues output unique by line (default true)\n --sort-results Sort linter results\n --sort-order strings Sort order of linter results\n --path-prefix string Path prefix to add to output\n --show-stats Show statistics per linter\n -e, --exclude strings Exclude issue by regexp\n --exclude-use-default Use or not use default excludes:\n - EXC0001 (errcheck): Almost all programs ignore errors on these functions and in most cases it's ok.\n Pattern: 'Error return value of .((os\\.)?std(out|err)\\..*|.*Close|.*Flush|os\\.Remove(All)?|.*print(f|ln)?|os\\.(Un)?Setenv). is not checked'\n - EXC0002 (golint): Annoying issue about not having a comment. The rare codebase has such comments.\n Pattern: '(comment on exported (method|function|type|const)|should have( a package)? comment|comment should be of the form)'\n - EXC0003 (golint): False positive when tests are defined in package 'test'.\n Pattern: 'func name will be used as test\\.Test.* by other packages, and that stutters; consider calling this'\n - EXC0004 (govet): Common false positives.\n Pattern: '(possible misuse of unsafe.Pointer|should have signature)'\n - EXC0005 (staticcheck): Developers tend to write in C-style with an explicit 'break' in a 'switch', so it's ok to ignore.\n Pattern: 'SA4011'\n - EXC0006 (gosec): Too many false-positives on 'unsafe' usage.\n Pattern: 'G103: Use of unsafe calls should be audited'\n - EXC0007 (gosec): Too many false-positives for parametrized shell calls.\n Pattern: 'G204: Subprocess launched with variable'\n - EXC0008 (gosec): Duplicated errcheck checks.\n Pattern: 'G104'\n - EXC0009 (gosec): Too many issues in popular repos.\n Pattern: '(G301|G302|G307): Expect (directory permissions to be 0750|file permissions to be 0600) or less'\n - EXC0010 (gosec): False positive is triggered by 'src, err := ioutil.ReadFile(filename)'.\n Pattern: 'G304: Potential file inclusion via variable'\n - EXC0011 (stylecheck): Annoying issue about not having a comment. The rare codebase has such comments.\n Pattern: '(ST1000|ST1020|ST1021|ST1022)'\n - EXC0012 (revive): Annoying issue about not having a comment. The rare codebase has such comments.\n Pattern: 'exported (.+) should have comment( \\(or a comment on this block\\))? or be unexported'\n - EXC0013 (revive): Annoying issue about not having a comment. The rare codebase has such comments.\n Pattern: 'package comment should be of the form \"(.+)...\"'\n - EXC0014 (revive): Annoying issue about not having a comment. The rare codebase has such comments.\n Pattern: 'comment on exported (.+) should be of the form \"(.+)...\"'\n - EXC0015 (revive): Annoying issue about not having a comment. The rare codebase has such comments.\n Pattern: 'should have a package comment' (default true)\n --exclude-case-sensitive If set to true exclude and exclude rules regular expressions are case-sensitive\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 --exclude-files strings Regexps of files to exclude\n --exclude-dirs strings Regexps of directories to exclude\n --exclude-dirs-use-default Use or not use default excluded directories:\n - (^|/)vendor($|/)\n - (^|/)third_party($|/)\n - (^|/)testdata($|/)\n - (^|/)examples($|/)\n - (^|/)Godeps($|/)\n - (^|/)builtin($|/)\n (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 --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" } diff --git a/assets/default-exclusions.json b/assets/default-exclusions.json index 93f096dd6c5f..5b985e5496a0 100644 --- a/assets/default-exclusions.json +++ b/assets/default-exclusions.json @@ -3,90 +3,90 @@ "id": "EXC0001", "pattern": "Error return value of .((os\\.)?std(out|err)\\..*|.*Close|.*Flush|os\\.Remove(All)?|.*print(f|ln)?|os\\.(Un)?Setenv). is not checked", "linter": "errcheck", - "why": "Almost all programs ignore errors on these functions and in most cases it's ok" + "why": "Almost all programs ignore errors on these functions and in most cases it's ok." }, { "id": "EXC0002", "pattern": "(comment on exported (method|function|type|const)|should have( a package)? comment|comment should be of the form)", "linter": "golint", - "why": "Annoying issue about not having a comment. The rare codebase has such comments" + "why": "Annoying issue about not having a comment. The rare codebase has such comments." }, { "id": "EXC0003", "pattern": "func name will be used as test\\.Test.* by other packages, and that stutters; consider calling this", "linter": "golint", - "why": "False positive when tests are defined in package 'test'" + "why": "False positive when tests are defined in package 'test'." }, { "id": "EXC0004", "pattern": "(possible misuse of unsafe.Pointer|should have signature)", "linter": "govet", - "why": "Common false positives" + "why": "Common false positives." }, { "id": "EXC0005", - "pattern": "ineffective break statement. Did you mean to break out of the outer loop", + "pattern": "SA4011", "linter": "staticcheck", - "why": "Developers tend to write in C-style with an explicit 'break' in a 'switch', so it's ok to ignore" + "why": "Developers tend to write in C-style with an explicit 'break' in a 'switch', so it's ok to ignore." }, { "id": "EXC0006", - "pattern": "Use of unsafe calls should be audited", + "pattern": "G103: Use of unsafe calls should be audited", "linter": "gosec", - "why": "Too many false-positives on 'unsafe' usage" + "why": "Too many false-positives on 'unsafe' usage." }, { "id": "EXC0007", - "pattern": "Subprocess launch(ed with variable|ing should be audited)", + "pattern": "G204: Subprocess launched with variable", "linter": "gosec", - "why": "Too many false-positives for parametrized shell calls" + "why": "Too many false-positives for parametrized shell calls." }, { "id": "EXC0008", - "pattern": "(G104)", + "pattern": "G104", "linter": "gosec", - "why": "Duplicated errcheck checks" + "why": "Duplicated errcheck checks." }, { "id": "EXC0009", - "pattern": "(Expect directory permissions to be 0750 or less|Expect file permissions to be 0600 or less)", + "pattern": "(G301|G302|G307): Expect (directory permissions to be 0750|file permissions to be 0600) or less", "linter": "gosec", - "why": "Too many issues in popular repos" + "why": "Too many issues in popular repos." }, { "id": "EXC0010", - "pattern": "Potential file inclusion via variable", + "pattern": "G304: Potential file inclusion via variable", "linter": "gosec", - "why": "False positive is triggered by 'src, err := ioutil.ReadFile(filename)'" + "why": "False positive is triggered by 'src, err := ioutil.ReadFile(filename)'." }, { "id": "EXC0011", - "pattern": "(comment on exported (method|function|type|const)|should have( a package)? comment|comment should be of the form)", + "pattern": "(ST1000|ST1020|ST1021|ST1022)", "linter": "stylecheck", - "why": "Annoying issue about not having a comment. The rare codebase has such comments" + "why": "Annoying issue about not having a comment. The rare codebase has such comments." }, { "id": "EXC0012", "pattern": "exported (.+) should have comment( \\(or a comment on this block\\))? or be unexported", "linter": "revive", - "why": "Annoying issue about not having a comment. The rare codebase has such comments" + "why": "Annoying issue about not having a comment. The rare codebase has such comments." }, { "id": "EXC0013", - "pattern": "package comment should be of the form \"(.+)...", + "pattern": "package comment should be of the form \"(.+)...\"", "linter": "revive", - "why": "Annoying issue about not having a comment. The rare codebase has such comments" + "why": "Annoying issue about not having a comment. The rare codebase has such comments." }, { "id": "EXC0014", "pattern": "comment on exported (.+) should be of the form \"(.+)...\"", "linter": "revive", - "why": "Annoying issue about not having a comment. The rare codebase has such comments" + "why": "Annoying issue about not having a comment. The rare codebase has such comments." }, { "id": "EXC0015", "pattern": "should have a package comment", "linter": "revive", - "why": "Annoying issue about not having a comment. The rare codebase has such comments" + "why": "Annoying issue about not having a comment. The rare codebase has such comments." } ] diff --git a/assets/linters-info.json b/assets/linters-info.json index b7f7d0ff720c..44e6befd3de6 100644 --- a/assets/linters-info.json +++ b/assets/linters-info.json @@ -49,6 +49,18 @@ "isSlow": true, "since": "v1.18.0" }, + { + "name": "canonicalheader", + "desc": "canonicalheader checks whether net/http.Header uses canonical header", + "loadMode": 575, + "inPresets": [ + "style" + ], + "originalURL": "https://github.com/lasiar/canonicalHeader", + "internal": false, + "isSlow": true, + "since": "v1.58.0" + }, { "name": "containedctx", "desc": "containedctx is a linter that detects struct contained context.Context field", @@ -110,23 +122,6 @@ "isSlow": false, "since": "v1.44.0" }, - { - "name": "deadcode", - "desc": "Deprecated", - "loadMode": 575, - "inPresets": [ - "unused" - ], - "originalURL": "https://github.com/remyoudompheng/go-misc/tree/master/deadcode", - "internal": false, - "isSlow": true, - "since": "v1.0.0", - "deprecation": { - "since": "v1.49.0", - "message": "The owner seems to have abandoned the linter.", - "replacement": "unused" - } - }, { "name": "depguard", "desc": "Go linter that checks if package imports are in a list of acceptable packages", @@ -247,10 +242,14 @@ "inPresets": [ "sql" ], - "originalURL": "https://github.com/lufeee/execinquery", + "originalURL": "https://github.com/1uf3/execinquery", "internal": false, "isSlow": true, - "since": "v1.46.0" + "since": "v1.46.0", + "deprecation": { + "since": "v1.58.0", + "message": "The repository of the linter has been archived by the owner." + } }, { "name": "exhaustive", @@ -264,24 +263,6 @@ "isSlow": true, "since": " v1.28.0" }, - { - "name": "exhaustivestruct", - "desc": "Deprecated", - "loadMode": 575, - "inPresets": [ - "style", - "test" - ], - "originalURL": "https://github.com/mbilski/exhaustivestruct", - "internal": false, - "isSlow": true, - "since": "v1.32.0", - "deprecation": { - "since": "v1.46.0", - "message": "The repository of the linter has been deprecated by the owner.", - "replacement": "exhaustruct" - } - }, { "name": "exhaustruct", "desc": "Checks if all structure fields are initialized", @@ -331,6 +312,18 @@ "isSlow": false, "since": "v1.38.0" }, + { + "name": "fatcontext", + "desc": "detects nested contexts in loops", + "loadMode": 575, + "inPresets": [ + "performance" + ], + "originalURL": "https://github.com/Crocmagnon/fatcontext", + "internal": false, + "isSlow": true, + "since": "1.58.0" + }, { "name": "funlen", "desc": "Tool for detection of long functions", @@ -494,13 +487,16 @@ "since": "v1.19.0" }, { - "name": "goerr113", + "name": "err113", "desc": "Go linter to check the errors handling expressions", "loadMode": 575, "inPresets": [ "style", "error" ], + "alternativeNames": [ + "goerr113" + ], "originalURL": "https://github.com/Djarvur/go-err113", "internal": false, "isSlow": true, @@ -560,21 +556,16 @@ "since": "v1.20.0" }, { - "name": "golint", - "desc": "Deprecated", - "loadMode": 575, + "name": "mnd", + "desc": "An analyzer to detect magic numbers.", + "loadMode": 7, "inPresets": [ "style" ], - "originalURL": "https://github.com/golang/lint", + "originalURL": "https://github.com/tommy-muehle/go-mnd", "internal": false, - "isSlow": true, - "since": "v1.0.0", - "deprecation": { - "since": "v1.41.0", - "message": "The repository of the linter has been archived by the owner.", - "replacement": "revive" - } + "isSlow": false, + "since": "v1.22.0" }, { "name": "gomnd", @@ -586,7 +577,12 @@ "originalURL": "https://github.com/tommy-muehle/go-mnd", "internal": false, "isSlow": false, - "since": "v1.22.0" + "since": "v1.22.0", + "deprecation": { + "since": "v1.58.0", + "message": "The linter has been renamed.", + "replacement": "mnd" + } }, { "name": "gomoddirectives", @@ -700,22 +696,6 @@ "isSlow": false, "since": "v1.44.0" }, - { - "name": "ifshort", - "desc": "Deprecated", - "loadMode": 7, - "inPresets": [ - "style" - ], - "originalURL": "https://github.com/esimonov/ifshort", - "internal": false, - "isSlow": false, - "since": "v1.36.0", - "deprecation": { - "since": "v1.48.0", - "message": "The repository of the linter has been deprecated by the owner." - } - }, { "name": "importas", "desc": "Enforces consistent import aliases", @@ -765,22 +745,6 @@ "isSlow": false, "since": "v1.49.0" }, - { - "name": "interfacer", - "desc": "Deprecated", - "loadMode": 575, - "inPresets": [ - "style" - ], - "originalURL": "https://github.com/mvdan/interfacer", - "internal": false, - "isSlow": true, - "since": "v1.0.0", - "deprecation": { - "since": "v1.38.0", - "message": "The repository of the linter has been archived by the owner." - } - }, { "name": "intrange", "desc": "intrange is a linter to find places where for loops could make use of an integer range.", @@ -854,23 +818,6 @@ "isSlow": true, "since": "v1.34.0" }, - { - "name": "maligned", - "desc": "Deprecated", - "loadMode": 575, - "inPresets": [ - "performance" - ], - "originalURL": "https://github.com/mdempsky/maligned", - "internal": false, - "isSlow": true, - "since": "v1.0.0", - "deprecation": { - "since": "v1.38.0", - "message": "The repository of the linter has been archived by the owner.", - "replacement": "govet 'fieldalignment'" - } - }, { "name": "mirror", "desc": "reports wrong mirror patterns of bytes/strings usage", @@ -996,23 +943,6 @@ "isSlow": true, "since": "v1.46.0" }, - { - "name": "nosnakecase", - "desc": "Deprecated", - "loadMode": 7, - "inPresets": [ - "style" - ], - "originalURL": "https://github.com/sivchari/nosnakecase", - "internal": false, - "isSlow": false, - "since": "v1.47.0", - "deprecation": { - "since": "v1.48.1", - "message": "The repository of the linter has been deprecated by the owner.", - "replacement": "revive 'var-naming'" - } - }, { "name": "nosprintfhostport", "desc": "Checks for misuse of Sprintf to construct a host with port in a URL.", @@ -1150,23 +1080,6 @@ "isSlow": true, "since": "v1.55.0" }, - { - "name": "scopelint", - "desc": "Deprecated", - "loadMode": 7, - "inPresets": [ - "bugs" - ], - "originalURL": "https://github.com/kyoh86/scopelint", - "internal": false, - "isSlow": false, - "since": "v1.12.0", - "deprecation": { - "since": "v1.39.0", - "message": "The repository of the linter has been deprecated by the owner.", - "replacement": "exportloopref" - } - }, { "name": "sqlclosecheck", "desc": "Checks that sql.Rows, sql.Stmt, sqlx.NamedStmt, pgx.Query are closed.", @@ -1209,23 +1122,6 @@ "isSlow": true, "since": "v1.0.0" }, - { - "name": "structcheck", - "desc": "Deprecated", - "loadMode": 575, - "inPresets": [ - "unused" - ], - "originalURL": "https://github.com/opennota/check", - "internal": false, - "isSlow": true, - "since": "v1.0.0", - "deprecation": { - "since": "v1.49.0", - "message": "The owner seems to have abandoned the linter.", - "replacement": "unused" - } - }, { "name": "stylecheck", "desc": "Stylecheck is a replacement for golint", @@ -1343,12 +1239,9 @@ "name": "typecheck", "desc": "Like the front-end of a Go compiler, parses and type-checks Go code", "enabledByDefault": true, - "loadMode": 575, - "inPresets": [ - "bugs" - ], + "loadMode": 7, "internal": true, - "isSlow": true, + "isSlow": false, "since": "v1.3.0" }, { @@ -1404,23 +1297,6 @@ "isSlow": false, "since": "v1.48.0" }, - { - "name": "varcheck", - "desc": "Deprecated", - "loadMode": 575, - "inPresets": [ - "unused" - ], - "originalURL": "https://github.com/opennota/check", - "internal": false, - "isSlow": true, - "since": "v1.0.0", - "deprecation": { - "since": "v1.49.0", - "message": "The owner seems to have abandoned the linter.", - "replacement": "unused" - } - }, { "name": "varnamelen", "desc": "checks that the length of a variable's name matches its scope", diff --git a/jsonschema/golangci.jsonschema.json b/jsonschema/golangci.jsonschema.json index 6e72616e8367..e7684df3f395 100644 --- a/jsonschema/golangci.jsonschema.json +++ b/jsonschema/golangci.jsonschema.json @@ -215,6 +215,7 @@ "asciicheck", "bidichk", "bodyclose", + "canonicalheader", "containedctx", "contextcheck", "copyloopvar", @@ -235,6 +236,7 @@ "exhaustivestruct", "exhaustruct", "exportloopref", + "fatcontext", "forbidigo", "forcetypeassert", "funlen", @@ -250,13 +252,12 @@ "gocyclo", "godot", "godox", - "goerr113", + "err113", "gofmt", "gofumpt", "goheader", "goimports", "golint", - "gomnd", "gomoddirectives", "gomodguard", "goprintffuncname", @@ -280,6 +281,7 @@ "maligned", "mirror", "misspell", + "mnd", "musttag", "nakedret", "nestif", @@ -748,16 +750,6 @@ "type": "boolean", "default": false }, - "ignore": { - "description": "DEPRECATED: use `exclude-functions` instead. Comma-separated list of pairs of the form \"pkg:regex\".", - "type": "string", - "default": "fmt:.*" - }, - "exclude": { - "description": "DEPRECATED: use `exclude-functions` instead. Path to a file containing a list of functions to exclude from checking.", - "type": "string", - "examples": ["/path/to/file.txt"] - }, "exclude-functions": { "description": "List of functions to exclude from checking, where each entry is a single function to exclude", "type": "array", @@ -811,6 +803,36 @@ "description": "Check for plain error comparisons", "type": "boolean", "default": true + }, + "allowed-errors": { + "type": "array", + "items": { + "type": "object", + "additionalProperties": false, + "properties": { + "err": { + "type": "string" + }, + "fun": { + "type": "string" + } + } + } + }, + "allowed-errors-wildcard": { + "type": "array", + "items": { + "type": "object", + "additionalProperties": false, + "properties": { + "err": { + "type": "string" + }, + "fun": { + "type": "string" + } + } + } } } }, @@ -960,16 +982,25 @@ "type": "object", "additionalProperties": false, "properties": { - "local-prefixes": { - "description": "DEPRECATED: use 'sections' and 'prefix(github.com/org/project)' instead.", - "type": "string", - "examples": ["github.com/org/project"] - }, "sections": { "description": "Section configuration to compare against.", "type": "array", "items": { - "type": "string" + "anyOf": [ + { + "enum": [ + "standard", + "default", + "blank", + "dot", + "alias", + "localmodule" + ] + }, + { + "type": "string" + } + ] }, "default": ["standard", "default"] }, @@ -1143,8 +1174,157 @@ "settings": { "description": "Settings passed to gocritic. Properties must be valid and enabled check names.", "type": "object", - "propertyNames": { - "$ref": "#/definitions/gocritic-checks" + "additionalProperties": false, + "properties": { + "captLocal": { + "type": "object", + "additionalProperties": false, + "properties": { + "paramsOnly" : { + "type": "boolean", + "default": true + } + } + }, + "commentedOutCode": { + "type": "object", + "additionalProperties": false, + "properties": { + "minLength" : { + "type": "number", + "default": 15 + } + } + }, + "elseif": { + "type": "object", + "additionalProperties": false, + "properties": { + "skipBalanced" : { + "type": "boolean", + "default": true + } + } + }, + "hugeParam": { + "type": "object", + "additionalProperties": false, + "properties": { + "sizeThreshold" : { + "type": "number", + "default": 80 + } + } + }, + "ifElseChain": { + "type": "object", + "additionalProperties": false, + "properties": { + "minThreshold" : { + "type": "number", + "default": 2 + } + } + }, + "nestingReduce": { + "type": "object", + "additionalProperties": false, + "properties": { + "bodyWidth" : { + "type": "number", + "default": 5 + } + } + }, + "rangeExprCopy": { + "type": "object", + "additionalProperties": false, + "properties": { + "sizeThreshold" : { + "type": "number", + "default": 512 + }, + "skipTestFuncs" : { + "type": "boolean", + "default": true + } + } + }, + "rangeValCopy": { + "type": "object", + "additionalProperties": false, + "properties": { + "sizeThreshold" : { + "type": "number", + "default": 128 + }, + "skipTestFuncs" : { + "type": "boolean", + "default": true + } + } + }, + "ruleguard": { + "type": "object", + "additionalProperties": false, + "properties": { + "debug" : { + "type": "string" + }, + "enable" : { + "type": "string" + }, + "disable" : { + "type": "string" + }, + "failOn" : { + "type": "string" + }, + "rules" : { + "type": "string" + } + } + }, + "tooManyResultsChecker": { + "type": "object", + "additionalProperties": false, + "properties": { + "maxResults" : { + "type": "number", + "default": 5 + } + } + }, + "truncateCmp": { + "type": "object", + "additionalProperties": false, + "properties": { + "skipArchDependent" : { + "type": "boolean", + "default": true + } + } + }, + "underef": { + "type": "object", + "additionalProperties": false, + "properties": { + "skipRecvDeref" : { + "type": "boolean", + "default": true + } + } + }, + "unnamedResult": { + "type": "object", + "additionalProperties": false, + "properties": { + "checkExported" : { + "type": "boolean", + "default": false + } + } + } } }, "disable-all": { @@ -1261,11 +1441,6 @@ "type": "boolean", "default": false }, - "lang-version": { - "description": "Select the Go version to target.", - "type": "string", - "default": "1.15" - }, "module-path": { "description": " Module path which contains the source code being formatted.", "type": "string" @@ -1343,50 +1518,6 @@ } } }, - "gomnd": { - "type": "object", - "additionalProperties": false, - "properties": { - "ignored-files": { - "description": "List of file patterns to exclude from analysis.", - "examples": [["magic1_.*.go"]], - "type": "array", - "items": { - "type": "string" - } - }, - "ignored-functions": { - "description": "Comma-separated list of function patterns to exclude from the analysis.", - "examples": [["math.*", "http.StatusText", "make"]], - "type": "array", - "items": { - "type": "string" - } - }, - "ignored-numbers": { - "description": "List of numbers to exclude from analysis.", - "examples": [["1000", "1234_567_890", "3.14159264"]], - "type": "array", - "items": { - "type": "string" - } - }, - "checks": { - "description": "The list of enabled checks, see https://github.com/tommy-muehle/go-mnd/#checks for description.", - "type": "array", - "items": { - "enum": [ - "argument", - "case", - "condition", - "operation", - "return", - "assign" - ] - } - } - } - }, "gomoddirectives": { "type": "object", "additionalProperties": false, @@ -1509,11 +1640,6 @@ "type": "object", "additionalProperties": false, "properties": { - "go": { - "description": "Targeted Go version", - "type": "string", - "default": "1.13" - }, "checks": { "type": "array", "items": { @@ -1976,6 +2102,50 @@ } } }, + "mnd": { + "type": "object", + "additionalProperties": false, + "properties": { + "ignored-files": { + "description": "List of file patterns to exclude from analysis.", + "examples": [["magic1_.*.go"]], + "type": "array", + "items": { + "type": "string" + } + }, + "ignored-functions": { + "description": "Comma-separated list of function patterns to exclude from the analysis.", + "examples": [["math.*", "http.StatusText", "make"]], + "type": "array", + "items": { + "type": "string" + } + }, + "ignored-numbers": { + "description": "List of numbers to exclude from analysis.", + "examples": [["1000", "1234_567_890", "3.14159264"]], + "type": "array", + "items": { + "type": "string" + } + }, + "checks": { + "description": "The list of enabled checks, see https://github.com/tommy-muehle/go-mnd/#checks for description.", + "type": "array", + "items": { + "enum": [ + "argument", + "case", + "condition", + "operation", + "return", + "assign" + ] + } + } + } + }, "nolintlint": { "type": "object", "additionalProperties": false, @@ -2274,10 +2444,10 @@ "type": "boolean", "default": true }, - "context-only": { + "context": { "description": "Enforce using methods that accept a context.", - "type": "boolean", - "default": false + "enum": ["", "all", "scope"], + "default": "" }, "static-msg": { "description": "Enforce using static values for log messages.", @@ -2322,6 +2492,13 @@ "items": { "type": "string" } + }, + "extra-start-span-signatures": { + "description": "A list of regexes for additional function signatures that create spans.", + "type": "array", + "items": { + "type": "string" + } } } }, @@ -2329,11 +2506,6 @@ "type": "object", "additionalProperties": false, "properties": { - "go": { - "description": "Targeted Go version", - "type": "string", - "default": "1.13" - }, "checks": { "type": "array", "items": { @@ -2353,11 +2525,6 @@ "type": "object", "additionalProperties": false, "properties": { - "go": { - "description": "Targeted Go version", - "type": "string", - "default": "1.13" - }, "checks": { "type": "array", "items": { @@ -2855,11 +3022,6 @@ "type": "boolean", "default": false }, - "os-dev-null": { - "description": "Suggest the use of os.DevNull.", - "type": "boolean", - "default": false - }, "sql-isolation-level": { "description": "Suggest the use of sql.LevelXX.String().", "type": "boolean", @@ -2874,11 +3036,6 @@ "description": "Suggest the use of constant.Kind.String().", "type": "boolean", "default": false - }, - "syslog-priority": { - "description": "Suggest the use of syslog.Priority.", - "type": "boolean", - "default": false } } }, @@ -3157,7 +3314,7 @@ "type": "object", "additionalProperties": false, "properties": { - "ignore-alias": { + "check-alias": { "type": "boolean", "default": false }