Skip to content

Commit

Permalink
Remove prerelease workaround
Browse files Browse the repository at this point in the history
Resolves: #455
  • Loading branch information
Jake-Shadle committed Oct 7, 2022
1 parent 7ecb6bb commit 66bbabe
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 69 deletions.
34 changes: 0 additions & 34 deletions src/advisories.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,40 +81,6 @@ pub fn check<R>(
ctx.krates, pkg,
) {
Some((i, krate)) => {
// This is a workaround for https://github.com/steveklabnik/semver/issues/172,
// it's not strictly correct so we do emit a warning to notify the user
// (though to be honest most people only run cargo-deny in CI and won't notice)
if let Some(versions) = versions {
if !krate.version.pre.is_empty() {
let rematch = semver::Version::new(
krate.version.major,
krate.version.minor,
krate.version.patch,
);

// Patches are usually (always) specified in ascending order,
// so we walk them in reverse to get the closest patch that
// may apply to the crate version in question
for patched in versions.patched().iter().rev() {
if patched.matches(&rematch) {
let skipped_diag =
ctx.diag_for_prerelease_skipped(krate, i, advisory, patched);
sink.push(skipped_diag);
return;
}
}

for unaffected in versions.unaffected().iter().rev() {
if unaffected.matches(&rematch) {
let skipped_diag =
ctx.diag_for_prerelease_skipped(krate, i, advisory, unaffected);
sink.push(skipped_diag);
return;
}
}
}
}

let diag = ctx.diag_for_advisory(krate, i, advisory, versions, |index| {
ignore_hits.as_mut_bitslice().set(index, true);
});
Expand Down
35 changes: 0 additions & 35 deletions src/advisories/diags.rs
Original file line number Diff line number Diff line change
Expand Up @@ -227,39 +227,4 @@ impl<'a> crate::CheckCtx<'a, super::cfg::ValidConfig> {
)
.into()
}

pub(crate) fn diag_for_prerelease_skipped(
&self,
krate: &crate::Krate,
krate_index: krates::NodeId,
advisory: &Metadata,
matched: &semver::VersionReq,
) -> Pack {
let mut pack = Pack::with_kid(Check::Advisories, krate.id.clone());

let notes = {
let mut n = vec![format!("ID: {}", advisory.id)];
if let Some(url) = advisory.id.url() {
n.push(format!("Advisory: {url}"));
}

n.push(format!("Satisfied version requirement: {matched}"));

n
};

pack.push(
Diagnostic::new(Severity::Warning)
.with_message(
"advisory for a crate with a pre-release was skipped as it matched a patch",
)
.with_code("A009")
.with_notes(notes)
.with_labels(vec![self
.krate_spans
.label_for_index(krate_index.index(), "pre-release crate")]),
);

pack
}
}

0 comments on commit 66bbabe

Please sign in to comment.