Skip to content

Commit 3779708

Browse files
committed
Add --no-dev flag to skip dev-dependencies
Closes #607. The false positive only fires when the dev-dep crate is resolvable in the scanned tree, so the test fixture depends on rand 0.8 directly to recreate it. xz2 is flagged without the flag, clean with it.
1 parent f1568ba commit 3779708

11 files changed

Lines changed: 236 additions & 0 deletions

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ Options:
7474
repository to be considered current; 0 effectively disables this check,
7575
though ages are still reported [default: 365]
7676
--no-cache Do not cache data on disk for future runs
77+
--no-dev Do not consider dev-dependencies
7778
--no-exit-code Do not set exit status when unmaintained packages are found
7879
--no-warnings Do not show warnings
7980
-p, --package <NAME> Check only whether package NAME is unmaintained

fixtures/dev-dependencies/Cargo.lock

Lines changed: 182 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
[package]
2+
name = "dev-dependencies"
3+
version = "0.1.0"
4+
edition = "2024"
5+
6+
[dependencies]
7+
rand = "0.8"
8+
xz2 = "0.1.7"

fixtures/dev-dependencies/src/lib.rs

Whitespace-only changes.

src/lib.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,9 @@ struct Opts {
139139
#[clap(long, help = "Do not cache data on disk for future runs")]
140140
no_cache: bool,
141141

142+
#[clap(long, help = "Do not consider dev-dependencies")]
143+
no_dev: bool,
144+
142145
#[clap(
143146
long,
144147
help = "Do not set exit status when unmaintained packages are found",
@@ -796,6 +799,9 @@ fn outdated_deps<'a>(metadata: &'a Metadata, pkg: &'a Package) -> Result<Vec<Out
796799
if dep.path.is_some() {
797800
continue;
798801
}
802+
if opts::get().no_dev && dep.kind == DependencyKind::Development {
803+
continue;
804+
}
799805
let Some(dep_pkg) = find_packages(metadata, dep.into()).next() else {
800806
debug_assert!(dep.kind == DependencyKind::Development || dep.optional);
801807
continue;

tests/cases/dev-dependencies.json

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
[
2+
{
3+
"name": "rand_chacha",
4+
"outdated_deps": [],
5+
"repo_status": "Unassociated",
6+
"version": "0.3.1"
7+
},
8+
{
9+
"name": "xz2",
10+
"outdated_deps": [
11+
{
12+
"name": "rand",
13+
"req": "^0.8.0",
14+
"version_latest": null,
15+
"version_used": "0.8.6"
16+
}
17+
],
18+
"repo_status": {
19+
"Age": null
20+
},
21+
"version": "0.1.7"
22+
}
23+
]
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Prefetching GitHub data for 15 repositories
2+
Scanning 20 packages and their dependencies (pass --verbose for more information)

tests/cases/dev-dependencies.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
path = "fixtures/dev-dependencies"
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
[
2+
{
3+
"name": "rand_chacha",
4+
"outdated_deps": [],
5+
"repo_status": "Unassociated",
6+
"version": "0.3.1"
7+
}
8+
]
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Prefetching GitHub data for 15 repositories
2+
Scanning 20 packages and their dependencies (pass --verbose for more information)

0 commit comments

Comments
 (0)