htmlhint / HTMLHint

⚙️ The static code analysis tool you need for your HTML
https://htmlhint.com
MIT License
3.07k stars 375 forks source link

refactor: Simplify glob call to use readdir #1370

Closed hyperupcall closed 5 months ago

hyperupcall commented 9 months ago

Short description of what this resolves:

Calling out to a glob library just to read a directory has an unecessary performance impact and complexity.

In the future, the glob will be upgraded (doing so may help fix other various issues), and the library introduces major changes to the API on later versions. Restructuring out glob prevents this area from being hit during that inevitable upgrade.

Proposed changes:

Remove the call to glob and replace it with calls to functions from the fs and path module.

I note that the structure of arrFiles changes subtly. Before, it looked like:

[ './formatters/checkstyle.js', ...]

Now, the relative path prefix no longer exists:

[ 'formatters/checkstyle.js', ... ]

This is not an issue because the paths are subsequently passed to path.resolve(__dirname, ARRAY_ENTRY), which can handle both cases.

codecov[bot] commented 9 months ago

Codecov Report

Merging #1370 (b70c799) into master (22c5716) will not change coverage. Report is 4 commits behind head on master. The diff coverage is n/a.

Additional details and impacted files [![Impacted file tree graph](https://app.codecov.io/gh/htmlhint/HTMLHint/pull/1370/graphs/tree.svg?width=650&height=150&src=pr&token=S8oI6yuz12&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=htmlhint)](https://app.codecov.io/gh/htmlhint/HTMLHint/pull/1370?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=htmlhint) ```diff @@ Coverage Diff @@ ## master #1370 +/- ## ======================================= Coverage 99.07% 99.07% ======================================= Files 2 2 Lines 1627 1627 Branches 332 332 ======================================= Hits 1612 1612 Misses 15 15 ``` ------ [Continue to review full report in Codecov by Sentry](https://app.codecov.io/gh/htmlhint/HTMLHint/pull/1370?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=htmlhint). > **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=htmlhint) > `Δ = absolute (impact)`, `ø = not affected`, `? = missing data` > Powered by [Codecov](https://app.codecov.io/gh/htmlhint/HTMLHint/pull/1370?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=htmlhint). Last update [21022c6...b70c799](https://app.codecov.io/gh/htmlhint/HTMLHint/pull/1370?src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=htmlhint). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=htmlhint).