Skip to content
18 changes: 18 additions & 0 deletions crates/dependable-core/src/result.rs
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,24 @@ impl DependencyStatus {
}
}

/// Whether a newer release exists that this dependency could move to.
///
/// The one predicate behind every "there is something to do here" decision:
/// which rows `fix` plans a rewrite for, and which of the rows it cannot
/// rewrite are worth saying so about. Those two answers must be the same set
/// or the two commands contradict each other, which is exactly the defect
/// this replaced three hand-written copies of the same `matches!` to prevent.
///
/// [`Vulnerable`](Self::Vulnerable) counts: a vulnerable-but-current
/// dependency is the one most worth upgrading.
#[must_use]
pub fn has_update(&self) -> bool {
matches!(
self,
Self::PatchAvailable | Self::UpdateAvailable | Self::Outdated | Self::Vulnerable
)
}

/// A stable uppercase token for machine-readable output.
#[must_use]
pub fn token(&self) -> &'static str {
Expand Down
10 changes: 1 addition & 9 deletions crates/dependable-fetch/src/check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,15 +134,7 @@ pub struct ManifestCheck {
impl ManifestCheck {
/// Results that represent an available upgrade (patch/update/outdated/vulnerable).
pub fn outdated(&self) -> impl Iterator<Item = &CheckResult> {
self.results.iter().filter(|r| {
matches!(
r.status,
DependencyStatus::PatchAvailable
| DependencyStatus::UpdateAvailable
| DependencyStatus::Outdated
| DependencyStatus::Vulnerable
)
})
self.results.iter().filter(|r| r.status.has_update())
}

/// Results with known advisories on the current version.
Expand Down
Loading
Loading