mirror of
https://github.com/norandom/OpenUltraSAST.git
synced 2026-10-18 12:39:28 +00:00
fix(contributor-scan): retain declared Gruntfile and report census gaps honestly
This commit is contained in:
@@ -106,6 +106,9 @@ class PartitionGraph:
|
||||
raw = batch(kind, selected) if callable(batch) else {rid: graph.run(kind, params) for rid, params in selected.items()}
|
||||
if not isinstance(raw, Mapping):
|
||||
continue
|
||||
raw = dict(raw)
|
||||
if not isinstance(raw.get("__census__"), list):
|
||||
raw["__census__"] = []
|
||||
for rid, rows in raw.items():
|
||||
if rid in selected and isinstance(rows, list):
|
||||
answers[rid] = self._normalize(rows)
|
||||
@@ -117,17 +120,18 @@ class PartitionGraph:
|
||||
observed = {p.removeprefix("./") for n in names if isinstance(n, list) for p in n if isinstance(p, str)}
|
||||
if not named or not expected <= observed:
|
||||
self.diagnostics.append("partition_file_census_incomplete" if named else "partition_file_census_unavailable")
|
||||
reason = "partition_file_census_incomplete" if named else "partition_file_census_unavailable"
|
||||
rows = [
|
||||
{
|
||||
"methods": 0,
|
||||
"files": 0,
|
||||
"shards": max((int(str(r.get("shards", 1))) for r in rows if isinstance(r, Mapping)), default=1),
|
||||
}
|
||||
]
|
||||
dict(r, census_failure=reason, missing_file_names=sorted(expected - observed) if named else [])
|
||||
for r in normalized
|
||||
if isinstance(r, Mapping)
|
||||
] or [{"census_failure": reason, "missing_file_names": []}]
|
||||
# Preserve any individual empty or sharded graph's degradation.
|
||||
previous = answers.get(rid, [])
|
||||
if not previous or any(
|
||||
isinstance(r, Mapping) and (int(str(r.get("methods", 0))) == 0 or int(str(r.get("shards", 1))) > 1) for r in rows
|
||||
isinstance(r, Mapping)
|
||||
and (r.get("census_failure") or int(str(r.get("methods", 0))) == 0 or int(str(r.get("shards", 1))) > 1)
|
||||
for r in rows
|
||||
):
|
||||
answers[rid] = rows
|
||||
return answers
|
||||
|
||||
@@ -355,6 +355,8 @@ def _scan_repository_impl(
|
||||
in {
|
||||
"files_unparsed",
|
||||
"cpg_empty",
|
||||
"partition_file_census_incomplete",
|
||||
"partition_file_census_unavailable",
|
||||
"cpg_sharded",
|
||||
"cross_partition_semantics_unresolved",
|
||||
"vendor_semantics_unresolved",
|
||||
@@ -410,8 +412,14 @@ def _scan_repository_impl(
|
||||
if census and not census_reported:
|
||||
entry = census[0] if isinstance(census[0], Mapping) else {}
|
||||
methods = int(str(entry.get("methods", "0")) or 0)
|
||||
if methods == 0:
|
||||
degradations.append({"stage": "model", "reason": "cpg_empty", "files": int(str(entry.get("files", "0")) or 0)})
|
||||
if methods == 0 or entry.get("census_failure"):
|
||||
degradations.append(
|
||||
{
|
||||
"stage": "model",
|
||||
"reason": "cpg_empty" if "methods" in entry and methods == 0 else entry.get("census_failure", "cpg_empty"),
|
||||
**{k: entry[k] for k in ("methods", "files", "missing_file_names") if k in entry},
|
||||
}
|
||||
)
|
||||
# More than one graph means some files could only be built apart from the rest, and a
|
||||
# flow whose source is in one shard and whose sink is in another does not exist for any
|
||||
# question we can ask. Reporting the split is the difference between a partial answer and
|
||||
@@ -508,6 +516,8 @@ def _scan_repository_impl(
|
||||
in {
|
||||
"files_unparsed",
|
||||
"cpg_empty",
|
||||
"partition_file_census_incomplete",
|
||||
"partition_file_census_unavailable",
|
||||
"cpg_sharded",
|
||||
"cross_partition_semantics_unresolved",
|
||||
"vendor_semantics_unresolved",
|
||||
@@ -741,8 +751,14 @@ def _evidence_pass(
|
||||
shards = int(str(entry.get("shards", "1")))
|
||||
except ValueError:
|
||||
methods, shards = 0, 1
|
||||
if methods <= 0:
|
||||
degradations.append({"stage": "model", "reason": "cpg_empty"})
|
||||
if methods <= 0 or entry.get("census_failure"):
|
||||
degradations.append(
|
||||
{
|
||||
"stage": "model",
|
||||
"reason": "cpg_empty" if "methods" in entry and methods <= 0 else entry.get("census_failure", "cpg_empty"),
|
||||
**{k: entry[k] for k in ("methods", "files", "missing_file_names") if k in entry},
|
||||
}
|
||||
)
|
||||
if shards > 1:
|
||||
degradations.append({"stage": "model", "reason": "cpg_sharded", "shards": shards})
|
||||
by_rid = {rid: (region, spec) for rid, region, spec in work}
|
||||
|
||||
Reference in New Issue
Block a user