-
-
Notifications
You must be signed in to change notification settings - Fork 237
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
golangci-lint: support autofix #2679
Comments
Sounds like a good idea. Feel free to open a pull request! |
Since golang-ci is a Golang linter aggregator (compiled into one binary), and on their help page, they mention that the --fix option will work if it is supported by the linter, then for the tests file, we should find an error that is fixable by one of the linters to test that the option works when provided by MegaLinter. Ie: it's possible that our test files for Go won't trigger a fix as is. |
I share @Kurt-von-Laven & @echoix 's opinion, that would be a good improvement :) @seaneagan do you have an example of error that could be autofixed in this file ? https://github.com/oxsecurity/megalinter/blob/main/.automation/test/golang/golang_good_01.go |
@nvuillam the unused variable check is enabled by default, and autofixing will remove the line where the variable is defined, so that might be a good option |
Well, we'll see what CI jobs say in #2683 :) |
@seaneagan not working yet... Maybe you could provide an example of file + example call ? |
The call itself looks right to me based on the docs, so I'm guessing we simply need a different example. |
@nvuillam do the tests use one of these .golangci.yml's? those don't match the golangci-lint's default config, which has the it seems the git history of those files got lost in the superlinter > megalinter migration, but updating them to match the current default might make sense: linters:
disable-all: true
enable:
- gocritic
- gosimple
- govet
- ineffassign
- staticcheck
- typecheck
- unused |
^ would also get rid of the deprecated linter usage (maligned, golint) |
@seaneagan thanks, I try that :) |
@seaneagan Still no fix with this update :/ Maybe you could try locally and provide the exact call and test file ? |
sorry, i thought Probably the most clear formatting mistake, which will get fixed by the above, will be to under-indent a line:
|
Thanks I try that :) |
@seaneagan still KO :/ |
Is your feature request related to a problem? Please describe.
golangci-lint supports a --fix option, but it's not supported by megalinter:
https://golangci-lint.run/usage/configuration/#command-line-options
Describe the solution you'd like
APPLY_FIXES against GO_GOLANGCI_LINT results in
golangci-lint --fix ...
Describe alternatives you've considered
Running golangci-lint manually outside megalinter
The text was updated successfully, but these errors were encountered: