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

Add options to include/exclude paths #4635

Open
willfaught opened this issue Apr 11, 2024 · 4 comments
Open

Add options to include/exclude paths #4635

willfaught opened this issue Apr 11, 2024 · 4 comments
Labels
area: config Related to .golangci.yml and/or cli options no decision No decision to fix or not proposal

Comments

@willfaught
Copy link

willfaught commented Apr 11, 2024

Your feature request related to a problem? Please describe

I use https://entgo.io. It generates an /ent directory, and expects you to put your schema definitions in /ent/schema. It then generates code in /ent/foo, /ent/bar, etc. I have no control over the generated code, so I don't want to see linter errors for it. I don't see a way to exclude /ent/**, but include /ent/schema.

Describe the solution you'd like

run --exclude-path '^ent/.*$' --include-path '^ent/schema/.*$'

Describe alternatives you've considered

--exclude-dirs only works on directory names, which won't work if you want to skip some directories and exclude others with the same name.

Additional context

No response

@willfaught willfaught added the enhancement New feature or improvement label Apr 11, 2024
Copy link

boring-cyborg bot commented Apr 11, 2024

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

@ldez ldez added area: config Related to .golangci.yml and/or cli options question Further information is requested and removed enhancement New feature or improvement labels Apr 11, 2024
@ldez
Copy link
Member

ldez commented Apr 11, 2024

Hello,

you can use exclude-files: https://golangci-lint.run/usage/false-positives/#exclude-or-skip

@ldez ldez closed this as completed Apr 11, 2024
@willfaught
Copy link
Author

I don't see how exclude-files can exclude /ent/**, but include /ent/schema. Adjusting my example above, run --exclude-files '^ent/.*$' will exclude ent/schema.

@ldez ldez added no decision No decision to fix or not proposal and removed question Further information is requested labels Apr 13, 2024
@ldez ldez reopened this Apr 13, 2024
@denis-tingaikin
Copy link
Member

denis-tingaikin commented Apr 21, 2024

I see a few options for how we can manage it.

  1. Add a new flag that will exclude things from the exluded_path, as suggested by @willfaught. Here we can simply re-use approach from the golangci-linter/issues config, where we have exclude and include options.
  2. Allow using regexp in exclude-path with negative lookahead. E.g., use this lib: https://github.com/dlclark/regexp2
  3. Currently, it can be workarounded without chages via list all paths in --exclude-path  except '^ent/schema/.*$'. For example,  --exclude-path ent/folder1, ent/folder2/.*, ent/folder3/.* and etc 😀

@ldez Thoughts?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: config Related to .golangci.yml and/or cli options no decision No decision to fix or not proposal
Projects
None yet
Development

No branches or pull requests

3 participants