Skip to content

nolint for function and for line #106

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

Closed
rekby opened this issue Jun 14, 2018 · 2 comments
Closed

nolint for function and for line #106

rekby opened this issue Jun 14, 2018 · 2 comments
Labels
area: nolint Related to nolint directive and nolintlint bug Something isn't working

Comments

@rekby
Copy link

rekby commented Jun 14, 2018

for code:

package main

import (
	"bytes"
	"io"
)

//nolint:gas
func main() {
	var buf io.Writer = &bytes.Buffer{}
	//nolint:errcheck
	buf.Write([]byte("123"))
}

I have error errcheck

golangci-lint run
main.go:12:11: Error return value of `buf.Write` is not checked (errcheck)
        buf.Write([]byte("123"))

Expected no errors:

Congrats! No issues were found.
@jirfag jirfag added the bug Something isn't working label Jun 14, 2018
golangci pushed a commit that referenced this issue Jun 16, 2018
@jirfag
Copy link
Contributor

jirfag commented Jun 16, 2018

@rekby thank you! cool bug :)
@alecthomas FYI gometalinter has the same bug:

~/go/src/github.com/golangci/golangci-lint (master *)$ cat test.go
package testdata

import (
  "bytes"
  "io"
)

func noTransitiveExpanding() {
  //nolint:errcheck
  var buf io.Writer = &bytes.Buffer{}
  buf.Write([]byte("123"))
}
~/go/src/github.com/golangci/golangci-lint (support/fix-nolint-transitive-expanding)$ gometalinter --disable-all -E errcheck test.go
~/go/src/github.com/golangci/golangci-lint (support/fix-nolint-transitive-expanding)$ golangci-lint run --disable-all -E errcheck --no-config test.go
test.go:11:12: Error return value of `buf.Write` is not checked (errcheck)
  buf.Write([]byte("123"))
           ^

@jirfag jirfag closed this as completed in 9fa9e2b Jun 16, 2018
@septs
Copy link

septs commented Sep 21, 2020

edge cases:

var buf bytes.Buffer
binary.Write(&buf, binary.BigEndian, ....)
v.WriteTo(&buf) // v is `io.WriterTo`
// etc

@ldez ldez added the area: nolint Related to nolint directive and nolintlint label Mar 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: nolint Related to nolint directive and nolintlint bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants