JuliaEcosystem / PackageAnalyzer.jl

https://juliaecosystem.github.io/PackageAnalyzer.jl/dev/
MIT License
59 stars 5 forks source link

Refactor uses of `mktempdir` to use `do` block #82

Open MarkNahabedian opened 1 year ago

MarkNahabedian commented 1 year ago

If one runs the PackageAnalyzer on many packages, for example the entirity of the General Registry, it takes that JUlia session a really long time to exit because of all of the defered cleanup.

This also would release disk space sooner, giving a much smaller file system footprint for such large runs.

giordano commented 1 year ago

Thanks for the interest in the package! That's a good suggestion, but it'd require a bit of redesign which may add more complexity, because many mktempdira are used to create directories which are passed as arguments to other functions, so the life of those directories isn't confined to a single scope.

MarkNahabedian commented 1 year ago

Thanks for your quick response.

I took a quick look at the code and appreciate the amount of refactoring that would be needed. All of the mktempdir calls would need to be lifter to scopes that encompass the complete lifetime of their respective temporary directories and those directory paths passed down to where they're needed.

I might take a deeper look and maybe write a PR when I finish up with other projects.

ericphanson commented 1 year ago

I believe they can mostly or entirely be avoided by passing a root directory to analyze to store the package code in. If that's not the case, I would prefer PRs fixing or documenting that (i.e. letting those be configurable directories) rather than big refactorings