Skip to content

v1.47.0 regression with gci linter #2982

Closed
@invidian

Description

@invidian

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

It seem using v1.47.0 docker image in GitHub action now fails: https://github.com/flexkube/libflexkube/runs/7389828332?check_suite_focus=true

golangci-lint run ./...
level=warning msg="[runner] Can't run linter goanalysis_metalinter: gci: 1:1: expected 'package', found 'EOF'"
level=error msg="Running error: 1 error occurred:\n\t* can't run linter goanalysis_metalinter: gci: 1:1: expected 'package', found 'EOF'\n\n"

Running locally and running gci linter independently works fine:

go run github.com/daixiang0/[email protected] --section 'standard,default,prefix(github.com/flexkube/libflexkube)' diff $(find -name *.go | tr \\n ' '; echo)

Version of golangci-lint

$ golangci-lint --version
golangci-lint has version 1.47.0 built from b4154027 on 2022-07-18T11:32:14Z

Configuration file

$ cat .golangci.yml
output:
  sort-results: true

run:
  timeout: 10m
  build-tags:
    - e2e
    - integration

issues:
  exclude-use-default: false
  max-same-issues: 0
  max-issues-per-linter: 0
  exclude-rules:
    # False positive: https://github.com/kunwardeep/paralleltest/issues/8.
    - linters:
        - paralleltest
      text: "does not use range value in test Run"
    - linters:
        - godot
      source: "(front proxy CA certificate,|certificate, as recommended by)"
    # Allow packages to print output to the user until we introduce loggers.
    - linters:
        - forbidigo
      text: "use of `fmt.Printf` forbidden by pattern"
    - linters:
        - forbidigo
      text: "use of `fmt.Println` forbidden by pattern"
    # Allow some errors to be not wrapped, as it is not ambiguous where they come from.
    - linters:
        - wrapcheck
      text: "error returned from external package is unwrapped"
    # Allow wrapping function which return errors.
    - linters:
        - wrapcheck
      text: "error returned from interface method should be wrapped"
    # Allow certain abbreviations in JSON fields for better readability.
    - linters:
        - tagliatelle
      text: "(CIDR|CA|DNS|API|CN|SSH).+(Cidr|Ca|Dns|Api|Cn|Ssh)"
    # Allow shadowing 'err' variables as this is convention. Other shadowing should still be avoided.
    - linters:
        - govet
      text: "shadow: declaration of \"err\" shadows declaration at line"
    # Allow using snake case for test and example names for better readability, as those functions are not called
    # directly by anyone anyway.
    - linters:
        - nosnakecase
      text: "^(Test_|Example)"

linters-settings:
  errcheck:
    check-type-assertions: true
    check-blank: true
  gci:
    sections:
      - standard
      - default
      - prefix(github.com/flexkube/libflexkube)
  godot:
    capital: true
  gofumpt:
    extra-rules: true
  govet:
    enable-all: true
    disable:
      - fieldalignment
  nolintlint:
    allow-leading-space: false
    require-explanation: true
    require-specific: true
  wsl:
    force-err-cuddling: true

linters:
  disable:
    # Triggers on TODOs in the code, which is fine to put.
    - godox
    # Disabled until tests are split and moved to the right file names.
    - testpackage
    # Disabled until we implement some error types and migrate to use them.
    - goerr113
    # To be able to make use of Go zero-value feature.
    - exhaustivestruct
    - exhaustruct
    # To allow defensive approach when initializing structs.
    - ireturn
    # Panics in v1.46.1
    - execinquery
    # This linter has been deprecated.
    - golint
    - interfacer
    - maligned
  enable:
    - asasalint
    - asciicheck
    - bidichk
    - bodyclose
    - containedctx
    - contextcheck
    - cyclop
    - deadcode
    - decorder
    - depguard
    - dogsled
    - dupl
    - durationcheck
    - errcheck
    - errchkjson
    - errname
    - errorlint
    - exhaustive
    - exportloopref
    - forbidigo
    - forcetypeassert
    - funlen
    - gci
    - gochecknoglobals
    - gochecknoinits
    - gocognit
    - goconst
    - gocritic
    - gocyclo
    - godot
    - gofmt
    - gofumpt
    - goheader
    - goimports
    - gomnd
    - gomoddirectives
    - gomodguard
    - goprintffuncname
    - grouper
    - ifshort
    - importas
    - ineffassign
    - lll
    - maintidx
    - makezero
    - misspell
    - nakedret
    - nestif
    - nilerr
    - nilnil
    - nlreturn
    - noctx
    - nolintlint
    - nonamedreturns
    - nosnakecase
    - nosprintfhostport
    - paralleltest
    - prealloc
    - predeclared
    - promlinter
    - revive
    - rowserrcheck
    - sqlclosecheck
    - structcheck
    - stylecheck
    - tagliatelle
    - tenv
    - thelper
    - tparallel
    - typecheck
    - unconvert
    - unparam
    - varcheck
    - varnamelen
    - wastedassign
    - whitespace
    - wrapcheck
    - wsl

Go environment

$ go version && go env
go version go1.18.4 linux/amd64
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/invidian/.cache/go-build"
GOENV="/home/invidian/.config/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/home/invidian/.cache/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/invidian/.cache/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/lib/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/lib/go/pkg/tool/linux_amd64"
GOVCS=""
GOVERSION="go1.18.4"
GCCGO="gccgo"
GOAMD64="v1"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/home/invidian/repos/libflexkube/go.mod"
GOWORK=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build687876676=/tmp/go-build -gno-record-gcc-switches"

Verbose output of running

$ golangci-lint cache clean
$ golangci-lint run -v
# paste output here

Code example or link to a public repository

// add your code here

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingdependenciesRelates to an upstream dependency

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions