Broaden orphan candidate detection

This commit is contained in:
2026-04-21 15:29:21 +00:00
parent 987d20ce15
commit 366a7fbf50
5 changed files with 45 additions and 17 deletions

View File

@@ -1,4 +1,4 @@
import { classifyRisk, createCanonicalLocator, detectMediaKind, inferOwnerHint, isCorePublicPath, isStorageAreaPath } from "./path-utils.js";
import { classifyRisk, createCanonicalLocator, detectMediaKind, inferOwnerHint } from "./path-utils.js";
function compareOwner(sourceScope, targetOwner) {
if (!sourceScope) return "unknown";
@@ -128,7 +128,7 @@ export function buildFindings({ files, references, i18n, packageActivity }={}) {
if (detectMediaKind(file.path) === "other") continue;
const refs = matchingReferencesForFile(file, refsByLocator, wildcardReferences);
if (refs.length) continue;
if (!shouldReportOrphan(file, resolvedReferences)) continue;
if (!shouldReportOrphan(file)) continue;
const severity = (file.riskClass === "package-module") || (file.riskClass === "package-system") || (file.riskClass === "release-public")
? "warning"
@@ -223,19 +223,9 @@ function wildcardToRegExp(pattern) {
return new RegExp(`^${escaped}$`, "u");
}
function shouldReportOrphan(file, references) {
function shouldReportOrphan(file) {
if (isDerivedSceneThumbnail(file)) return false;
if (file.riskClass === "stable-world") {
const worldId = file.ownerHint.ownerId;
return references.some(reference => reference.sourceScope?.ownerType === "world" && reference.sourceScope.ownerId === worldId);
}
if ((file.riskClass === "package-module") || (file.riskClass === "package-system")) {
return isStorageAreaPath(file);
}
if (file.riskClass === "release-public") {
return !isCorePublicPath(file);
}
return false;
return true;
}
function isInactiveModuleTarget(file, packageActivity) {