Skip to content

Commit dae8a5e

Browse files
committed
fix: resolve clippy and dead-code lint warnings
- Replace match in display_name with map_or (option_if_let_else) - Collapse nested if-let in create_provider (collapsible_if) - Remove needless borrow in detach handler (needless_borrow) - Allow dead_code on owner_prefix and scoped_name_for_principal (used in tests; needed for admin addressability TODO) Assisted-By: Claude (Anthropic AI) <noreply@anthropic.com> Signed-off-by: Paolo Dettori <dettori@us.ibm.com>
1 parent 1402d69 commit dae8a5e

3 files changed

Lines changed: 10 additions & 9 deletions

File tree

crates/openshell-server/src/auth/ownership.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -188,19 +188,20 @@ pub fn scoped_name(owner: &str, name: &str) -> String {
188188
/// If the key contains a `/`, the part after the first `/` is the display name.
189189
/// If no `/`, the key *is* the display name (shared/legacy provider).
190190
pub fn display_name(db_key: &str) -> &str {
191-
match db_key.find(SCOPE_SEPARATOR) {
192-
Some(pos) => &db_key[pos + 1..],
193-
None => db_key,
194-
}
191+
db_key
192+
.find(SCOPE_SEPARATOR)
193+
.map_or(db_key, |pos| &db_key[pos + 1..])
195194
}
196195

197196
/// Extract the owner prefix from a scoped DB key, if present.
197+
#[allow(dead_code)] // Used in tests; needed for admin addressability (TODO).
198198
pub fn owner_prefix(db_key: &str) -> Option<&str> {
199199
db_key.find(SCOPE_SEPARATOR).map(|pos| &db_key[..pos])
200200
}
201201

202202
/// Build the scoped DB key for the given principal, or return the raw name for
203203
/// anonymous/admin callers.
204+
#[allow(dead_code)] // Used in tests; needed for admin addressability (TODO).
204205
pub fn scoped_name_for_principal(
205206
name: &str,
206207
principal: Option<&Principal>,

crates/openshell-server/src/grpc/provider.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -175,10 +175,10 @@ pub(super) async fn create_provider_record(
175175

176176
// Scope the DB name: if the provider has an owner label, prefix the name
177177
// with `{owner}/` so two users can have the same user-visible name.
178-
if let Some(metadata) = provider.metadata.as_mut() {
179-
if let Some(owner) = metadata.labels.get(OWNER_LABEL).cloned() {
180-
metadata.name = scoped_name(&owner, &metadata.name);
181-
}
178+
if let Some(metadata) = provider.metadata.as_mut()
179+
&& let Some(owner) = metadata.labels.get(OWNER_LABEL).cloned()
180+
{
181+
metadata.name = scoped_name(&owner, &metadata.name);
182182
}
183183

184184
// Generate UUID for database row and update metadata.id to match

crates/openshell-server/src/grpc/sandbox.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -516,7 +516,7 @@ pub(super) async fn handle_detach_sandbox_provider(
516516
state.store.as_ref(),
517517
&request.provider_name,
518518
principal.as_ref(),
519-
&admin_role_name(state),
519+
admin_role_name(state),
520520
)
521521
.await
522522
.ok();

0 commit comments

Comments
 (0)