revive icon indicating copy to clipboard operation
revive copied to clipboard

Support Suggested Fixes (--fix)

Open StevenACoffman opened this issue 1 year ago • 2 comments

Since Revive (and golint) was originally authored, Go analysis has added stable SuggestedFix support for linters.

I would like revive to provide suggested fixes with a --fix argument, such that they can be automatically applied as in this example: https://github.com/golang/tools/blob/54dc8c5edb561003330ec7e649333181bbd0a9bd/go/analysis/internal/checker/checker.go#L316

BTW, there is ongoing work in golangci-lint to support applying multiline suggested fixes golangci/golangci-lint#1779 and it would be nice if revive had such available when that landed.

StevenACoffman avatar Jun 11 '24 12:06 StevenACoffman

Hey @StevenACoffman, thanks for the feature request. It'll be a trade-off between performance/complexity and DX. We're currently running rules concurrently over the project and we'll have to modify this logic which will be a performance regression.

I'm leaning towards skipping this feature, but I'll keep the feature request open for longer to collect more feedback on the trade-offs.

mgechev avatar Jun 11 '24 17:06 mgechev

Fair enough. We have really enjoyed gofumpt and similar tools that avoid needless code review nit discussions.

Some of the rules in revive are similarly straightforwardly inarguable (and can be obviously fixed in an automated fashion), and we may pull them out into their own "autofixer" utility (renew perhaps?) if that's ok.

StevenACoffman avatar Jun 11 '24 18:06 StevenACoffman