Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Warning for option that has not been set (linters.errcheck.ignore) #4733

Closed
5 tasks done
ping-localhost opened this issue May 20, 2024 · 7 comments · Fixed by #4734
Closed
5 tasks done

Warning for option that has not been set (linters.errcheck.ignore) #4733

ping-localhost opened this issue May 20, 2024 · 7 comments · Fixed by #4734
Assignees
Labels
bug Something isn't working

Comments

@ping-localhost
Copy link

ping-localhost commented May 20, 2024

Welcome

Description of the problem

My current configuration warns be for something that hasn't been set.

The configuration option linters.errcheck.ignore is deprecated, please use linters.errcheck.exclude-functions.

Version of golangci-lint

golangci-lint has version 1.58.2 built with go1.22.3 from 8c4cfb61 on 2024-05-19T18:08:33Z

Configuration

# options for analysis running
linters-settings:
  dogsled:
    # checks assignments with too many blank identifiers
    max-blank-identifiers: 2

  errcheck:
    # report about not checking of errors in type assertions: `a := b.(MyStruct)`;
    check-type-assertions: true
    # report about assignment of errors to blank identifier: `num, _ := strconv.Atoi(numStr)`;
    check-blank: true

  gci:
    # Section configuration to compare against.
    sections:
      - standard # Standard section: captures all standard packages.
      - default # Default section: contains all imports that could not be matched to another section type.
      - prefix(github.com/ping-localhost/foobar) # Custom section: groups all imports with the specified Prefix.
      - 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.
    # Skip generated files.
    skip-generated: true
    # Enable custom order of sections.
    custom-order: true

  goconst:
    # minimal length of string constant
    min-len: 3
    # minimal occurrences count to trigger
    min-occurrences: 3

  gocritic:
    # Enable multiple checks by tags, run `GL_DEBUG=gocritic golangci-lint run` to see all tags and checks.
    # Empty list by default. See https://github.com/go-critic/go-critic#usage -> section "Tags".
    enabled-tags:
      - performance
      - style
      - experimental
    disabled-checks:
      - ifElseChain
      - typeAssertChain
      - unnamedResult
      - sloppyReassign

  gofmt:
    # simplify code: gofmt with `-s` option
    simplify: true

  goimports:
    # put imports beginning with prefix after 3rd-party packages;
    local-prefixes: github.com/foobar

  govet:
    # enable or disable analyzers by name
    enable-all: true
    disable: [ fieldalignment, shadow ]

  maintidx:
    # Show functions with maintainability index lower than N.
    # A high index indicates better maintainability (it's kind of the opposite of complexity).
    # Default: 20
    under: 15

  nakedret:
    # make an issue if func has more lines of code than this setting and it has naked returns; default is 30
    max-func-lines: 30

  prealloc:
    # Report pre-allocation suggestions only on simple loops that have no returns/breaks/continues/goto's in them.
    simple: true
    # Report pre-allocation suggestions on range loops
    range-loops: true
    # Report pre-allocation suggestions on for loops
    for-loops: true

  revive:
    # When set to false, ignores files with "GENERATED" header, similar to golint.
    # See https://github.com/mgechev/revive#available-rules for details.
    ignore-generated-header: true
    severity: warning

  stylecheck:
    # STxxxx checks in https://staticcheck.io/docs/configuration/options/#checks
    checks: [ "all", "-ST1003" ]
    # https://staticcheck.io/docs/configuration/options/#dot_import_whitelist
    dot-import-whitelist: [ ]
    # https://staticcheck.io/docs/configuration/options/#initialisms
    initialisms: [ ]
    # https://staticcheck.io/docs/configuration/options/#http_status_code_whitelist
    http-status-code-whitelist: [ "200", "400", "404", "500" ]

linters:
  disable-all: true
  enable:
    - asciicheck
    - bidichk
    - bodyclose
    - decorder
    - dogsled
    - dupword
    - errcheck
    - errchkjson
    - errorlint
    - exportloopref
    - forcetypeassert
    - gci
    - gochecknoglobals
    - gochecknoinits
    - goconst
    - gocritic
    - godot
    - gofmt
    - gofumpt
    - goheader
    - goimports
    - gomoddirectives
    - gomodguard
    - goprintffuncname
    - gosec
    - gosimple
    - govet
    - grouper
    - ineffassign
    - loggercheck
    - maintidx
    - makezero
    - nakedret
    - nolintlint
    - nonamedreturns
    - prealloc
    - predeclared
    - reassign
    - revive
    - staticcheck
    - stylecheck
    - tenv
    - testpackage
    - thelper
    - typecheck
    - unconvert
    - unparam
    - unused
    - usestdlibvars
    - whitespace

issues:
  # Show only new issues: if there are unstaged changes or untracked files,
  # only those changes are analyzed, else only changes in HEAD~ are analyzed.
  # It's a super-useful option for integration of golangci-lint into existing large codebase.
  # It's not practical to fix all existing issues at the moment of integration:
  # much better don't allow issues in new code.
  new: false

  # Which dirs to exclude: issues from them won't be reported.
  # Can use regexp here: `generated.*`, regexp is applied on full path,
  # including the path prefix if one is set.
  # Default dirs are skipped independently of this option's value (see exclude-dirs-use-default).
  # "/" will be replaced by current OS file path separator to properly work on Windows.
  exclude-dirs:
    - test/mocks/
    - static/
    - web/

  # Excluding configuration per-path, per-linter, per-text and per-source
  exclude-rules:
    # Exclude some linters from running on tests files
    - path: _test\.go
      linters:
        - forcetypeassert
        - maintidx
        - scopelint
        - unused
        - dupword

    - path: _test\.go
      linters: [ govet ]
      text: unusedwrite

# output configuration options
output:
  # The formats used to render issues.
  # Format: `colored-line-number`, `line-number`, `json`, `colored-tab`, `tab`, `checkstyle`, `code-climate`, `junit-xml`, `github-actions`, `teamcity`
  # Output path can be either `stdout`, `stderr` or path to the file to write to.
  #
  # For the CLI flag (`--out-format`), multiple formats can be specified by separating them by comma.
  # The output can be specified for each of them by separating format name and path by colon symbol.
  # Example: "--out-format=checkstyle:report.xml,json:stdout,colored-line-number"
  # The CLI flag (`--out-format`) override the configuration file.
  #
  # Default:
  #   formats:
  #     - format: colored-line-number
  #       path: stdo
  formats: [ { format: colored-line-number } ]

  # Print lines of code with issue.
  print-issued-lines: false

  # Print linter name in the end of issue text.
  print-linter-name: true

Go environment

go version go1.22.2 darwin/arm64
GO111MODULE='on'
GOARCH='arm64'
GOBIN=''
GOCACHE='/Users/ping-localhost/Library/Caches/go-build'
GOENV='/Users/ping-localhost/Library/Application Support/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='arm64'
GOHOSTOS='darwin'
GOINSECURE=''
GOMODCACHE='/Users/ping-localhost/go/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='darwin'
GOPATH='/Users/ping-localhost/go'
GOPRIVATE=''
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/Users/ping-localhost/go/pkg/mod/golang.org/toolchain@v0.0.1-go1.22.2.darwin-arm64'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/Users/ping-localhost/go/pkg/mod/golang.org/toolchain@v0.0.1-go1.22.2.darwin-arm64/pkg/tool/darwin_arm64'
GOVCS=''
GOVERSION='go1.22.2'
GCCGO='gccgo'
AR='ar'
CC='clang'
CXX='clang++'
CGO_ENABLED='1'
GOMOD='/Users/ping-localhost/go/src/github.com/ping-localhost/foobar/go.mod'
GOWORK=''
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
PKG_CONFIG='pkg-config'
GOGCCFLAGS='-fPIC -arch arm64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -ffile-prefix-map=/var/folders/c6/4l4ylj_530z56dccw0b7_pq00000gn/T/go-build3048698457=/tmp/go-build -gno-record-gcc-switches -fno-common'

Verbose output of running

[11:23:12]foobar git:(master) golangci-lint cache clean                                             

[11:25:01]foobar git:(master) golangci-lint run -v     

