chore(rust/clippy): pedantic, nursery, and some#12209
Conversation
Apply clippy's machine-applicable pedantic fixes across the workspace (inlined format args, removed needless borrows/closures, added must_use, etc.), fix a few doc-comment backtick nits, and drop pointless #[inline(always)] on trivial accessors. Opt specific pedantic lints back out in [workspace.lints.clippy] with documented justifications, grouped into false positives, library-API hygiene that doesn't fit an internal CLI, suggestions that conflict with the cardinal rule of porting pnpm 1:1, and opinionated style.
|
Important Review skippedToo many files! This PR contains 300 files, which is 150 over the limit of 150. To get a review, narrow the scope: ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (300)
You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Micro-Benchmark ResultsLinux |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #12209 +/- ##
==========================================
- Coverage 87.70% 87.69% -0.01%
==========================================
Files 289 289
Lines 35610 35550 -60
==========================================
- Hits 31231 31175 -56
+ Misses 4379 4375 -4 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Integrated-Benchmark Report (Linux)Each scenario reports direct installs and pnpr installs. Bencher consumes pacquet@HEAD and pnpr@HEAD. Scenario: Isolated linker: fresh restore, cold cache + cold store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 10.287718022419998,
"stddev": 0.11222301138632337,
"median": 10.24064199772,
"user": 3.2973355599999996,
"system": 3.2480421199999996,
"min": 10.18247804072,
"max": 10.54308726172,
"times": [
10.230297393719999,
10.386097509719999,
10.198442911719999,
10.28109281472,
10.21153109672,
10.18247804072,
10.36286919972,
10.54308726172,
10.25021002372,
10.231073971719999
]
},
{
"command": "pacquet@main",
"mean": 10.34314045322,
"stddev": 0.14796278579963112,
"median": 10.280119091220001,
"user": 3.35120076,
"system": 3.2590924200000004,
"min": 10.19538302172,
"max": 10.591478477719999,
"times": [
10.32771313472,
10.58420292972,
10.28360797172,
10.27388396372,
10.21334417972,
10.27663021072,
10.45565514372,
10.19538302172,
10.591478477719999,
10.22950549872
]
},
{
"command": "pnpr@HEAD",
"mean": 5.3537672356199995,
"stddev": 0.07262273796693952,
"median": 5.33560900372,
"user": 2.5761539599999996,
"system": 2.9443005199999996,
"min": 5.28220615672,
"max": 5.5243000447199995,
"times": [
5.31635737672,
5.28925006172,
5.34707738572,
5.38744797772,
5.5243000447199995,
5.3928453767199995,
5.28220615672,
5.37919885372,
5.32414062172,
5.29484850072
]
},
{
"command": "pnpr@main",
"mean": 5.380347422919999,
"stddev": 0.11716093175286822,
"median": 5.342706092719999,
"user": 2.6013003599999998,
"system": 2.9085484200000002,
"min": 5.29103919272,
"max": 5.65396972772,
"times": [
5.344006139719999,
5.40816408172,
5.342439907719999,
5.3429722777199995,
5.51265624072,
5.29997946172,
5.31366084872,
5.29103919272,
5.65396972772,
5.2945863507199995
]
}
]
}Scenario: Isolated linker: fresh restore, hot cache + hot store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 0.6527910082000001,
"stddev": 0.010366416492487993,
"median": 0.6548038664,
"user": 0.37166836000000003,
"system": 1.319448,
"min": 0.6331575554000001,
"max": 0.6683802624,
"times": [
0.6620638354,
0.6572169634,
0.6598622484000001,
0.6487057394000001,
0.6574840604000001,
0.6683802624,
0.6523907694000001,
0.6436741994,
0.6331575554000001,
0.6449744484000001
]
},
{
"command": "pacquet@main",
"mean": 0.6947479963000001,
"stddev": 0.09134943405736423,
"median": 0.6644833719000001,
"user": 0.39258186000000006,
"system": 1.3241995000000002,
"min": 0.6547333334000001,
"max": 0.9529743564000001,
"times": [
0.6933277584,
0.6663047834000001,
0.6696035634,
0.6547333334000001,
0.9529743564000001,
0.6609481524,
0.6611477124,
0.6626619604,
0.6580788694,
0.6676994734
]
},
{
"command": "pnpr@HEAD",
"mean": 0.7648042452000001,
"stddev": 0.019229818932810668,
"median": 0.7585245474,
"user": 0.39261866,
"system": 1.328843,
"min": 0.7468795764,
"max": 0.8046636724,
"times": [
0.7660963464,
0.7543838794000001,
0.7468795764,
0.7546546114,
0.7714435774,
0.7900484294000001,
0.7623944834,
0.7495733254000001,
0.8046636724,
0.7479045504
]
},
{
"command": "pnpr@main",
"mean": 0.7564689724000001,
"stddev": 0.01911238635682458,
"median": 0.7452540639,
"user": 0.38665286000000004,
"system": 1.3312613000000002,
"min": 0.7382549534,
"max": 0.7845480414,
"times": [
0.7430641494000001,
0.7382549534,
0.7397941824,
0.7404984524,
0.7699960644,
0.7784409294000001,
0.7845480414,
0.7464643884000001,
0.7795848234,
0.7440437394
]
}
]
}Scenario: Isolated linker: fresh install, cold cache + cold store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 9.2967246804,
"stddev": 0.05488100950430872,
"median": 9.2727284392,
"user": 3.7419807,
"system": 3.2978592399999997,
"min": 9.236822583199999,
"max": 9.4156989112,
"times": [
9.4156989112,
9.319436250199999,
9.2618122682,
9.307075312199999,
9.2603094112,
9.262030548199998,
9.2751622752,
9.2702946032,
9.3586046412,
9.236822583199999
]
},
{
"command": "pacquet@main",
"mean": 9.2784294994,
"stddev": 0.030982340452410943,
"median": 9.2873665257,
"user": 3.7450223,
"system": 3.30362534,
"min": 9.2111276842,
"max": 9.3165109742,
"times": [
9.296415976199999,
9.3165109742,
9.2899780592,
9.2609257932,
9.2847549922,
9.266605966199998,
9.254545066199999,
9.3072572592,
9.2111276842,
9.296173223199999
]
},
{
"command": "pnpr@HEAD",
"mean": 5.0992545712,
"stddev": 0.05025223214001015,
"median": 5.1013220957000005,
"user": 2.4235525,
"system": 2.8048152399999995,
"min": 5.0175774122000005,
"max": 5.1948086142,
"times": [
5.1275510632,
5.1948086142,
5.1059282322,
5.1281108652,
5.048812062200001,
5.0768896052,
5.1311974822,
5.0649544162,
5.0967159592,
5.0175774122000005
]
},
{
"command": "pnpr@main",
"mean": 5.0968938318,
"stddev": 0.07034638408020151,
"median": 5.0634850912000005,
"user": 2.4029719,
"system": 2.7883799399999996,
"min": 5.0296217582,
"max": 5.2197839082,
"times": [
5.1370179062000005,
5.2196569542,
5.053051050200001,
5.0717160822,
5.0570461262,
5.0666116972,
5.0603584852,
5.2197839082,
5.0296217582,
5.0540743502000005
]
}
]
}Scenario: Isolated linker: fresh install, hot cache + hot store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 1.4549940344599999,
"stddev": 0.016010420867032187,
"median": 1.45699365156,
"user": 1.57785566,
"system": 1.80852104,
"min": 1.4327582455599999,
"max": 1.4836849405599999,
"times": [
1.45783882056,
1.43877845656,
1.4836849405599999,
1.45614848256,
1.44155226556,
1.46321753656,
1.46941113656,
1.4327582455599999,
1.44198442156,
1.46456603856
]
},
{
"command": "pacquet@main",
"mean": 1.4521215013600002,
"stddev": 0.015311631146987931,
"median": 1.44613895756,
"user": 1.5983041599999999,
"system": 1.8066429400000001,
"min": 1.43533539256,
"max": 1.48430626656,
"times": [
1.48430626656,
1.43533539256,
1.46144600156,
1.44643154556,
1.43669844956,
1.46400103456,
1.44466373756,
1.44584636956,
1.46118110256,
1.44130511356
]
},
{
"command": "pnpr@HEAD",
"mean": 0.68758999536,
"stddev": 0.013301580818236543,
"median": 0.6817417350600001,
"user": 0.32449606,
"system": 1.3041495400000003,
"min": 0.6743542785600001,
"max": 0.7181357365600001,
"times": [
0.7181357365600001,
0.68071441456,
0.6761933535600001,
0.6793606955600001,
0.69497688156,
0.6908779145600001,
0.68251407356,
0.6978032085600001,
0.6743542785600001,
0.6809693965600001
]
},
{
"command": "pnpr@main",
"mean": 0.6947597740600002,
"stddev": 0.07897181131041081,
"median": 0.6716651400600001,
"user": 0.33134705999999997,
"system": 1.27741544,
"min": 0.6530776485600001,
"max": 0.9169577695600001,
"times": [
0.69675029056,
0.6702130875600001,
0.6638653245600001,
0.9169577695600001,
0.6731171925600001,
0.6568387525600001,
0.6675660495600001,
0.6530776485600001,
0.6750162235600001,
0.6741954015600001
]
}
]
}Scenario: Isolated linker: fresh install, cold cache + hot store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 5.0766420854200005,
"stddev": 0.02456406908129996,
"median": 5.07702000952,
"user": 1.7843182599999998,
"system": 1.9633979200000002,
"min": 5.036657656519999,
"max": 5.108624509519999,
"times": [
5.036657656519999,
5.04777422752,
5.108624509519999,
5.05900120752,
5.087984362519999,
5.10269436652,
5.066170684519999,
5.10347382052,
5.073338222519999,
5.08070179652
]
},
{
"command": "pacquet@main",
"mean": 5.107935138319999,
"stddev": 0.022591563758594238,
"median": 5.11468221152,
"user": 1.8477540599999998,
"system": 2.00990162,
"min": 5.07376243552,
"max": 5.14247181052,
"times": [
5.0946996555199995,
5.07376243552,
5.09023673952,
5.078770135519999,
5.1145381175199995,
5.126687674519999,
5.11562540752,
5.12773310152,
5.114826305519999,
5.14247181052
]
},
{
"command": "pnpr@HEAD",
"mean": 0.69644714752,
"stddev": 0.009626016112580984,
"median": 0.6969169235200001,
"user": 0.34141386,
"system": 1.3299561199999999,
"min": 0.68077654752,
"max": 0.71153033452,
"times": [
0.69712195052,
0.69482140552,
0.71153033452,
0.7001830145200001,
0.6981730075200001,
0.7081030785200001,
0.6967118965200001,
0.68077654752,
0.6822247275200001,
0.69482551252
]
},
{
"command": "pnpr@main",
"mean": 0.7263233949200001,
"stddev": 0.05861037097975595,
"median": 0.7087875545200001,
"user": 0.33987636,
"system": 1.31497062,
"min": 0.6799488865200001,
"max": 0.88021304852,
"times": [
0.73367804252,
0.6939449925200001,
0.68649713152,
0.88021304852,
0.7548281665200001,
0.70591062952,
0.6799488865200001,
0.72051661552,
0.69603195652,
0.7116644795200001
]
}
]
} |
|
| Branch | pr/12209 |
| Testbed | pacquet |
Click to view all benchmark results
| Benchmark | Latency | Benchmark Result milliseconds (ms) (Result Δ%) | Upper Boundary milliseconds (ms) (Limit %) |
|---|---|---|---|
| isolated-linker.fresh-install.cold-cache.cold-store | 📈 view plot 🚷 view threshold | 9,296.72 ms(+18.12%)Baseline: 7,870.61 ms | 9,444.73 ms (98.43%) |
| isolated-linker.fresh-install.cold-cache.hot-store | 📈 view plot 🚷 view threshold | 5,076.64 ms(+1.09%)Baseline: 5,022.02 ms | 6,026.43 ms (84.24%) |
| isolated-linker.fresh-install.hot-cache.hot-store | 📈 view plot 🚷 view threshold | 1,454.99 ms(+2.63%)Baseline: 1,417.71 ms | 1,701.25 ms (85.52%) |
| isolated-linker.fresh-restore.cold-cache.cold-store | 📈 view plot 🚷 view threshold | 10,287.72 ms(+6.44%)Baseline: 9,665.28 ms | 11,598.33 ms (88.70%) |
| isolated-linker.fresh-restore.hot-cache.hot-store | 📈 view plot 🚷 view threshold | 652.79 ms(-0.75%)Baseline: 657.75 ms | 789.30 ms (82.70%) |
Convert two self-less private methods (overrides pick_most_specific, tarball head_only_result) to associated functions.
Widen engine_json to Option<&str>; #[expect] the two serde serialize_with helpers, which serde must call as f(&field, ser).
Pass the 1-byte Copy types NodeLinker and FilterWorkspaceProjectsOptions by value; #[expect] the serde skip_serializing_if helper is_false.
Use clone_from for seven field assignments to reuse allocations.
Convert 27 match/if-let guards to let-else; preserve the non-UTF-8 skip rationale comment in the directory walker.
Name the concrete type on Default::default() call sites; #[expect] two struct-literal test fixtures where naming each field type would force ~20 imports.
Replace push_str(&format!(...)) with write!/writeln! into the target String (local 'use std::fmt::Write as _'); writeln! preserves the exact LF/CRLF shell-shim output.
Take by reference where the argument is only read (incl. dropping some redundant clones in resolve_peers' recursion). Where converting would cascade badly, #[expect] with a reason: functions that destructure/consume the arg (build_resolve_result, PrefetchingResolver, S3Store::new), the by-value `impl IntoIterator + Clone` in build_direct_deps_by_importer, and the serde/test helpers whose owned fixtures keep call sites clean.
Add trailing commas to the multi-line writeln! shell-shim templates
(macro_trailing_comma) and merge the new `fmt::Write as _` imports into
each file's existing `use std::{...}` block (import_granularity).
…nics_doc deferred
The format_push_string Write import landed as a sibling fmt:: path next to the existing fmt import; merge them so import_granularity passes.
Add #[must_use] to the WorkspaceTreeCtx builder methods, matching the #[must_use] already on the parallel TreeCtx builders.
Heap-allocate the 64 KiB read buffer in verify_file_integrity with a Vec instead of placing it on the stack.
db4bac8 to
dfaf2aa
Compare
Enable the nursery lint group on the pacquet/pnpr workspace and bring the code into compliance. Fixed in code: - iter_on_single_items: [x].into_iter()/.iter() -> std::iter::once - equatable_if_let: pattern match -> equality check (the install_accelerator rewrite wraps in a multi-line matches!, which gets a trailing comma for perfectionist::macro_trailing_comma) - needless_pass_by_ref_mut: load_pending_row/apply_write_msg take &StoreIndex Opted back out in Cargo.toml, each with a documented justification: use_self, too_long_first_doc_paragraph, missing_const_for_fn, option_if_let_else, significant_drop_tightening, redundant_pub_crate, derive_partial_eq_without_eq, branches_sharing_code, useless_let_if_seq, single_option_map, iter_with_drain, literal_string_with_formatting_args, collection_is_never_read. Dropped the now-redundant individual nursery warns (needless_collect, or_fun_call, redundant_clone) the group now covers, plus the default-on unnecessary_lazy_evaluations. Kept clone_on_ref_ptr and if_then_some_else_none (restriction lints not enabled by any group).
48fcc6f to
c72ff84
Compare
Integrate the 17 commits main gained since this branch forked (pnpr server-side resolve refactor, cold-batch linking perf, tarball CAS parallelism, dependency bumps, and the bare-#NNN commit-msg hook). Conflict resolution: - pnpr install_accelerator module: main refactored it into the resolver module (renaming protocol/resolve/verdict_cache, dropping the grant_table/public_packages server-side gating). Took main's version and dropped this branch's now-stale clippy edits to the deleted files. - create_virtual_store, pnpr-client integration test, integrated-benchmark, registry-mock pnpr_command, pnpr s3: took main's authoritative newer implementations; this branch only carried stale snapshots plus lint edits, which are re-derived by re-running clippy. - Cargo.toml: kept this branch's lint configuration alongside main's dependency bumps.
The 17 commits merged from main predate this branch's pedantic/nursery lint config, so their new code tripped pedantic lints. Apply the machine-applicable fixes (uninlined_format_args, if_not_else, elidable_lifetime_names, must_use_candidate, single_match_else, map_unwrap_or, default_trait_access, assigning_clones, doc_markdown, ...) and re-add the documented #[expect(needless_pass_by_value)] on S3Store::new that this branch had carried on the now-replaced file.
Integrate the 28 commits main gained (pacquet config-dependency support, security hardening for runtime/registry signature verification, lockfile format parity work, overrides/peer-resolution fixes, perf passes, and dependency bumps). Conflict resolution: all eight conflicts (cmd-shim/config/lockfile/ package-manager/resolving-deps-resolver/integrated-benchmark) were between this branch's lint edits and main's feature changes — took main's authoritative versions; the lint compliance is re-derived by re-running clippy in the follow-up commit.
The 28 commits merged from main predate this branch's lint config, so their new code tripped pedantic lints. Apply the machine-applicable fixes (uninlined_format_args, manual_let_else, needless_raw_string_hashes, redundant_closure_for_method_calls, map_unwrap_or, elidable_lifetime_names, doc_markdown, ...) plus a few by hand: - derive Copy on LinkSlotsParallel (all fields are Copy/refs) to clear needless_pass_by_value without a signature change - deduplicate_all takes &[Vec<DepPath>] (it only borrows the duplicates) - pick_most_specific becomes an associated fn (it never used self) - default_trait_access -> concrete types; assigning_clones -> clone_from; format_push_string -> write! - #[expect] with reasons where a fix would churn main's feature code: needless_pass_by_value on the recursive resolve_node and a test helper, and float_cmp on two deterministic-fixture assertions
…eason Both are restriction lints (not implied by any group), enabled alongside the existing clone_on_ref_ptr / if_then_some_else_none. Convert every #[allow(...)] (including one nested in cfg_attr) to #[expect(...)]; all already carried a reason, so allow_attributes_without_reason is satisfied. Drop two now-redundant suppressions surfaced by the conversion: a duplicated #[expect(too_many_arguments)] on fetch_and_extract_zip_once (a prior merge left both an allow and an expect), and the #[expect(dead_code)] on MissingPeerInfo's fields (the #[derive(Debug, Clone)] already reads them, so dead_code never fired). clone_on_ref_ptr was already enabled. mod_module_files is intentionally NOT enabled: it mandates mod.rs, the opposite of the flat module.rs pattern this project requires (CODE_STYLE_GUIDE.md, enforced by perfectionist::flat_module_pattern).
mod_module_files bans mod.rs files, enforcing the flat module.rs pattern this project already uses (0 mod.rs in the tree, so no violations). Update CODE_STYLE_GUIDE.md to cite it as the enforcer; perfectionist's flat_module_pattern is being retired in favor of this Clippy rule.
…_yaml tests The default_trait_access fix lengthened the assert_eq! so fmt wrapped it to multi-line, which perfectionist::macro_trailing_comma requires to end with a trailing comma.
… args With clippy::allow_attributes enabled, the #[cfg_attr(windows, allow(unused))] on make_file_executable and the ensure_file/write_atomic mode params fails Windows CI. Switch to #[cfg_attr(windows, expect(unused, reason = ...))]; on Windows the lint fires (Unix mode unused there) so the expectation is fulfilled, and the attribute stays inert on Unix.
ensure_file forwards mode to verify_or_rewrite unconditionally, so it is used on Windows too; the #[cfg_attr(windows, expect(unused))] was therefore unfulfilled and failed Windows CI under -D warnings. write_atomic and make_file_executable keep their expect — they use mode/file only under #[cfg(unix)], so the lint fires (and the expectation holds) on Windows.
|
| Branch | pr/12209 |
| Testbed | pnpr |
⚠️ WARNING: No Threshold found!Without a Threshold, no Alerts will ever be generated.
Click here to create a new Threshold
For more information, see the Threshold documentation.
To only post results if a Threshold exists, set the--ci-only-thresholdsflag.
Click to view all benchmark results
| Benchmark | Latency | milliseconds (ms) |
|---|---|---|
| isolated-linker.fresh-install.cold-cache.cold-store | 📈 view plot | 5,099.25 ms |
| isolated-linker.fresh-install.cold-cache.hot-store | 📈 view plot | 696.45 ms |
| isolated-linker.fresh-install.hot-cache.hot-store | 📈 view plot | 687.59 ms |
| isolated-linker.fresh-restore.cold-cache.cold-store | 📈 view plot | 5,353.77 ms |
| isolated-linker.fresh-restore.hot-cache.hot-store | 📈 view plot | 764.80 ms |
731a60e to
ecd1208
Compare
Integrate the 9 commits main gained (#12271, #12294, #12301, #12303, #12305, #12312, #12315, #12316, and the release/version bumps). Conflict resolution: all four conflicts (record_lockfile_verified, build_modules, hoisted_dep_graph, install) were between this branch's lint edits and main's feature changes — took main's authoritative versions; lint compliance is re-derived by re-running clippy in the follow-up commit.
…atch - Add & at the two run_postinstall_hooks / run_project_lifecycle_scripts call sites: this branch widened lifecycle.rs to take &RunPostinstallHooks, but main's by-value call sites came in via the conflict resolution. - pedantic fixes on main's new code: must_use_candidate, unnested_or_patterns, manual_let_else, default_trait_access, iter_on_single_items, and trivially_copy_pass_by_ref (map_node_linker takes NodeLinker by value).
Enables the
clippy::pedanticandclippy::nurserylint groups on the pacquet/pnpr Rust workspace — plus theclone_on_ref_ptr,if_then_some_else_none, andmod_module_filesrestriction lints — and brings the code into compliance, sojust lint(--deny warnings) andcargo dylintstay green.mod_module_filesforbidsmod.rs, enforcing the flatmodule.rslayout the project uses.Specific lints are opted back out in
[workspace.lints.clippy], each with an inline justification (the project's guide forbids blanket#[allow]):doc_link_with_quotes(markdown link titles),unreadable_literal(octal Unix file-modes),case_sensitive_file_extension_comparisons(intentional, matches pnpm),iter_with_drain(theVecis reused),literal_string_with_formatting_args(${VAR:-default}are.npmrc/env-replace fixtures),collection_is_never_read(theVecowns sockets to keep them alive).missing_errors_doc,missing_panics_doc,implicit_hasher,missing_const_for_fn,derive_partial_eq_without_eq.too_many_lines,struct_excessive_bools/fn_params_excessive_bools,match_same_arms,option_option/unnecessary_wraps(mirror JSundefined/null/T | undefined), thecast_*family (JSNumbercoercion),unnecessary_debug_formatting,similar_names.use_self,too_long_first_doc_paragraph,option_if_let_else,significant_drop_tightening,redundant_pub_crate,branches_sharing_code,useless_let_if_seq,single_option_map.The full per-lint rationale lives in the
[workspace.lints.clippy]comments.pacquet/pnpr-only change (Rust lint config + compliance); no TypeScript pnpm side to mirror, so no changeset.
Written by an agent (Claude Code).