summaryrefslogtreecommitdiffstats
path: root/src/db/candidates.rs
diff options
context:
space:
mode:
authoraur-build <aur-build@localhost>2026-11-21 13:28:55 +0000
committeraur-build <aur-build@localhost>2026-11-21 13:28:55 +0000
commit48fecfe03be4f214eaf4f9c49cb3c27496bb74ba (patch)
tree432f6e32351df60d36a115561c1bf8b8013c5430 /src/db/candidates.rs
parenta200edaac2056dd9c85d6bddff3ca181f0cc277e (diff)
downloadaur-build-48fecfe03be4f214eaf4f9c49cb3c27496bb74ba.tar.gz
aur-build-48fecfe03be4f214eaf4f9c49cb3c27496bb74ba.zip
src: narrow what only its own module reads, and delete what nothing reads at all
The census's 35 `deadonly` items were a lead, not a verdict, and the compiler answered it: 17 of them are read only inside their own module and were declared `pub` for no reason, so they are `pub(crate)` now — `db::OpenReview` and its two queries, `ReviewSubject` and its query, `fetch::Body`, `http`'s `form_get`, `query_get` and `Page::flash`, `ops::EvictPlan`, `usecase`'s `StageB`… — and two are read by nobody: `ReleaseState::can_transition` and `SubscriptionState::can_transition`, both already annotated "nothing consults this table today", which is the definition of dead rather than the argument for keeping. Narrowing them is what made the compiler look harder, and it found three more: `ReviewSubject::pkgbase` was selected out of the database and never read, `StageB::cached` was written in three places and never read, and `StageB::version` was never called. All gone, the SELECT column with them. The other 18 cannot be narrowed and now say so, once at the declaration and once in the budget file: a row type the `aur-build` binary binds without naming (`PackageRow`, `Checked`, `GcPlan`, `Prepared`), a type behind a `pub` fn a test calls (`Unbuilt`, `BulkItem`, `StageA`, `CheckReport`, `PkgInfo`, `Installed`, `Subscription`, `Manifest`), a trait a public test provisioner implements (`Provisioner`, `ProvisionRequest`), and three that a release build never even compiles because their module is `test-support`-gated (`shims::*`, `VirtualClock`). `deadonly` therefore means *dead and unargued* now: an allowlisted item leaves the dead columns, which is the only way the number can be held at zero forever. 448 pub, 49 dead, 0 unargued; 284 tests pass, one ignored, none lost.
Diffstat (limited to 'src/db/candidates.rs')
-rw-r--r--src/db/candidates.rs14
1 files changed, 6 insertions, 8 deletions
diff --git a/src/db/candidates.rs b/src/db/candidates.rs
index e2f011c..411d60b 100644
--- a/src/db/candidates.rs
+++ b/src/db/candidates.rs
@@ -53,7 +53,7 @@ impl NewCandidate {
}
#[derive(Debug, Clone)]
-pub struct OpenReview {
+pub(crate) struct OpenReview {
pub id: i64,
pub identity_hash: String,
pub viewed_at: Option<String>,
@@ -69,7 +69,7 @@ impl OpenReview {
// ------------------------------------------------------------------ in-tx --
#[derive(Debug, Clone)]
-pub struct ReviewSubject {
+pub(crate) struct ReviewSubject {
pub id: i64,
pub pkgbase_id: i64,
pub state: CandidateState,
@@ -78,14 +78,13 @@ pub struct ReviewSubject {
pub base_release_id: Option<i64>,
pub current_base_release_id: Option<i64>,
pub risk_level: String,
- pub pkgbase: String,
}
-pub fn review_subject_in(tx: &Transaction<'_>, candidate_id: i64) -> Result<Option<ReviewSubject>> {
+pub(crate) fn review_subject_in(tx: &Transaction<'_>, candidate_id: i64) -> Result<Option<ReviewSubject>> {
Ok(tx
.query_row(
"SELECT c.id, c.pkgbase_id, c.state, c.identity_hash, c.diff_digest, c.base_release_id,
- p.current_accepted_release_id, c.risk_level, p.name
+ p.current_accepted_release_id, c.risk_level
FROM candidate c JOIN pkgbase p ON p.id = c.pkgbase_id
WHERE c.id = ?1",
params![candidate_id],
@@ -99,7 +98,6 @@ pub fn review_subject_in(tx: &Transaction<'_>, candidate_id: i64) -> Result<Opti
base_release_id: r.get(5)?,
current_base_release_id: r.get(6)?,
risk_level: r.get(7)?,
- pkgbase: r.get(8)?,
})
},
)
@@ -151,7 +149,7 @@ pub fn risk_level(db: &Db, id: i64) -> Result<Option<String>> {
})
}
-pub fn open_in(tx: &Transaction<'_>, pkgbase_id: i64) -> Result<Option<OpenReview>> {
+pub(crate) fn open_in(tx: &Transaction<'_>, pkgbase_id: i64) -> Result<Option<OpenReview>> {
Ok(tx
.query_row(
"SELECT id, identity_hash, viewed_at, revision FROM candidate
@@ -169,7 +167,7 @@ pub fn open_in(tx: &Transaction<'_>, pkgbase_id: i64) -> Result<Option<OpenRevie
.optional()?)
}
-pub fn collapse_in(tx: &mut Transaction<'_>, open: &OpenReview, nc: &NewCandidate) -> Result<i64> {
+pub(crate) fn collapse_in(tx: &mut Transaction<'_>, open: &OpenReview, nc: &NewCandidate) -> Result<i64> {
let revision = open.revision + 1;
tx.execute(
"UPDATE candidate SET snapshot_id=?1, epoch=?2, pkgver=?3, pkgrel=?4,