-
Notifications
You must be signed in to change notification settings - Fork 492
cmd/golint: introduce auto fix option (--fix) #476
Conversation
This PR (HEAD: c2b0edc) has been imported to Gerrit for code review. Please visit https://go-review.googlesource.com/c/lint/+/210659 to see it. Tip: You can toggle comments from me using the |
This patch introduces an option to fix pointed out warnings automatically. This one provides such function partially; actually it has the only naming auto-correction. Ref golang#214
c2b0edc
to
00dcd60
Compare
This PR (HEAD: 00dcd60) has been imported to Gerrit for code review. Please visit https://go-review.googlesource.com/c/lint/+/210659 to see it. Tip: You can toggle comments from me using the |
If not, `format.Node()` outputs the source code that has comments on an incorrect position.
This PR (HEAD: 86ac914) has been imported to Gerrit for code review. Please visit https://go-review.googlesource.com/c/lint/+/210659 to see it. Tip: You can toggle comments from me using the |
… name rule on fix mode When `*ast.Ident` value was fixed, it doesn't show a warning message.
86ac914
to
9ceeaa3
Compare
This PR (HEAD: 9ceeaa3) has been imported to Gerrit for code review. Please visit https://go-review.googlesource.com/c/lint/+/210659 to see it. Tip: You can toggle comments from me using the |
This PR (HEAD: 601803c) has been imported to Gerrit for code review. Please visit https://go-review.googlesource.com/c/lint/+/210659 to see it. Tip: You can toggle comments from me using the |
Any plans to land this PR? |
Would love to see this merged in! |
This PR is being closed because golang.org/cl/210659 has been abandoned. Thank you for submitting this patch! As proposed[1], we are freezing and deprecating golint. There's no drop-in replacement to golint per se, but you should find that Staticcheck[2] works well in encouraging good Go code, much like golint did in the past, since it also includes style checks. There's always gofmt and "go vet" too, of course. If you would like to contribute further, I'd encourage you to engage Staticcheck's issue tracker[3] or look at vet's open issues[4], as they are both actively maintained. If you have an idea that doesn't fit into either of those tools, you could look at other Go linters[5], or write your own - these days it's fairly straightforward with go/analysis[6]. To help avoid confusion, I'm closing all CLs before we freeze the repository. If you have any feedback, you can leave a comment on the proposal thread where it was decided to deprecate golint - though note that the proposal has been accepted for nearly a year. Thanks! [1] golang/go#38968 |
This patch introduces an option to fix pointed out warnings automatically.
This one provides such function partially; actually it has the only naming auto-correction.
To be honest, I'm not confident about how to test this feature, this patch contains a simple shell-script based test as you can see. Could you please tell me if there is a good way?Update: I wrote a test case to check the behavior of auto-fix mode at 86ac914
It can fix like so:
https://github.com/golang/lint/blob/9ceeaa38f1710f96dd9f0dc840a44b4e0de0c390/testdata/names.go
=>
https://github.com/golang/lint/blob/9ceeaa38f1710f96dd9f0dc840a44b4e0de0c390/testdata/auto_fix/expected.go
Ref #214