summaryrefslogtreecommitdiffstats
path: root/tools/test-surface.py
diff options
context:
space:
mode:
authoraur-build <aur-build@localhost>2026-11-21 17:07:56 +0000
committeraur-build <aur-build@localhost>2026-11-21 17:07:56 +0000
commit689b82bfe36660c18cbce66a3f05550c4d02dc12 (patch)
treee5b6fcdea7add1cdb017432fcec9b063c6a045c1 /tools/test-surface.py
parentd96a46ea15cfb7b47ed7b53d2b0465f20fc9b43e (diff)
downloadaur-build-689b82bfe36660c18cbce66a3f05550c4d02dc12.tar.gz
aur-build-689b82bfe36660c18cbce66a3f05550c4d02dc12.zip
error,tools: a variant nothing constructed, and three tool constructs nothing read
`Missing::Snapshot` was declared, rendered by the `Display` arm, and constructed by nothing: `From<&str> for Missing` routes a bare sentence to `Missing::Other`, and the test that mentions a snapshot asserts `Other(_)`. The variant and its formatting arm are gone. A variant scan that counted *mentions* could not see it, because the formatting arm is a mention; the scan now ignores a line that only renders the variant, and what it reports afterwards is `Error::Json` and `Error::Sqlite`, both of which the compiler proves live — deleting either breaks the hundred-odd `?` sites that reach them through `#[from]`. Three survivors in `tools/`, none of them caught by the audit that claimed the axis was empty, because that audit looked at module-level constants and function parameters and never at local bindings: - `test-surface.py` opened `render()` with `out = [...] if False else []`, a literal dead branch whose binding was then never read. Both gone. - `test-surface.py` computed a `collisions` set that nothing consulted; the rule it narrated had moved into `mentioned` as `sole_owner`. The set is deleted and the explanation now sits in the docstring of the function that applies it. - `release-surface-probe.py` built `decl_line` and used `decl_no` instead. `a, b = item.split(" as ", 1)` became `_, b = ..` for the same reason. The scans now cover locals and constant conditions as well, and report nothing: no unread binding, no `if False`, no unreachable statement after a terminator, no unused import, constant, parameter, or unread argparse option across the five tools.
Diffstat (limited to 'tools/test-surface.py')
-rw-r--r--tools/test-surface.py21
1 files changed, 8 insertions, 13 deletions
diff --git a/tools/test-surface.py b/tools/test-surface.py
index ae5a78f..4110c06 100644
--- a/tools/test-surface.py
+++ b/tools/test-surface.py
@@ -333,7 +333,7 @@ def use_prefixes(path):
if item == "self":
out.setdefault(base.split("::")[-1], top)
elif " as " in item:
- a, b = item.split(" as ", 1)
+ _, b = item.split(" as ", 1)
out.setdefault(b.strip(), top)
else:
out.setdefault(item, top)
@@ -432,17 +432,6 @@ def analyse():
# to the module that published it: `notice_kind` routes to `db`.
ALIAS_TOP = {(m, n): m for (m, n) in REEXPORTS}
- # A bare mention in another module cannot be resolved to one item when the
- # same name is declared in several modules — `new`, `parse` and `open` are
- # declared all over the crate, and a line saying `Foo::new()` in `http` says
- # nothing about `db::open`. For a colliding name a mention counts only if
- # the line actually routes through the declaring module: a qualified path
- # (`db::open`, `crate::db::open`) or a `use` that imports from it. A
- # colliding name with unqualified mentions is kept and flagged, because the
- # honest answer is "a line-based tool cannot tell" and a human should.
- collisions = {name for (mod, name) in names if
- len({m for (m, n) in names if n == name}) > 1}
-
def mentioned(line, mod, name, prefixes, file_mod):
"""Does this line show production reaching `mod::name`?
@@ -458,6 +447,13 @@ def analyse():
`review`, and production calls it `candidates::mark_viewed`. And the
unresolvable cases are mostly std and local names wearing a crate item's
name: `Vec::new()`, `v.parse::<u64>()`, `stop.load(..)`.
+
+ A name declared in several modules — `new`, `parse` and `open` are
+ declared all over the crate — is the hard case: a line saying
+ `Foo::new()` in `http` says nothing about `db::open`, so a mention of a
+ colliding name counts only when the line routes through the declaring
+ module, and an unqualified mention of one is flagged for a human rather
+ than guessed at.
"""
top = mod.split(os.sep)[0]
# A method name declared in exactly one module is safe to credit: there
@@ -634,7 +630,6 @@ def render(rows):
"already-gated": "Already gated",
"interface": "Public because a public signature requires it; no test asked for it",
"narrowed": "Feature-conditional visibility — production uses it, only from inside its module"}
- out = [open(DOC).read().split("## gate-marker")[0]] if False else []
L = []
A = L.append
A("# The test surface: every `pub` item that exists because a test names it\n")