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

Exclude vendor/... by default #1056

Closed
mcandre opened this issue Oct 4, 2024 · 12 comments
Closed

Exclude vendor/... by default #1056

mcandre opened this issue Oct 4, 2024 · 12 comments

Comments

@mcandre
Copy link

mcandre commented Oct 4, 2024

Is your feature request related to a problem? Please describe.

revive's default behavior with revive ./... generates linter warnings for third party code in the vendor directory, when using the go mod vendor system to manage dependencies.

Linter warnings for third party code tends to be less actionable compared to linter warnings for first party code.

Describe the solution you'd like

Exclude vendor/... by default.

Describe alternatives you've considered

Baking -exclude vendor/... into mcand/remage-extras's Revive task.

@mfederowicz
Copy link
Contributor

hey @mcandre have you tried add: exclude = ['vendor/...']
to ~/revive.toml and then run: ./revive ./...

@mcandre
Copy link
Author

mcandre commented Oct 6, 2024

Yes, I see a configuration file and command line flag to do this.

I'm asking for better default behavior. The vendor directory is a Go programming language standard.

We should also ensure that the config file and flags are able to overwrite default exclusion patterns, as some users have a need to examine third party code with linters. But the majority of users will be drowned out by unactionable noise for warnings on code they don't directly control.

@mfederowicz
Copy link
Contributor

@chavacava my #1058 adds vendor/... to ignored only if we don set -exclude from cli or exclude = [] in revive.toml what you think?

@chavacava
Copy link
Collaborator

chavacava commented Oct 6, 2024

@mfederowicz thanks for the PR. My concern with by default excluding vendor is that revive will not behave as before thus vendor will be silently excluded.

About the PR: What if I actually want to analyze vendor? How I need to run revive?

@mfederowicz
Copy link
Contributor

@chavacava good point, then you can run revive with one exclude even pointing to not existing path:

./revive -exclude xxx -formatter friendly ./...

then excludePatterns list is processed as before (and vendor back to game) :)

@mfederowicz
Copy link
Contributor

ofcourse @chavacava iam open to other options (maybe dedicated flag in config set by default to true) or something else :)

@chavacava
Copy link
Collaborator

@mfederowicz IMO the hack of excluding a non existent pattern rather than a solution is a smell on the inconvenience of excluding vendor by default. The same on adding a flag to actually (un)do what another already existing flag does.

@mcandre
As you already know, there is a flag to exclude vendor (or any other arbitrary directory). Use it if you are not interested in analyzing vendored code.

I'll close this issue for now, if in the future there is more people interested in changes on the treatment of vendor we can re-open the discussion.

@mcandre
Copy link
Author

mcandre commented Oct 7, 2024

This is the first Go linter in recent memory to not exclude the vendor directory properly by default.

@denisvmedia
Copy link
Collaborator

#1058 is merged.

@mcandre
Copy link
Author

mcandre commented Oct 31, 2024

Amazing!

When can we expect a new release to include this change?

@mfederowicz
Copy link
Contributor

@mcandre if you dont want to wait for new release you can install dev version of revive by:

go install github.com/mgechev/revive@master

@mcandre
Copy link
Author

mcandre commented Nov 1, 2024

Fair point. @master or @latest would suffice if I need to rush.

However, I prefer to target stable, tagged version releases as a safeguard against potentially breaking changes.

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

No branches or pull requests

4 participants