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

gci auto fix is broken #2591

Closed
4 tasks done
Dreamacro opened this issue Feb 17, 2022 · 9 comments
Closed
4 tasks done

gci auto fix is broken #2591

Dreamacro opened this issue Feb 17, 2022 · 9 comments
Labels
question Further information is requested

Comments

@Dreamacro
Copy link
Contributor

Welcome

  • Yes, I'm using a binary release within 2 latest major releases. Only such installations are supported.
  • Yes, I've searched similar issues on GitHub and didn't find any.
  • Yes, I've included all information below (version, config, etc).
  • Yes, I've tried with the standalone linter if available. (https://golangci-lint.run/usage/linters/)

Description of the problem

gci only report issues but it won't fix it

Version of golangci-lint

$ golangci-lint --version
golangci-lint has version v1.44.1

Configuration file

$ cat .golangci.yml
linters:
  disable-all: true
  enable:
    - gofumpt
    - govet
    - gci

issues:
  fix: true

linters-settings:
  gci:
    sections:
      - standard
      - prefix(github.com/pkg/pkg)
      - default

Go environment

$ go version && go env
go version go1.17.6 darwin/arm64

Verbose output of running

$ golangci-lint cache clean
$ golangci-lint run -v
INFO [runner] linters took 924.918333ms with stages: goanalysis_metalinter: 924.218458ms
INFO fixer took 0s with no stages
component/dialer/bind_darwin.go:7:4: Expected 'i', Found 'o' at component/dialer/bind_darwin.go[line 7,col 4] (gci)
	"golang.org/x/sys/unix"
	  ^
INFO File cache stats: 1 entries of total size 1.4KiB
INFO Memory: 13 samples, avg is 273.7MB, max is 352.6MB
INFO Execution took 1.127992166s

Code example or link to a public repository

import (
	"net"
	"syscall"

	"golang.org/x/sys/unix"

	"github.com/pkg/pkg"
)
@Dreamacro Dreamacro added the bug Something isn't working label Feb 17, 2022
@boring-cyborg
Copy link

boring-cyborg bot commented Feb 17, 2022

Hey, thank you for opening your first Issue ! 🙂 If you would like to contribute we have a guide for contributors.

@ldez
Copy link
Member

ldez commented Feb 17, 2022

Hello,

since the last gci update (#2532), autofix is no longer supported.

https://github.com/daixiang0/gci

@ldez ldez closed this as completed Feb 17, 2022
@ldez ldez added question Further information is requested and removed bug Something isn't working labels Feb 17, 2022
@songkeys
Copy link

Could you please provide some suggestions on how we can get the auto-fix feature back?

@Dreamacro
Copy link
Contributor Author

It would be nice to have the autofix feature on gci. it's really useful

@SVilgelm
Copy link
Member

Yeah, this was the main feature of the gci, now I have to revert golangci-linter to v1.44.0

@ldez
Copy link
Member

ldez commented Feb 18, 2022

We (the golangci-lint team) are not responsible for changes in the linters.

Autofix support can be restored in several ways, I'll try to see what I can do but the gci changes are deep, I don't promise anything.

@SVilgelm
Copy link
Member

there are a lot of questions to gci, the auto fix is just one of them. The error messages are completely unclear, like expected \t, but got \n. I will open issues on gci repo.

About restoring, I see that gci can do it if we use gci cli, probably we should talk with the @daixiang0

@SVilgelm
Copy link
Member

@ldez I see that the logic to prepare a diff was removed in that PR

err = differ.Diff(&diff, bytes.NewReader(source), bytes.NewReader(result))
if err != nil {
	return nil, fmt.Errorf("can't get gci diff output: %v", err)
}

I remember I had to implement it because the gci did not support analyzer at that time. Can we restore it?

@ldez
Copy link
Member

ldez commented Feb 18, 2022

Can we restore it?

no because gci is now an analyzer, we don't have like goimports/gofmt a "diffable" output

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

No branches or pull requests

4 participants