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

allow for skipping file names by patterns #30

Closed
srenatus opened this issue May 28, 2018 · 5 comments
Closed

allow for skipping file names by patterns #30

srenatus opened this issue May 28, 2018 · 5 comments
Labels
enhancement New feature or improvement

Comments

@srenatus
Copy link
Contributor

I'm not sure if this is again only something I haven't found in the docs, but -- it would be very nice if golangci-lint could be configured to ignore files that have been generated. One way we've used this with GML was to configure an "exclude pattern" of *.pb.*.go, like

{
  "Exclude": [
     ".*\\.pb\\.go"
  ]
}

Any way to achieve that, short of (pre-)filtering the list of files to check?

@golangci golangci added the enhancement New feature or improvement label May 29, 2018
@golangci
Copy link
Collaborator

golangci commented May 29, 2018

@srenatus thank you for the suggestion!
We will implement it. Now, these files analyzed, but issues from them aren't reported (we see the first line of these autogenerated files and understand they are autogenerated).

@srenatus
Copy link
Contributor Author

Ah! Thanks for the pointer -- indeed, the checks catch our protobuf files (*.pb.go), but not stuff generated with a custom code generator:

// Code generated by protoc-gen-validate
// source: foo.proto
// DO NOT EDIT!!!

In this case, the generator is https://github.com/lyft/protoc-gen-validate.

Likewise, files generated using https://github.com/twitter/go-bindata don't seem to be excluded -- they start with

// Code generated by go-bindata.
// sources:
// foo/bar.baz
// DO NOT EDIT!

srenatus added a commit to srenatus/golangci-lint that referenced this issue May 31, 2018
As observed in golangci#30, there's tools out there that don't comply 100% with
the referenced golang convention.

With this change, golangci-lint will skip some more of those generated
files.

Signed-off-by: Stephan Renatus <[email protected]>
@jirfag
Copy link
Contributor

jirfag commented Jun 2, 2018

Skipping files (not dirs) for all linters looks difficult now because of packages loading scheme: linters work with packages, not files. To properly exclude files we should make packages in another way.

@kop
Copy link

kop commented Jun 6, 2018

It would be nice to be able to skip at least dirs/packages for now.
Another use case for this is third-party code that is not part of the vendor (needed in some cases).
I do not want to fix issues there in order to be able to update it later without issues.

golangci pushed a commit that referenced this issue Jun 7, 2018
golangci pushed a commit that referenced this issue Jun 7, 2018
jirfag added a commit that referenced this issue Jun 7, 2018
#30: support --skip-files and --skip-dirs options: they skip files an…
@jirfag
Copy link
Contributor

jirfag commented Jun 7, 2018

try in master, please. Options --skip-files and --skip-dirs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or improvement
Projects
None yet
Development

No branches or pull requests

3 participants