Skip to content

Commit d9f5278

Browse files
committed
Fix vlt registry_base doc lint for clippy
clippy -D warnings rejected the registry_base doc comment (doc_lazy_continuation), failing CI on cb35d5a. Separate the scoped-registry paragraph from the list, and rustfmt the three touched files that were rustfmt-clean on main. No behavior change. Assisted-by: Claude Code:claude-opus-5-5
1 parent cb35d5a commit d9f5278

3 files changed

Lines changed: 48 additions & 25 deletions

File tree

‎crates/socket-patch-core/src/patch/redirect/upstream/vlt.rs‎

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -364,18 +364,36 @@ mod tests {
364364
Some(&with_registries)
365365
));
366366
let alias = opts(r#"{"default-registry-alias":"corp","registries":{"corp":"https://c/"}}"#);
367-
assert!(records_url(DepIdEra::Tilde, "corp", "left-pad", &[], Some(&alias)));
367+
assert!(records_url(
368+
DepIdEra::Tilde,
369+
"corp",
370+
"left-pad",
371+
&[],
372+
Some(&alias)
373+
));
368374
// A recorded `registry` the node resolves under: vlt (rc.33 … 1.2.0
369375
// with `config.registry`) writes no slot [3].
370376
let configured = opts(
371377
r#"{"registry":"http://127.0.0.1:4873/","registries":{"npm":"http://127.0.0.1:4873/"}}"#,
372378
);
373-
assert!(!records_url(DepIdEra::Tilde, "npm", "left-pad", &[], Some(&configured)));
379+
assert!(!records_url(
380+
DepIdEra::Tilde,
381+
"npm",
382+
"left-pad",
383+
&[],
384+
Some(&configured)
385+
));
374386
// ...but a node on another registry than the configured one does.
375387
let elsewhere = opts(
376388
r#"{"registry":"https://registry.npmjs.org/","registries":{"npm":"http://127.0.0.1:4873/"}}"#,
377389
);
378-
assert!(records_url(DepIdEra::Tilde, "npm", "left-pad", &[], Some(&elsewhere)));
390+
assert!(records_url(
391+
DepIdEra::Tilde,
392+
"npm",
393+
"left-pad",
394+
&[],
395+
Some(&elsewhere)
396+
));
379397
}
380398

381399
use super::super::{restore_upstream, RestoreOptions, RestoreOutcome};
@@ -556,12 +574,16 @@ mod tests {
556574
let text = format!(
557575
"{{\n \"lockfileVersion\": 1,\n \"options\": {SCOPED_REGISTRY_OPTIONS},\n \"nodes\": {{\n \"~npm~@s+a@1.0.0\": [0,\"@s/a\",\"sha512-AA==\",\"{url}\"]{sibling}\n }},\n \"edges\": {{}}\n}}\n"
558576
);
559-
let (outcome, after) =
560-
run(&text, &[pin("pkg:npm/@s/a@1.0.0", LP_UUID)], false).await;
577+
let (outcome, after) = run(&text, &[pin("pkg:npm/@s/a@1.0.0", LP_UUID)], false).await;
561578
assert!(refused(&outcome).is_empty(), "{:?}", refused(&outcome));
562579
let after: Value = serde_json::from_str(&after).unwrap();
563580
let expected = if records_url {
564-
serde_json::json!([0, "@s/a", LP_UPSTREAM, "https://a.example/@s/a/-/a-1.0.0.tgz"])
581+
serde_json::json!([
582+
0,
583+
"@s/a",
584+
LP_UPSTREAM,
585+
"https://a.example/@s/a/-/a-1.0.0.tgz"
586+
])
565587
} else {
566588
// The scoped URL is under options.registry, even though
567589
// registries.npm names a different base: vlt omits slot 3.

‎crates/socket-patch-core/src/vendor/lock_inventory/tests.rs‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2727,9 +2727,7 @@ async fn vlt_inventory_resolves_registries_through_the_shared_registry_base() {
27272727

27282728
#[tokio::test]
27292729
async fn vlt_inventory_honors_scope_for_named_and_url_registry_segments() {
2730-
use crate::vendor::vlt_lock_text::{
2731-
encode_segment, DepIdEra, SCOPED_REGISTRY_OPTIONS,
2732-
};
2730+
use crate::vendor::vlt_lock_text::{encode_segment, DepIdEra, SCOPED_REGISTRY_OPTIONS};
27332731
for segment in ["npm", "corp", "https://explicit.example/npm"] {
27342732
let tmp = tempfile::tempdir().unwrap();
27352733
let node = format!(

‎crates/socket-patch-core/src/vendor/vlt_lock_text.rs‎

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -452,6 +452,7 @@ pub(crate) fn default_registry_alias(options: Option<&Map<String, Value>>) -> Op
452452
/// else the default alias's `options.registries` URL, else the public
453453
/// npm registry (`registry ?? registries[default-registry-alias]`);
454454
/// - any other segment is `None`: the lock names an alias it never maps.
455+
///
455456
/// Once the segment resolves, a configured scope registry takes precedence,
456457
/// including in a named/URL registry spec's final subspec. Unknown aliases
457458
/// still fail before scope lookup, as `hydrateTuple` does.
@@ -473,21 +474,20 @@ pub(crate) fn registry_base(
473474
.and_then(|r| r.get(alias)),
474475
)
475476
};
476-
let base = if reqwest::Url::parse(segment)
477-
.is_ok_and(|url| matches!(url.scheme(), "http" | "https"))
478-
{
479-
with_trailing_slash(segment)
480-
} else if let Some(base) = Some(segment).filter(|s| !s.is_empty()).and_then(alias_url) {
481-
base
482-
} else if is_default_registry(segment, options) {
483-
string(options.and_then(|o| o.get("registry")))
484-
.or_else(|| default_registry_alias(options).and_then(alias_url))
485-
.unwrap_or_else(|| {
486-
with_trailing_slash(crate::vendor::registry_fetch::DEFAULT_NPM_REGISTRY)
487-
})
488-
} else {
489-
return None;
490-
};
477+
let base =
478+
if reqwest::Url::parse(segment).is_ok_and(|url| matches!(url.scheme(), "http" | "https")) {
479+
with_trailing_slash(segment)
480+
} else if let Some(base) = Some(segment).filter(|s| !s.is_empty()).and_then(alias_url) {
481+
base
482+
} else if is_default_registry(segment, options) {
483+
string(options.and_then(|o| o.get("registry")))
484+
.or_else(|| default_registry_alias(options).and_then(alias_url))
485+
.unwrap_or_else(|| {
486+
with_trailing_slash(crate::vendor::registry_fetch::DEFAULT_NPM_REGISTRY)
487+
})
488+
} else {
489+
return None;
490+
};
491491
name.split_once('/')
492492
.map(|(scope, _)| scope)
493493
.filter(|scope| scope.starts_with('@'))
@@ -1817,7 +1817,10 @@ mod tests {
18171817
("", "https://a.example/"),
18181818
("npm", "https://b.example/"),
18191819
("corp", "https://corp.example/"),
1820-
("https://explicit.example/npm", "https://explicit.example/npm/"),
1820+
(
1821+
"https://explicit.example/npm",
1822+
"https://explicit.example/npm/",
1823+
),
18211824
] {
18221825
assert_eq!(
18231826
registry_base(segment, "@s/a", Some(&opts)).as_deref(),

0 commit comments

Comments
 (0)