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 cannot use custom section ordering, and cannot use multiple prefixes added in gci 0.10.0 #3776

Closed
4 tasks done
deathbots opened this issue Apr 13, 2023 · 3 comments · Fixed by #3777
Closed
4 tasks done
Labels
question Further information is requested

Comments

@deathbots
Copy link
Contributor

deathbots commented Apr 13, 2023

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 (e.g., gocritic, go vet, etc.). (https://golangci-lint.run/usage/linters/)

Description of the problem

Custom section ordering was not working if specified in the config file.

Additionally, gci mentions a breaking change in version 0.10.0. See PR which means comma-separated sections no longer work.

golangci-lint would need to change how the linter is executed to support the new style.

Version of golangci-lint

$ golangci-lint --version
golangci-lint has version 1.51.2 built from 3e8facb4 on 2023-02-19T21:43:54Z

Configuration file

$ cat .golangci.yml
linters-settings:

  gci:
    sections:
      - standard                                                    # stdlib
      - default                                                     # other
      - prefix(github.com/[Redacted],github.com/[Redacted])         # us
    skip-generated: false
    custom-order: true                        # enable sections-based sorting


linters:
  disable-all: true
  enable:
    - gci

Go environment

GO111MODULE=""
GOARCH="arm64"
GOBIN=""
GOCACHE="/Users/[redacted]/Library/Caches/go-build"
GOENV="/Users/[redacted]/Library/Application Support/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="arm64"
GOHOSTOS="darwin"
GOINSECURE=""
GOMODCACHE="/Users/[redacted]/.direnv/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="darwin"
GOPATH="/Users/[redacted]/.gopath"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/go"
GOSUMDB="off"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/darwin_arm64"
GOVCS=""
GOVERSION="go1.20.2"
GCCGO="gccgo"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/Users/[redacted]/go.mod"
GOWORK="/Users/[redacted]/go.work"
CGO_CFLAGS="-O2 -g"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-O2 -g"
CGO_FFLAGS="-O2 -g"
CGO_LDFLAGS="-O2 -g"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -arch arm64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/83/vbv2phhx2g11gdnr6vlnlfsm0000gn/T/go-build1961314045=/tmp/go-build -gno-record-gcc-switches -fno-common"

Verbose output of running

$ golangci-lint cache clean
$ golangci-lint run -v

INFO [config_reader] Config search paths: [./ /Users/[redacted] /Users/[redacted] /Users /] 
INFO [config_reader] Used config file .golangci.yml 
INFO [lintersdb] Active 1 linters: [gci]          
INFO [loader] Go packages loading at mode 7 (files|compiled_files|name) took 11.794804667s 
INFO [runner/filename_unadjuster] Pre-built 0 adjustments in 276.208875ms 
INFO [linters_context/goanalysis] analyzers took 2.329851837s with top 10 stages: gci: 2.329851837s 
INFO [runner] Issues before processing: 3, after processing: 0 
INFO [runner] Processors filtering stat (out/in): cgo: 3/3, autogenerated_exclude: 0/3, filename_unadjuster: 3/3, skip_dirs: 3/3, path_prettifier: 3/3, skip_files: 3/3 
INFO [runner] processing took 2.820169ms with stages: autogenerated_exclude: 2.704875ms, path_prettifier: 86.834µs, skip_dirs: 22.918µs, cgo: 1.083µs, max_same_issues: 750ns, nolint: 708ns, filename_unadjuster: 459ns, identifier_marker: 458ns, diff: 292ns, sort_results: 250ns, exclude: 250ns, exclude-rules: 249ns, uniq_by_line: 209ns, source_code: 167ns, path_shortener: 167ns, severity-rules: 167ns, skip_files: 166ns, max_from_linter: 125ns, max_per_file_from_linter: 42ns, path_prefixer: 0s 
INFO [runner] linters took 827.049459ms with stages: gci: 824.16375ms 
INFO File cache stats: 0 entries of total size 0B 
INFO Memory: 131 samples, avg is 69.9MB, max is 847.9MB 
INFO Execution took 12.908264583s

Runs fine, doesn't produce desired sort

Code example or link to a public repository

// add your code here
@deathbots deathbots added the bug Something isn't working label Apr 13, 2023
@boring-cyborg
Copy link

boring-cyborg bot commented Apr 13, 2023

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

deathbots added a commit to deathbots/golangci-lint that referenced this issue Apr 13, 2023
Adds custom-order flag
Supports gci StringArray breaking change introduced in version 0.10.0.
CSV-style `-s one,two,three` must now be `use -s one -s two -s three`
which now supports multiple prefixes.

Fixes golangci#3776
@ldez ldez added enhancement New feature or improvement linter: update Update the linter implementation inside golangci-lint question Further information is requested and removed bug Something isn't working enhancement New feature or improvement linter: update Update the linter implementation inside golangci-lint labels Apr 13, 2023
@ldez
Copy link
Member

ldez commented Apr 13, 2023

hello,

the custom section order is supported.

See #3052

I think you are mixing the error message and what the linter does.

@ldez ldez closed this as completed Apr 13, 2023
@deathbots
Copy link
Contributor Author

You are correct, see related PR comment :)

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

Successfully merging a pull request may close this issue.

2 participants