INFO [config_reader] Config search paths: [./ /Users/ping-localhost/go/src/github.com/ping-localhost/foobar /Users/ping-localhost/go/src/github.com/ping-localhost /Users/ping-localhost/go/src/github.com /Users/ping-localhost/go/src /Users/ping-localhost/go /Users/ping-localhost /Users /] 
INFO [config_reader] Used config file .golangci.yml 
WARN [config_reader] The configuration option `linters.errcheck.ignore` is deprecated, please use `linters.errcheck.exclude-functions`. 
INFO [lintersdb] Active 49 linters: [asciicheck bidichk bodyclose decorder dogsled dupword errcheck errchkjson errorlint exportloopref forcetypeassert gci gochecknoglobals gochecknoinits goconst gocritic godot gofmt gofumpt goheader goimports gomoddirectives gomodguard goprintffuncname gosec gosimple govet grouper ineffassign loggercheck maintidx makezero nakedret nolintlint nonamedreturns prealloc predeclared reassign revive staticcheck stylecheck tenv testpackage thelper unconvert unparam unused usestdlibvars whitespace] 
INFO [loader] Go packages loading at mode 575 (deps|exports_file|files|imports|name|compiled_files|types_sizes) took 302.132083ms 
INFO [runner/filename_unadjuster] Pre-built 0 adjustments in 585.25µs 
INFO [linters_context/goanalysis] analyzers took 1.030545088s with top 10 stages: buildir: 423.498086ms, gocritic: 294.018708ms, ctrlflow: 31.369291ms, findcall: 28.067248ms, nilness: 27.704503ms, printf: 26.790789ms, the_only_name: 23.852917ms, SA5012: 23.430959ms, fact_purity: 23.104169ms, fact_deprecated: 22.191794ms 
INFO [runner] processing took 1.125µs with stages: max_same_issues: 292ns, skip_dirs: 166ns, nolint: 125ns, max_from_linter: 83ns, max_per_file_from_linter: 42ns, cgo: 42ns, path_prettifier: 42ns, sort_results: 42ns, path_shortener: 42ns, severity-rules: 42ns, uniq_by_line: 42ns, filename_unadjuster: 42ns, identifier_marker: 41ns, exclude-rules: 41ns, source_code: 41ns, invalid_issue: 0s, path_prefixer: 0s, diff: 0s, autogenerated_exclude: 0s, skip_files: 0s, fixer: 0s, exclude: 0s 
INFO [runner] linters took 1.115722042s with stages: goanalysis_metalinter: 1.115695125s 
INFO File cache stats: 0 entries of total size 0B 
INFO Memory: 16 samples, avg is 128.8MB, max is 244.3MB 
INFO Execution took 1.424589917s    

A minimal reproducible example or link to a public repository

https://github.com/ping-localhost/foobar

Validation

  • Yes, I've included all information above (version, config, etc.).
@ping-localhost ping-localhost added the bug Something isn't working label May 20, 2024
Copy link

boring-cyborg bot commented May 20, 2024

Hey, thank you for opening your first Issue ! 🙂 If you would like to contribute we have a guide for contributors.

@ping-localhost
Copy link
Author

Also happens when I disable all linters. I have no further mentions of ignore in my config.

@Tadimsky
Copy link

Seeing the same here.

Looks like it's being set by default here:

@ldez ldez self-assigned this May 20, 2024
@ldez
Copy link
Member

ldez commented May 20, 2024

I created a PR to fix that.

As a workaround, you should explicitly set ignore to an empty value:

linters-settings:
  errcheck:
    ignore : ""

@yangyile1990

This comment has been minimized.

@ping-localhost

This comment was marked as off-topic.

@ldez

This comment was marked as off-topic.

HenryQW added a commit to RSS3-Network/Node that referenced this issue May 20, 2024
KyleJu added a commit to web-platform-tests/wpt.fyi that referenced this issue May 21, 2024
KyleJu added a commit to web-platform-tests/wpt.fyi that referenced this issue May 21, 2024
* Temporary workaround for linter err

golangci/golangci-lint#4733

* Update Makefile

* Update Makefile

* Update backfill.go
CommanderStorm added a commit to TUM-Dev/Campus-Backend that referenced this issue Aug 5, 2024
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants