8000 Detect returning nil after `err != nil` check · Issue #863 · dominikh/go-tools · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
Detect returning nil after err != nil check #863
Open
@ilinum

Description

@ilinum

I would like staticcheck to detect the following:

func foo() error {
  ...
  err := bar()
  if err != nil {
    return nil // BUG! Most of the time it should be `return err`
  }
  ...
}

Sometimes, of course, you want to explicitly return an error there, so this check will have quite a few false positives.
Most of the time, however, it will detect bugs.

Metadata

Metadata

Assignees

No one assigned

    Labels

    aggressiveA set of checks that is more prone to false positives but is helpful during code reviewnew-check

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0