Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

errcheck doesn't detect all unchecked type assertion #882

Closed
3 tasks done
pierrre opened this issue Dec 6, 2019 · 1 comment · Fixed by #1319
Closed
3 tasks done

errcheck doesn't detect all unchecked type assertion #882

pierrre opened this issue Dec 6, 2019 · 1 comment · Fixed by #1319
Assignees
Labels
dependencies Relates to an upstream dependency false negative An error is not reported when one exists

Comments

@pierrre
Copy link
Contributor

pierrre commented Dec 6, 2019

Thank you for creating the issue!

  • Yes, I'm using a binary release within 2 latest major releases. Only such installations are supported.
  • Yes, I've searched similar issues on GitHub and didn't find any.
  • Yes, I've included all information below (version, config, etc).

Please include the following information:

Version of golangci-lint
$ golangci-lint --version
golangci-lint has version 1.21.0 built from 645e794 on 2019-10-15T18:16:56Z
Config file
$ cat .golangci.yml
run:
  timeout: "10m"
linters:
  disable-all: true
  enable:
    - "bodyclose"
    - "deadcode"
    - "depguard"
    - "errcheck"
    - "gocritic"
    - "gocyclo"
    - "gofmt"
    - "goimports"
    - "golint"
    - "govet"
    - "ineffassign"
    - "megacheck"
    - "misspell"
    - "nakedret"
    - "structcheck"
    - "unconvert"
    - "unparam"
    - "varcheck"
linters-settings:
  depguard:
    list-type: blacklist
    include-go-root: true
    packages:
      - errors
      - reflect
      - unsafe
      - github.com/pkg/errors
  errcheck:
    check-type-assertions: true
  gocyclo:
    min-complexity: 10
  govet:
    enable-all: true
issues:
  exclude-use-default: false
  max-issues-per-linter: 0
  max-same-issues: 0
Go environment
$ go version && go env
go version go1.13.5 linux/amd64
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/pierre/.cache/go-build"
GOENV="/home/pierre/.config/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/pierre/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/home/pierre/.gimme/versions/go1.13.5.src"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/home/pierre/.gimme/versions/go1.13.5.src/pkg/tool/linux_amd64"
GCCGO="gccgo"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/home/pierre/gosrc/github.com/xxx/yyy/go.mod"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build810139123=/tmp/go-build -gno-record-gcc-switches"
Verbose output of running
$ golangci-lint run -v
INFO [config_reader] Config search paths: [./ /home/pierre/gosrc/github.com/xxx/yyy /home/pierre/gosrc/github.com/xxx /home/pierre/gosrc/github.com /home/pierre/gosrc /home/pierre /home /] 
INFO [config_reader] Used config file .golangci.yml 
INFO [lintersdb] Active 20 linters: [bodyclose deadcode depguard errcheck gocritic gocyclo gofmt goimports golint gosimple govet ineffassign misspell nakedret staticcheck structcheck unconvert unparam unused varcheck] 
INFO [loader] Go packages loading at mode 575 (exports_file|imports|compiled_files|deps|files|name|types_sizes) took 235.781777ms 
INFO [runner/filename_unadjuster] Pre-built 0 adjustments in 24.339956ms 
INFO [runner/goanalysis_metalinter/goanalysis] analyzers took 25.433211455s with top 10 stages: buildssa: 9.13999065s, goimports: 1.69246075s, gofmt: 1.231308728s, unparam: 922.471835ms, golint: 834.866973ms, ineffassign: 768.164647ms, misspell: 738.716443ms, gocritic: 684.814951ms, SA4014: 671.62614ms, deadcode: 632.376094ms 
INFO [runner/unused/goanalysis] analyzers took 1.973672294s with top 10 stages: buildssa: 1.441568036s, U1000: 532.104258ms 
INFO [runner] Issues before processing: 18, after processing: 0 
INFO [runner] Processors filtering stat (out/in): filename_unadjuster: 18/18, identifier_marker: 18/18, exclude: 18/18, path_prettifier: 18/18, skip_files: 18/18, autogenerated_exclude: 18/18, nolint: 0/18, cgo: 18/18, skip_dirs: 18/18, exclude-rules: 18/18 
INFO [runner] processing took 5.717866ms with stages: nolint: 5.046802ms, path_prettifier: 242.312µs, identifier_marker: 211.745µs, autogenerated_exclude: 109.443µs, skip_dirs: 98.829µs, cgo: 4.679µs, filename_unadjuster: 1.501µs, max_same_issues: 683ns, skip_files: 281ns, diff: 255ns, max_from_linter: 241ns, uniq_by_line: 187ns, exclude-rules: 187ns, path_shortener: 185ns, max_per_file_from_linter: 182ns, source_code: 182ns, exclude: 172ns 
INFO [runner] linters took 3.431985751s with stages: goanalysis_metalinter: 2.888784135s, unused: 537.425552ms 
INFO File cache stats: 382 entries of total size 1.2MiB 
INFO Memory: 38 samples, avg is 368.0MB, max is 610.1MB 
INFO Execution took 3.696656595s

I've configured errcheck to report unchecked type assertion.
However, in this code:

if filter["messages_sent.messageid"].(map[string]interface{})["$ne"] != nil {

the type assertion is not checked, but it's not reported.
filter is a bson.M from github.com/globalsign/mgo/bson.

@tpounds tpounds added false negative An error is not reported when one exists dependencies Relates to an upstream dependency labels Dec 30, 2019
@SVilgelm SVilgelm self-assigned this Aug 4, 2020
@SVilgelm SVilgelm linked a pull request Aug 18, 2020 that will close this issue
@pierrre
Copy link
Contributor Author

pierrre commented Feb 25, 2021

thank you ! 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dependencies Relates to an upstream dependency false negative An error is not reported when one exists
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants