refactor(scripts): share could_be_file_path with parse_scripts#264
Merged
BartWaardenburg merged 1 commit intomainfrom May 3, 2026
Merged
refactor(scripts): share could_be_file_path with parse_scripts#264BartWaardenburg merged 1 commit intomainfrom
BartWaardenburg merged 1 commit intomainfrom
Conversation
…_scripts PR #262 added `could_be_file_path` in `crates/core/src/scripts/mod.rs` to reject tokens whose syntax precludes a Unix path (GHA expressions, backslash escapes, malformed `[...]`) before they reach globset compilation. The sibling `looks_like_file_path` / `looks_like_script_file` in `crates/core/src/discover/parse_scripts.rs` classify the same kinds of tokens for package.json / Dockerfile / Procfile / fly.toml extraction, but feed `resolve_entry_path_with_tracking` (real-fs `is_file()` check) instead of globset, so they never produced the noisy `invalid entry pattern` warning. No behavioral bug exists today, but maintaining two near-identical classifiers invites drift. Promote `could_be_file_path` from private to `pub` and call it as a pre-filter from the discover-side classifiers. This is a single-source-of-truth refactor with a micro perf win (skip `Path::join` + `is_file` syscalls on tokens that cannot be paths) and zero behavioral change for users. Verified: total_issues on the next.js benchmark is unchanged (24825), no `invalid entry pattern` warnings emitted (already 0 after #262), all 1917 fallow-core unit tests + 297 integration tests pass, full workspace test suite green.
Collaborator
Author
|
Released in v2.63.0. |
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.
Summary
Follow-up to #262. PR #262 added
could_be_file_pathincrates/core/src/scripts/mod.rsas a negative-only guard that rejects tokens whose syntax precludes a Unix path (GHA expressions, backslash escapes, malformed[...]). The sibling classifiers incrates/core/src/discover/parse_scripts.rs(looks_like_file_path,looks_like_script_file) classify the same kinds of tokens for package.json / Dockerfile / Procfile / fly.toml extraction.These discover-side classifiers do not feed globset (they feed
resolve_entry_path_with_tracking's real-fsis_file()check), so noinvalid entry patternwarning was ever emitted from this path. There is no behavioral bug today.But maintaining two near-identical classifiers invites drift, so promote
could_be_file_pathfrom private topuband call it as a pre-filter from the discover-side classifiers. Single source of truth, micro perf win (skipPath::join+is_filesyscalls on tokens that cannot be paths), zero behavioral change for users.Changes
crates/core/src/scripts/mod.rs:fn could_be_file_path→pub fn, doc comment updated to mention shared use.crates/core/src/discover/parse_scripts.rs: bothlooks_like_file_pathandlooks_like_script_filecallcrate::scripts::could_be_file_pathfirst.scripts/mod.rs(GHA fragments, backslash, bracket-class, Next.js dynamic-route positive cases).Test plan
cargo check --workspacecleancargo clippy -p fallow-core -- -D warningscleancargo fmt --all -- --checkcleantypos crates/core/src/{scripts,discover/parse_scripts.rs}cleancargo test -p fallow-core --lib1917/1917cargo test -p fallow-core --tests297/297cargo test --workspaceall greenbenchmarks/fixtures/real-world/next.js:total_issues=24825matches PR fix(scripts): harden YAML scanner against shell/regex fragment misclassification #262 baseline; 0invalid entry patternwarnings (unchanged).