Skip to content

refactor(scripts): share could_be_file_path with parse_scripts#264

Merged
BartWaardenburg merged 1 commit intomainfrom
fix/parse-scripts-could-be-file-path
May 3, 2026
Merged

refactor(scripts): share could_be_file_path with parse_scripts#264
BartWaardenburg merged 1 commit intomainfrom
fix/parse-scripts-could-be-file-path

Conversation

@BartWaardenburg
Copy link
Copy Markdown
Collaborator

Summary

Follow-up to #262. PR #262 added could_be_file_path in crates/core/src/scripts/mod.rs as a negative-only guard that rejects tokens whose syntax precludes a Unix path (GHA expressions, backslash escapes, malformed [...]). The sibling classifiers in crates/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-fs is_file() check), so no invalid entry pattern warning 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_path from private to pub and call it as a pre-filter from the discover-side classifiers. Single source of truth, micro perf win (skip Path::join + is_file syscalls on tokens that cannot be paths), zero behavioral change for users.

Changes

  • crates/core/src/scripts/mod.rs: fn could_be_file_pathpub fn, doc comment updated to mention shared use.
  • crates/core/src/discover/parse_scripts.rs: both looks_like_file_path and looks_like_script_file call crate::scripts::could_be_file_path first.
  • 4 new unit tests mirroring those in scripts/mod.rs (GHA fragments, backslash, bracket-class, Next.js dynamic-route positive cases).

Test plan

  • cargo check --workspace clean
  • cargo clippy -p fallow-core -- -D warnings clean
  • cargo fmt --all -- --check clean
  • typos crates/core/src/{scripts,discover/parse_scripts.rs} clean
  • cargo test -p fallow-core --lib 1917/1917
  • cargo test -p fallow-core --tests 297/297
  • cargo test --workspace all green
  • Behavioral parity on benchmarks/fixtures/real-world/next.js: total_issues=24825 matches PR fix(scripts): harden YAML scanner against shell/regex fragment misclassification #262 baseline; 0 invalid entry pattern warnings (unchanged).

…_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.
@BartWaardenburg BartWaardenburg merged commit 371fc4b into main May 3, 2026
20 checks passed
@BartWaardenburg BartWaardenburg deleted the fix/parse-scripts-could-be-file-path branch May 3, 2026 21:43
@BartWaardenburg
Copy link
Copy Markdown
Collaborator Author

Released in v2.63.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant