Skip to content

Commit b67e861

Browse files
hyperpolymathclaude
andcommitted
feat(assail): exclude vendored-snapshot directories from analysis
Three directory shapes hold vendored upstream snapshots that the project does not own and must not be flagged against: - .yarn/ (Yarn 4 cached release blobs, e.g. yarn-4.12.0.cjs) - idaptik-rescript13-staging/ (the ReScript 13 staging tree embedded in several estate repos) - rescript-ecosystem/ (vendored upstream ReScript packages) Add all three to both walk_directory's skip list and count_languages_recursive's skip list (the latter only needs the two snapshot trees — .yarn is already covered by its existing dot-prefix skip). Without these exclusions, panic-attack reports findings against code the project cannot fix — developer-ecosystem#83 logged 166 findings, ~70% of which fall in these paths. Regression tests verify each subtree is skipped while first-party sibling files are still walked. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 7935204 commit b67e861

1 file changed

Lines changed: 76 additions & 0 deletions

File tree

src/assail/analyzer.rs

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -790,6 +790,11 @@ impl Analyzer {
790790
".dub",
791791
"obj",
792792
"runtime",
793+
// Vendored upstream snapshots — analysing these flags
794+
// findings against code the project does not own.
795+
".yarn",
796+
"idaptik-rescript13-staging",
797+
"rescript-ecosystem",
793798
]
794799
.contains(&name)
795800
{
@@ -859,6 +864,9 @@ impl Analyzer {
859864
"corpus",
860865
"corpora",
861866
"runtime",
867+
// Vendored upstream snapshots — see walk_directory.
868+
"idaptik-rescript13-staging",
869+
"rescript-ecosystem",
862870
]
863871
.contains(&name_str)
864872
{
@@ -7763,4 +7771,72 @@ pub fn safe_get_x() -> Option<String> {
77637771
"unsafe fn / unsafe extern must not count toward the unsafe-block tally"
77647772
);
77657773
}
7774+
7775+
// ---------------------------------------------------------------
7776+
// Vendored-snapshot directory skip
7777+
// ---------------------------------------------------------------
7778+
7779+
fn walk_collects(root: &std::path::Path) -> Vec<std::path::PathBuf> {
7780+
let analyzer = Analyzer::new(std::path::Path::new(".")).expect("analyzer construction");
7781+
let mut files = Vec::new();
7782+
analyzer.walk_directory(root, &mut files).expect("walk");
7783+
files
7784+
}
7785+
7786+
#[test]
7787+
fn walk_skips_yarn_releases() {
7788+
let tmp = TempDir::new().expect("tempdir");
7789+
fs::create_dir_all(tmp.path().join(".yarn/releases")).unwrap();
7790+
fs::write(
7791+
tmp.path().join(".yarn/releases/yarn-4.12.0.cjs"),
7792+
"console.log(eval('1'));",
7793+
)
7794+
.unwrap();
7795+
fs::write(tmp.path().join("real.rs"), "fn main() {}").unwrap();
7796+
let collected = walk_collects(tmp.path());
7797+
assert!(
7798+
!collected.iter().any(|p| p.to_string_lossy().contains(".yarn/")),
7799+
".yarn/ subtree must be skipped"
7800+
);
7801+
assert!(
7802+
collected.iter().any(|p| p.ends_with("real.rs")),
7803+
"non-vendored files must still be walked"
7804+
);
7805+
}
7806+
7807+
#[test]
7808+
fn walk_skips_idaptik_rescript_staging() {
7809+
let tmp = TempDir::new().expect("tempdir");
7810+
let staging = tmp.path().join("idaptik-rescript13-staging/src");
7811+
fs::create_dir_all(&staging).unwrap();
7812+
fs::write(staging.join("v.res"), "let unsafe_thing = ()").unwrap();
7813+
fs::write(tmp.path().join("own.rs"), "fn main() {}").unwrap();
7814+
let collected = walk_collects(tmp.path());
7815+
assert!(
7816+
!collected
7817+
.iter()
7818+
.any(|p| p.to_string_lossy().contains("idaptik-rescript13-staging")),
7819+
"vendored idaptik staging snapshot must be skipped"
7820+
);
7821+
assert!(
7822+
collected.iter().any(|p| p.ends_with("own.rs")),
7823+
"first-party files must still be walked"
7824+
);
7825+
}
7826+
7827+
#[test]
7828+
fn walk_skips_rescript_ecosystem() {
7829+
let tmp = TempDir::new().expect("tempdir");
7830+
let staging = tmp.path().join("rescript-ecosystem/inner");
7831+
fs::create_dir_all(&staging).unwrap();
7832+
fs::write(staging.join("v.res"), "let unsafe_thing = ()").unwrap();
7833+
fs::write(tmp.path().join("own.rs"), "fn main() {}").unwrap();
7834+
let collected = walk_collects(tmp.path());
7835+
assert!(
7836+
!collected
7837+
.iter()
7838+
.any(|p| p.to_string_lossy().contains("rescript-ecosystem")),
7839+
"rescript-ecosystem vendored snapshot must be skipped"
7840+
);
7841+
}
77667842
}

0 commit comments

Comments
 (0)