Skip to content

Improve generated files detection #1083

Closed
@rayjlinden

Description

@rayjlinden

golangci-lint is not ignoring auto generated files like it is supposed to. The autogenerated files are made by open-api generator. Here is a part of the top of one of the generated files:

/*
 * webhooksio client
 *
 * Hack because Ray is too lazy to write a client by hand.
 *
 * API version: 1.0.0
 */

// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.

Thank you for creating the issue!

  • 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).

Please include the following information:

Version of golangci-lint
$ golangci-lint --version
# golangci-lint has version 1.26.0 built from 6bd10d0 on 2020-05-01T15:33:57Z
Config file
$ golangci-lint run --fix --no-config --disable-all -E gofmt -E govet -E errcheck -E staticcheck -E unused -E gosimple -E structcheck -E varcheck -E ineffassign -E deadcode -E typecheck -E gosec ./...
Go environment
$ go version && go env
go version go1.13 linux/amd64
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/rayj/.cache/go-build"
GOENV="/home/rayj/.config/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GONOPROXY="github.com/lindenlab/*"
GONOSUMDB="github.com/lindenlab/*"
GOOS="linux"
GOPATH="/var/tmp/rayj/gocode"
GOPRIVATE="github.com/lindenlab/*"
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/home/rayj/.gvm/gos/go1.13"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/home/rayj/.gvm/gos/go1.13/pkg/tool/linux_amd64"
GCCGO="gccgo"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/var/tmp/rayj/gocode/src/github.com/lindenlab/ecom-webhooks/go.mod"
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-build126193616=/tmp/go-build -gno-record-gcc-switches"```

</details>

<details><summary>Verbose output of running</summary>

```console
$ golangci-lint cache clean
$ golangci-lint run -v
DEBU [autogen_exclude] doc of len 0 doesn't contain any of markers: [code generated do not edit autogenerated file]
DEBU [autogen_exclude] file "webhooksio/api_default.go" is generated: false
DEBU [autogen_exclude] doc of len 0 doesn't contain any of markers: [code generated do not edit autogenerated file]
DEBU [autogen_exclude] file "webhooksio/client.go" is generated: false
DEBU [autogen_exclude] doc of len 0 doesn't contain any of markers: [code generated do not edit autogenerated file]
DEBU [autogen_exclude] file "lambda/main.go" is generated: false
webhooksio/client.go:241:18: Error return value of `w.WriteField` is not checked (errcheck)
					w.WriteField(k, iv)
					            ^
webhooksio/client.go:75:6: `atoi` is unused (deadcode)
func atoi(in string) (int, error) {
     ^
webhooksio/client.go:114:6: `typeCheckParameter` is unused (deadcode)
func typeCheckParameter(obj interface{}, expected string, name string) error {
     ^
webhooksio/client.go:152:6: `parameterToJson` is unused (deadcode)
func parameterToJson(obj interface{}) (string, error) {
     ^
webhooksio/client.go:402:6: `reportError` is unused (deadcode)
func reportError(format string, a ...interface{}) error {
     ^
webhooksio/client.go:508:6: `strlen` is unused (deadcode)
func strlen(s string) int {
     ^
webhooksio/client.go:106:6: SA6005: should use strings.EqualFold(a, b) instead of strings.ToLower(a) == strings.ToLower(b) (staticcheck)
		if strings.ToLower(a) == strings.ToLower(needle) {
		   ^

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions