walker: sniff shebangs only in extensionless files#5
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stacked on the traversal PR (top of the stack; reject-able independently). This is the one intentional behavior change from the audit — everything in the other three PRs is byte-identical.
aloc currently opens and reads every file whose extension it doesn't recognize, hunting for a shebang — ~13k wasted opens on the Linux kernel tree (
.lock,.dts, config fragments, …). tokei and scc only sniff extensionless files. This PR adopts that policy via asniffablehelper:script,Makefile.d/foo→ no ext) → sniffed, as beforerun.xyz) → skipped without any syscall, sameunknown languagetrace.bashrcis extensionless (one leading dot stripped, matching RustPath::extension, hence tokei);file.(bare trailing dot) still sniffsBehavior change: a shebang script with an unrecognized extension (e.g.
run.xyzstarting with#!/usr/bin/env python3) is no longer detected or counted. README updated; walker tests pin the full policy table end-to-end.Measured: on a corpus with ~17% unknown-extension files: wall −22% (1.168s → 0.91s mean, interleaved). On trees without such files: zero output change — verified byte-identical (including
--by-file) on the 52k corpus AND Linux 6.9; the 400 extensionlessbin/tool*shebang scripts in the corpus are all still counted. The single intended diff was demonstrated on a purpose-built tree: exactly one file (run.xyz) drops.🤖 Generated with Claude Code