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

Wrong line numbers reported breaking nolint #8

Open
stevenh opened this issue Jul 6, 2017 · 0 comments
Open

Wrong line numbers reported breaking nolint #8

stevenh opened this issue Jul 6, 2017 · 0 comments

Comments

@stevenh
Copy link

stevenh commented Jul 6, 2017

If you have an unused constant which is tagged with // nolint: deadcode a warning is still generated

package main
  
import (
        "fmt"
)

const (
        Valid   = iota
        Invalid // nolint: deadcode
        Another
)

func SetState(s int) {
        switch s {
        case Valid:
                fmt.Println("valid")
        default:
                fmt.Println("unknown state %v", s)
        }
}
gometalinter.v1 --disable-all --enable deadcode --debug .
DEBUG: PATH=/data/go/bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin:/root/bin:/usr/local/go/bin:/data/go/bin:/data/go/bin
DEBUG: GOPATH=/data/go
DEBUG: GOBIN=/data/go/bin
DEBUG: linting path .
DEBUG: linting with deadcode: deadcode {path} (on .)
DEBUG: executing /data/go/bin/deadcode ["."]
DEBUG: warning: deadcode . returned exit status 2
DEBUG: deadcode hits 2: ^deadcode: (?P<path>.*?\.go):(?P<line>\d+):(?P<col>\d+):\s*(?P<message>.*)$
DEBUG: nolint: parsing job.go for directives
DEBUG: deadcode linter took 11.886236ms
DEBUG: nolint: parsing job.go took 226.93µs
job.go:7:1:warning: Invalid is unused (deadcode)
job.go:12:1:warning: SetState is unused (deadcode)
DEBUG: total elapsed time 22.532206ms

Ignore the fact that SetState is unused, that's just a side effect of the simplified example.

The issue is caused by the fact that deadcode is reporting the issue for line 7 when in fact it should report line 9.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant