Skip to content

Error checking when the client is closed is not captured #609

Closed
@zhqqqy

Description

@zhqqqy

Thank you for creating the issue!

Please include the following information:

  1. golangci-lint has version 1.17.1
  2. no config
  3. go version go1.12.5 darwin/amd64

my code is

func main() {
    c := newKvClient("")
    c.Close()
}

func newKvClient(addr string) *redis.Client {
    client := redis.NewClient(&redis.Options{
        Addr: addr,
    })
     client.Ping().Result()

    return client
}
  1. Verbose output of running: golangci-lint run -v

INFO [config_reader] Config search paths: [./ /Users/zhaohq/go/src/sonargo-test /Users/zhaohq/go/src /Users/zhaohq/go /Users/zhaohq /Users /]
INFO [lintersdb] Active 10 linters: [deadcode errcheck gosimple govet ineffassign staticcheck structcheck typecheck unused varcheck]
INFO [lintersdb] Optimized sublinters [staticcheck gosimple unused] into metalinter megacheck
INFO [loader] Go packages loading at mode load types and syntax took 1.470327816s
INFO [loader] SSA repr building timing: packages building 9.962618ms, total 101.292279ms
INFO [runner] worker.4 took 923.948µs with stages: structcheck: 322.505µs, varcheck: 299.842µs, deadcode: 281.891µs, typecheck: 10.47µs
INFO [runner] worker.1 took 1.613303ms with stages: errcheck: 911.329µs, ineffassign: 525.108µs
main.go:21:26: Error return value of (*github.com/go-redis/redis.StatusCmd).Result is not checked (errcheck)
client.Ping().Result()
^
INFO [runner] worker.3 took 271.552451ms with stages: govet: 271.546439ms
INFO [runner] worker.2 took 760.285582ms with stages: megacheck: 760.264137ms
INFO [runner] Workers idle times: #1: 758.658684ms, #3: 488.723978ms, #4: 759.063965ms
INFO [runner] Issues before processing: 2, after processing: 1
INFO [runner] processing took 181.582759ms with stages: nolint: 119.140907ms, source_code: 59.228038ms, exclude: 2.194487ms, skip_dirs: 506.979µs, cgo: 350.218µs, identifier_marker: 90.421µs, autogenerated_exclude: 45.13µs, max_same_issues: 7.018µs, uniq_by_line: 4.952µs, path_prettifier: 4.288µs, path_shortener: 3.108µs, max_from_linter: 2.814µs, filename_unadjuster: 1.449µs, max_per_file_from_linter: 1.148µs, diff: 779ns, exclude-rules: 588ns, skip_files: 435ns
INFO File cache stats: 1 entries of total size 333B
INFO Memory: 27 samples, avg is 198.2MB, max is 406.0MB
INFO Execution took 2.542864033s

But the return value of c.Close() error is not checked. just checked client.Ping().Result()

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions