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 issue isn't reported #657

Closed
ferhatelmas opened this issue Sep 3, 2019 · 4 comments
Closed

errcheck issue isn't reported #657

ferhatelmas opened this issue Sep 3, 2019 · 4 comments
Labels
bug Something isn't working dependencies Relates to an upstream dependency false negative An error is not reported when one exists

Comments

@ferhatelmas
Copy link
Contributor

It is expected to get an errcheck lint error in the following program.
errcheck reports but golangci-lint doesn't.

package main

import (
	"fmt"
	"os"
)

func main() {
	os.Setenv("test", "some_value")
	fmt.Println("no lint error")
}

Please include the following information:

  1. Version of golangci-lint:
    1.17.1

  2. Config file: cat .golangci.yml
    https://gist.github.com/ferhatelmas/62bbfdb744316f24a9d207c5bac0bcf7

  3. Go environment: go version && go env
    https://gist.github.com/ferhatelmas/d85e9c6dc8ce7850da37e641c87f283f

  4. Verbose output of running: golangci-lint run -v
    https://gist.github.com/ferhatelmas/4b92c91cff8456d21084494c849970f7

@tpounds tpounds added bug Something isn't working false negative An error is not reported when one exists labels Sep 24, 2019
@tpounds tpounds added the dependencies Relates to an upstream dependency label Oct 6, 2019
@stale
Copy link

stale bot commented Apr 3, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale No recent correspondence or work activity label Apr 3, 2020
@JohnStarich
Copy link
Contributor

Poking this issue to keep it open. I’m also having this issue

@stale stale bot removed the stale No recent correspondence or work activity label Apr 4, 2020
@cjkreklow
Copy link
Contributor

This looks like the expected behavior of exclusion EXC0001:

[~/tmp] [pts/0]% golangci-lint run --help
...
      --exclude-use-default            Use or not use default excludes:
                                         # EXC0001 errcheck: Almost all programs ignore errors on these functions and in most cases it's ok
                                         - Error return value of .((os\.)?std(out|err)\..*|.*Close|.*Flush|os\.Remove(All)?|.*printf?|os\.(Un)?Setenv). is not checked

Running with option --exclude-use-default=false shows the error on os.Setenv:

[~/tmp] [pts/0]% golangci-lint run --exclude-use-default=false main.go
main.go:9:11: Error return value of `os.Setenv` is not checked (errcheck)
        os.Setenv("test", "some_value")

You can also just re-include EXC0001 in .golangci.yml:

issues:
  include:
    - EXC0001

It looks like errcheck itself excludes the check on fmt.Print*.

@ernado
Copy link
Member

ernado commented May 12, 2020

Please re-include EXC0001 for this check.
Closing for now.

@ernado ernado closed this as completed May 12, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working dependencies Relates to an upstream dependency false negative An error is not reported when one exists
Projects
None yet
Development

No branches or pull requests

5 participants