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

conflict results between gofmt and nolintlint #3110

Closed
4 tasks done
pranc1ngpegasus opened this issue Aug 18, 2022 · 3 comments
Closed
4 tasks done

conflict results between gofmt and nolintlint #3110

pranc1ngpegasus opened this issue Aug 18, 2022 · 3 comments
Labels
bug Something isn't working

Comments

@pranc1ngpegasus
Copy link

pranc1ngpegasus commented Aug 18, 2022

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

I have used // nolint: ireturn with following golangci-lint config.
When I run golangci-lint run, nolintlint has showed directive `// nolint: ireturn` should be written without leading space as `//nolint: ireturn` (nolintlint).
Then I run golangci-lint run with nolintlint config both of allow-leading-space: false and allow-leading-space: true , gofmt has showed File is not `gofmt`-ed with `-s` (gofmt).

Version of golangci-lint

$ golangci-lint --version
golangci-lint has version v1.47.3 built from (unknown, mod sum: "h1:ri7A2DgtFpxgqcMSsU3qIT0IBm/SCdYgXlvmJx4szUU=") on (unknown)

Configuration file

$ cat .golangci.yml
run:
  tests: false
  allow-parallel-runners: true
  go: '1.19'
  skip-dirs:
    - ent
    - graph/generated
    - graph/model

output:
  print-issued-lines: false
  sort-results: true

linters:
  enable-all: true
  disable:
    # deprecated
    - golint
    - exhaustivestruct
    - scopelint
    - golint
    - gci
    - interfacer
    - maligned
    - bodyclose
    - contextcheck
    - interfacer
    - nilerr
    - noctx
    - rowserrcheck
    - sqlclosecheck
    - structcheck
    - tparallel
    - wastedassign
   # disable
    - dupl 
    - gochecknoglobals
    - varnamelen

linters-settings:
  funlen:
    lines: 61
  ireturn:
    allow:
      - anon
      - error
      - empty
      - stdlib
      - (or|er)$
  lll:
    line-length: 194
  nolintlint:
    allow-leading-space: false
  wrapcheck:
    ignoreSigRegexps:
      - \.New.*Error\(
      - \.ErrorOrNil\(

Go environment

$ go version && go env
go version go1.19 darwin/arm64
GO111MODULE=""
GOARCH="arm64"
GOBIN="/Users/pranc1ngpegasus/go/bin"
GOCACHE="/Users/pranc1ngpegasus/Library/Caches/go-build"
GOENV="/Users/pranc1ngpegasus/Library/Application Support/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="arm64"
GOHOSTOS="darwin"
GOINSECURE=""
GOMODCACHE="/Users/pranc1ngpegasus/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="darwin"
GOPATH="/Users/pranc1ngpegasus/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/Users/pranc1ngpegasus/.asdf/installs/golang/1.19/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/Users/pranc1ngpegasus/.asdf/installs/golang/1.19/go/pkg/tool/darwin_arm64"
GOVCS=""
GOVERSION="go1.19"
GCCGO="gccgo"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/Users/pranc1ngpegasus/ghq/github.com/3-shake/securify-shield/server/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 -arch arm64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/cf/rzkpf1jd2297474llk7qvs240000gn/T/go-build710421967=/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/pranc1ngpegasus/ghq/github.com/ORG/REPO/server /Users/pranc1ngpegasus/ghq/github.com/ORG/REPO /Users/pranc1ngpegasus/ghq/github.com/ORG /Users/pranc1ngpegasus/ghq/github.com /Users/pranc1ngpegasus/ghq /Users/pranc1ngpegasus /Users /]
INFO [config_reader] Used config file .golangci.yml
INFO [lintersdb] Active 76 linters: [asasalint asciicheck bidichk containedctx cyclop deadcode decorder depguard dogsled durationcheck errcheck errchkjson errname errorlint execinquery exhaustive exhaustruct exportloopref forbidigo forcetypeassert funlen gochecknoinits gocognit goconst gocritic gocyclo godot godox goerr113 gofmt gofumpt goheader goimports gomnd gomoddirectives gomodguard goprintffuncname gosec gosimple govet grouper ifshort importas ineffassign ireturn lll maintidx makezero misspell nakedret nestif nilnil nlreturn nolintlint nonamedreturns nosnakecase nosprintfhostport paralleltest prealloc predeclared promlinter revive staticcheck stylecheck tagliatelle tenv testpackage thelper typecheck unconvert unparam unused varcheck whitespace wrapcheck wsl]
INFO [loader] Go packages loading at mode 575 (types_sizes|imports|deps|exports_file|files|name|compiled_files) took 2.005432667s
INFO [runner/filename_unadjuster] Pre-built 0 adjustments in 47.603ms
INFO [linters context] importas settings found, but no aliases listed. List aliases under alias: key.
INFO [linters context/goanalysis] analyzers took 2m21.002115091s with top 10 stages: goimports: 47.928571961s, buildir: 18.126535537s, the_only_name: 7.364609298s, bidichk: 5.559825462s, buildssa: 2.529537333s, exhaustive: 2.440864653s, fact_deprecated: 2.006502933s, ctrlflow: 1.912350339s, gofumpt: 1.890269505s, nilness: 1.600541923s
INFO [runner/skip dirs] Skipped 6 issues from dir adapter/presenter by pattern ent
INFO [runner/skip dirs] Skipped 46 issues from dir ent/accountinvitation by pattern ent
INFO [runner/skip dirs] Skipped 58 issues from dir ent/githubintegration by pattern ent
INFO [runner/skip dirs] Skipped 34 issues from dir ent/slackintegration by pattern ent
INFO [runner/skip dirs] Skipped 18 issues from dir adapter/authenticator by pattern ent
INFO [runner/skip dirs] Skipped 53 issues from dir ent/vuln by pattern ent
INFO [runner/skip dirs] Skipped 52 issues from dir ent/googleworkspaceintegration by pattern ent
INFO [runner/skip dirs] Skipped 34 issues from dir ent/organization by pattern ent
INFO [runner/skip dirs] Skipped 1 issues from dir ent/predicate by pattern ent
INFO [runner/skip dirs] Skipped 1 issues from dir ent/runtime by pattern ent
INFO [runner/skip dirs] Skipped 41 issues from dir ent/integration by pattern ent
INFO [runner/skip dirs] Skipped 19 issues from dir ent/schema by pattern ent
INFO [runner/skip dirs] Skipped 28 issues from dir adapter/client by pattern ent
INFO [runner/skip dirs] Skipped 28 issues from dir ent/integrationvulntarget by pattern ent
INFO [runner/skip dirs] Skipped 28 issues from dir ent/integrationscan by pattern ent
INFO [runner/skip dirs] Skipped 37 issues from dir ent/service by pattern ent
INFO [runner/skip dirs] Skipped 49 issues from dir ent/integrationvuln by pattern ent
INFO [runner/skip dirs] Skipped 8359 issues from dir graph/generated by pattern graph/generated
INFO [runner/skip dirs] Skipped 25 issues from dir ent/migrate by pattern ent
INFO [runner/skip dirs] Skipped 12 issues from dir ent/enttest by pattern ent
INFO [runner/skip dirs] Skipped 40 issues from dir ent/account by pattern ent
INFO [runner/skip dirs] Skipped 73 issues from dir ent/hook by pattern ent
INFO [runner/skip dirs] Skipped 1 issues from dir graph/model by pattern graph/model
INFO [runner/skip dirs] Skipped 13676 issues from dir ent by pattern ent
INFO [runner/max_same_issues] 51/54 issues with text "err113: do not define dynamic errors, use wrapped static errors instead: \"fmt.Errorf(\\\"not implemented\\\")\"" were hidden, use --max-same-issues
INFO [runner] Issues before processing: 22889, after processing: 7
INFO [runner] Processors filtering stat (out/in): path_shortener: 7/7, cgo: 22889/22889, autogenerated_exclude: 146/170, exclude: 146/146, max_from_linter: 7/7, max_per_file_from_linter: 58/58, path_prettifier: 22889/22889, skip_dirs: 170/22889, identifier_marker: 146/146, exclude-rules: 71/146, filename_unadjuster: 22889/22889, nolint: 63/71, sort_results: 7/7, source_code: 7/7, severity-rules: 7/7, path_prefixer: 7/7, skip_files: 22889/22889, uniq_by_line: 58/63, diff: 58/58, max_same_issues: 7/58
INFO [runner] processing took 40.613793ms with stages: path_prettifier: 14.723583ms, autogenerated_exclude: 9.801624ms, nolint: 4.856209ms, exclude-rules: 3.819958ms, skip_dirs: 1.912459ms, identifier_marker: 1.658959ms, cgo: 1.402042ms, source_code: 1.275499ms, filename_unadjuster: 1.11625ms, max_same_issues: 17.459µs, uniq_by_line: 16.083µs, max_per_file_from_linter: 5.625µs, sort_results: 2.459µs, path_shortener: 2.375µs, max_from_linter: 2.167µs, exclude: 292ns, severity-rules: 250ns, skip_files: 209ns, diff: 208ns, path_prefixer: 83ns
INFO [runner] linters took 54.542170333s with stages: goanalysis_metalinter: 54.50146525s
adapter/resolver/account.resolvers.go:55:8: err113: do not define dynamic errors, use wrapped static errors instead: "fmt.Errorf(\"not implemented\")" (goerr113)
adapter/resolver/account.resolvers.go:60:8: err113: do not define dynamic errors, use wrapped static errors instead: "fmt.Errorf(\"not implemented\")" (goerr113)
adapter/resolver/ent.resolvers.go:26:8: err113: do not define dynamic errors, use wrapped static errors instead: "fmt.Errorf(\"not implemented\")" (goerr113)
adapter/resolver/resolver.go:43: File is not `gofmt`-ed with `-s` (gofmt)
INFO File cache stats: 160 entries of total size 2.4MiB
INFO Memory: 577 samples, avg is 811.9MB, max is 951.4MB
INFO Execution took 57.51537625s

Code example or link to a public repository

// nolint: ireturn
func NewSomething() SomethingInterface {
    // do something
}
@pranc1ngpegasus pranc1ngpegasus added the bug Something isn't working label Aug 18, 2022
@boring-cyborg
Copy link

boring-cyborg bot commented Aug 18, 2022

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

@bombsimon
Copy link
Member

bombsimon commented Aug 18, 2022

Hello,

Due to a change of go fmt inside go1.19.
We have to enforce the directive style.

So the option allow-leading-space has been dropped.

The syntax of directives is: [a-zA-Z]+:[a-zA-Z].*.
The spaces around : and after the // must be removed.

// nolint:foo // <-- malformed
//nolint :foo // <-- malformed
//nolint: foo // <-- malformed

//nolint:foo // <-- OK

If you do that your IDE or go fmt will format the directive as a directive and it will not add extra space.

Related to:
#3002
#1658 (comment)

Duplicate of #3109, #3101, #3069, #3098, #3109, #3063.

@pranc1ngpegasus
Copy link
Author

Thank you @bombsimon !

EduardGomezEscandell added a commit to ubuntu/GoWSL that referenced this issue Mar 6, 2023
Nolintlint wants the //nolint directives without a leading space
GoFmt wants them with a leading space, ...
   except if nolint has no space afterwards:

// nolint:foo // <-- malformed
//nolint :foo // <-- malformed
//nolint: foo // <-- malformed

//nolint:foo // <-- OK


See golangci/golangci-lint#3110 (comment)
EduardGomezEscandell added a commit to ubuntu/GoWSL that referenced this issue Mar 6, 2023
Nolintlint wants the //nolint directives without a leading space
GoFmt wants them with a leading space, ...
   except if nolint has no space afterwards:

// nolint:foo // <-- malformed
//nolint :foo // <-- malformed
//nolint: foo // <-- malformed

//nolint:foo // <-- OK


See golangci/golangci-lint#3110 (comment)
EduardGomezEscandell added a commit to ubuntu/GoWSL that referenced this issue Mar 7, 2023
Nolintlint wants the //nolint directives without a leading space
GoFmt wants them with a leading space, ...
   except if nolint has no space afterwards:

// nolint:foo // <-- malformed
//nolint :foo // <-- malformed
//nolint: foo // <-- malformed

//nolint:foo // <-- OK

See golangci/golangci-lint#3110 (comment)
EduardGomezEscandell added a commit to ubuntu/GoWSL that referenced this issue Mar 7, 2023
Nolintlint wants the //nolint directives without a leading space
GoFmt wants them with a leading space, ...
   except if nolint has no space afterwards:

// nolint:foo // <-- malformed
//nolint :foo // <-- malformed
//nolint: foo // <-- malformed

//nolint:foo // <-- OK

See golangci/golangci-lint#3110 (comment)
EduardGomezEscandell added a commit to ubuntu/GoWSL that referenced this issue Mar 7, 2023
Nolintlint wants the //nolint directives without a leading space
GoFmt wants them with a leading space, ...
   except if nolint has no space afterwards:

// nolint:foo // <-- malformed
//nolint :foo // <-- malformed
//nolint: foo // <-- malformed

//nolint:foo // <-- OK

See golangci/golangci-lint#3110 (comment)
EduardGomezEscandell added a commit to ubuntu/GoWSL that referenced this issue Mar 7, 2023
Nolintlint wants the //nolint directives without a leading space
GoFmt wants them with a leading space, ...
   except if nolint has no space afterwards:

// nolint:foo // <-- malformed
//nolint :foo // <-- malformed
//nolint: foo // <-- malformed

//nolint:foo // <-- OK

See golangci/golangci-lint#3110 (comment)
EduardGomezEscandell added a commit to ubuntu/GoWSL that referenced this issue Mar 7, 2023
Nolintlint wants the //nolint directives without a leading space
GoFmt wants them with a leading space, ...
   except if nolint has no space afterwards:

// nolint:foo // <-- malformed
//nolint :foo // <-- malformed
//nolint: foo // <-- malformed

//nolint:foo // <-- OK

See golangci/golangci-lint#3110 (comment)
EduardGomezEscandell added a commit to ubuntu/GoWSL that referenced this issue Mar 8, 2023
Nolintlint wants the //nolint directives without a leading space
GoFmt wants them with a leading space, ...
   except if nolint has no space afterwards:

// nolint:foo // <-- malformed
//nolint :foo // <-- malformed
//nolint: foo // <-- malformed

//nolint:foo // <-- OK

See golangci/golangci-lint#3110 (comment)
EduardGomezEscandell added a commit to ubuntu/GoWSL that referenced this issue Mar 8, 2023
Nolintlint wants the //nolint directives without a leading space
GoFmt wants them with a leading space, ...
   except if nolint has no space afterwards:

// nolint:foo // <-- malformed
//nolint :foo // <-- malformed
//nolint: foo // <-- malformed

//nolint:foo // <-- OK

See golangci/golangci-lint#3110 (comment)
EduardGomezEscandell added a commit to ubuntu/GoWSL that referenced this issue Mar 8, 2023
Nolintlint wants the //nolint directives without a leading space
GoFmt wants them with a leading space, ...
   except if nolint has no space afterwards:

// nolint:foo // <-- malformed
//nolint :foo // <-- malformed
//nolint: foo // <-- malformed

//nolint:foo // <-- OK

See golangci/golangci-lint#3110 (comment)
EduardGomezEscandell added a commit to ubuntu/GoWSL that referenced this issue Mar 9, 2023
Nolintlint wants the //nolint directives without a leading space
GoFmt wants them with a leading space, ...
   except if nolint has no space afterwards:

// nolint:foo // <-- malformed
//nolint :foo // <-- malformed
//nolint: foo // <-- malformed

//nolint:foo // <-- OK

See golangci/golangci-lint#3110 (comment)
EduardGomezEscandell added a commit to ubuntu/GoWSL that referenced this issue Mar 9, 2023
Nolintlint wants the //nolint directives without a leading space
GoFmt wants them with a leading space, ...
   except if nolint has no space afterwards:

// nolint:foo // <-- malformed
//nolint :foo // <-- malformed
//nolint: foo // <-- malformed

//nolint:foo // <-- OK

See golangci/golangci-lint#3110 (comment)
EduardGomezEscandell added a commit to ubuntu/GoWSL that referenced this issue Mar 9, 2023
Nolintlint wants the //nolint directives without a leading space
GoFmt wants them with a leading space, ...
   except if nolint has no space afterwards:

// nolint:foo // <-- malformed
//nolint :foo // <-- malformed
//nolint: foo // <-- malformed

//nolint:foo // <-- OK

See golangci/golangci-lint#3110 (comment)
EduardGomezEscandell added a commit to canonical/ubuntu-pro-for-wsl that referenced this issue Mar 16, 2023
Nolintlint wants the //nolint directives without a leading space
GoFmt wants them with a leading space, ...
    except if nolint has no space afterwards:

// nolint:foo // <-- malformed
//nolint :foo // <-- malformed
//nolint: foo // <-- malformed

//nolint:foo // <-- OK

See golangci/golangci-lint#3110 (comment)
EduardGomezEscandell added a commit to canonical/ubuntu-pro-for-wsl that referenced this issue Mar 16, 2023
Nolintlint wants the //nolint directives without a leading space
GoFmt wants them with a leading space, ...
    except if nolint has no space afterwards:

// nolint:foo // <-- malformed
//nolint :foo // <-- malformed
//nolint: foo // <-- malformed

//nolint:foo // <-- OK

See golangci/golangci-lint#3110 (comment)
EduardGomezEscandell added a commit to canonical/ubuntu-pro-for-wsl that referenced this issue Mar 16, 2023
Nolintlint wants the //nolint directives without a leading space
GoFmt wants them with a leading space, ...
    except if nolint has no space afterwards:

// nolint:foo // <-- malformed
//nolint :foo // <-- malformed
//nolint: foo // <-- malformed

//nolint:foo // <-- OK

See golangci/golangci-lint#3110 (comment)
EduardGomezEscandell added a commit to canonical/ubuntu-pro-for-wsl that referenced this issue Mar 16, 2023
Nolintlint wants the //nolint directives without a leading space
GoFmt wants them with a leading space, ...
    except if nolint has no space afterwards:

// nolint:foo // <-- malformed
//nolint :foo // <-- malformed
//nolint: foo // <-- malformed

//nolint:foo // <-- OK

See golangci/golangci-lint#3110 (comment)
EduardGomezEscandell added a commit to canonical/ubuntu-pro-for-wsl that referenced this issue Mar 20, 2023
Nolintlint wants the //nolint directives without a leading space
GoFmt wants them with a leading space, ...
    except if nolint has no space afterwards:

// nolint:foo // <-- malformed
//nolint :foo // <-- malformed
//nolint: foo // <-- malformed

//nolint:foo // <-- OK

See golangci/golangci-lint#3110 (comment)
EduardGomezEscandell added a commit to canonical/ubuntu-pro-for-wsl that referenced this issue Mar 20, 2023
Nolintlint wants the //nolint directives without a leading space
GoFmt wants them with a leading space, ...
    except if nolint has no space afterwards:

// nolint:foo // <-- malformed
//nolint :foo // <-- malformed
//nolint: foo // <-- malformed

//nolint:foo // <-- OK

See golangci/golangci-lint#3110 (comment)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants