Skip to content

Autogenerated files from swagger-codegen not ignored #4965

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

Closed
6 of 7 tasks
OscarVanL opened this issue Aug 29, 2024 · 0 comments · Fixed by #4967
Closed
6 of 7 tasks

Autogenerated files from swagger-codegen not ignored #4965

OscarVanL opened this issue Aug 29, 2024 · 0 comments · Fixed by #4967
Assignees
Labels
area: processors enhancement New feature or improvement

Comments

@OscarVanL
Copy link

OscarVanL commented Aug 29, 2024

Welcome

  • Yes, I'm using a binary release within 2 latest releases. Only such installations are supported.
  • Yes, I've searched similar issues on GitHub and didn't find any.
  • Yes, I've read the typecheck section of the FAQ.
  • Yes, I've tried with the standalone linter if available (e.g., gocritic, go vet, etc.).
  • I agree to follow this project's Code of Conduct

Description of the problem

Autogenerated files from swagger-codegen are not ignored by golangci-lint.

Really, this is something that should be fixed on the swagger-codegen side (and there is an open bug here), because it does not include the standard ^// Code generated .* DO NOT EDIT\.$ pattern.

The golangci-lint configuration docs say:

# There is no need to include all autogenerated files,
# we confidently recognize autogenerated files.
# If it's not, please let us know.

So I thought I'd report it anyway.

I also tried setting exclude-generated: lax, but this does not exclude these files either.

You could add an ignore pattern for Generated by: Swagger Codegen to catch these files.

Version of golangci-lint

$ golangci-lint --version
v1.59.1

Configuration

# paste configuration file or CLI flags here

Go environment

$ go version && go env
go version && go env
go version go1.22.1 darwin/amd64
GO111MODULE='on'
GOARCH='amd64'
GOBIN=''
GOCACHE='/Users/user/Library/Caches/go-build'
GOENV='/Users/user/Library/Application Support/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='amd64'
GOHOSTOS='darwin'
GOINSECURE=''
GOMODCACHE='/Users/user/go/pkg/mod'
GONOPROXY='gitlab.com/foo/*,github.com/foo/*'
GONOSUMDB='gitlab.com/foo/*,github.com/foo/*'
GOOS='darwin'
GOPATH='/Users/user/go'
GOPRIVATE='gitlab.com/foo/*,github.com/foo/*'
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/usr/local/go'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/usr/local/go/pkg/tool/darwin_amd64'
GOVCS=''
GOVERSION='go1.22.1'
GCCGO='gccgo'
GOAMD64='v1'
AR='ar'
CC='clang'
CXX='clang++'
CGO_ENABLED='1'
GOMOD='/Users/user/go/src/github.com/foo/bar/src/baz/go.mod'
GOWORK=''
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 x86_64 -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -ffile-prefix-map=/var/folders/z4/tjbsqpbj5pz3_mh9jzb4vhxw0000gn/T/go-build336395111=/tmp/go-build -gno-record-gcc-switches -fno-common'

Verbose output of running

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

A minimal reproducible example or link to a public repository

Generate swagger files using swagger-codegen (docker example for portability):

docker run --rm -v ${PWD}:/local swaggerapi/swagger-codegen-cli generate \
    -i https://petstore.swagger.io/v2/swagger.json \
    -l go \
    -o /local/out/go

Run golangci-lint against those files. It'll probably fail against things like revive for missing exported var comments, lll for being too long, etc.

Validation

  • Yes, I've included all information above (version, config, etc.).

Supporter

@OscarVanL OscarVanL added the bug Something isn't working label Aug 29, 2024
@golangci golangci deleted a comment from rodeok Aug 29, 2024
@ldez ldez added question Further information is requested and removed bug Something isn't working labels Aug 29, 2024
@ldez ldez self-assigned this Aug 29, 2024
@ldez ldez added enhancement New feature or improvement no decision No decision to fix or not and removed question Further information is requested labels Aug 29, 2024
@ldez ldez added area: processors and removed no decision No decision to fix or not labels Aug 30, 2024
@ldez ldez closed this as completed in #4967 Sep 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: processors enhancement New feature or improvement
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants