-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Option to exclude folders from scanning #4360
Comments
Hey, thank you for opening your first Issue ! 🙂 If you would like to contribute we have a guide for contributors. |
This could also probably be fixed by caching. On multiple runs |
This is not about skipping packages, but skipping unrelated Folders without any .go files in it (like a folder with PDFs or JS files) |
Here is the output which illustrates the problem:
After deleting the big folder without any .go files:
|
Can you provide a reproducible example? |
@ldez sure - here is a simple example: A project with a single main.go file and a folder "stuff" which contains no files, just empty folders.
Here is the whole project as a zip file: |
I think I located the problem with how the go module system works. If I rename the folder to _stuff or if I put an empty "go.mod" file into the folder it will be ignored by the go module system and build and I get the fast response. |
Just to explain, golangci-lint uses the Go pieces and those pieces allow only the same pattern as |
My use case is different. I have some auto-generated code from a Ragel lexer, and it is huge and mostly not my own code. I'm willing to accept slightly broken code there so long as it compiles. The problem is, this 250k file takes significant time to run, and even if issues are found, it is not likely I will care enough to fix them so long as the code compiles. It is a literal waste of CPU minutes in GitHub Actions to scan this file, and I have to up my time limit to 10m just to get it to be scanned. If I were to add a My use case isn't per-package as I in the same package I have code I do want to be scanned. |
As I already explained: the issues reported for a file can be ignored but the files cannot be ignored by the analysis.
|
@skandragon can your code compile without this 250k file? If not than you're probably out of luck, since the whole code-base has to be compiled and linked by the go builder. But I was thinking - should it not be possible to increase performance with more aggressive caching for excluded files? If the files are in subfolder e.g. other modules, should not build-caching allow the linker to reuse the binary without rebuilding? And the linter could also use cached resources for this file, since it is marked as included? |
When the Go tooling supports that, we will be able to effectively ignore packages and files. |
Could also just crawl the files without relying on the go tooling which would also solve other issues like having to run golangci multiple times with different build tags or GOOS values to be able to lint everything. |
The Go tooling is the core of golangci-lint, golangci-lint relies on that to have its performance. |
This comment was marked as off-topic.
This comment was marked as off-topic.
I have also the same problem, I have a persistend database generated by Docker, in one of my subfolder and I would like that golangci does not try to look into it... golangci-lint run --fix
ERRO [linters_context] typechecking error: pattern ./...: open /home/user/project/docker/persistent-data/db: permission denied
make: *** [Makefile:83: lint] Error 7 |
Your feature request related to a problem? Please describe.
golang-lint-ci --fast
is slowed down, because it traverses all directories (even unrelated big directories like a node_modules folder) and there is no option to exclude unrelated folders from scanning/traversal.Describe the solution you'd like.
Provide an option to ignore/exclude folders from traversal/scanning.
Describe alternatives you've considered.
I tried excluding the folders with the
--skip-dirs
flag, but golang-lint-ci will still traverse the subfolders and take a lot of time on each run.Additional context.
I'm using golang-lint-ci as my integrated linter in VS Code (running on file-save), fast execution time is critical. I measured performance with --verbose and
Go packages loading at mode 575
takes up the most time (even with caching enabled) it takes almost 9 seconds every run, even though my project has only ~1000 Lines of Go-Code in 6 files.We have the frontend project in a subfolder of the go project (/frontend) which includes a huge node_modules folder. Deleting this folder speeds up the scan from 12 to 4 seconds. Is there any option to hide this folder from golang-lint-ci ?
The text was updated successfully, but these errors were encountered: