From 2b51554ff59d1e5cbf8dd2db65d278b0202a9102 Mon Sep 17 00:00:00 2001 From: nsfisis Date: Sat, 27 Jun 2026 03:52:05 +0900 Subject: refactor: fix compiler warnings and clippy warnings --- .../shirabe/src/command/create_project_command.rs | 67 +++++++++++----------- 1 file changed, 34 insertions(+), 33 deletions(-) (limited to 'crates/shirabe/src/command/create_project_command.rs') diff --git a/crates/shirabe/src/command/create_project_command.rs b/crates/shirabe/src/command/create_project_command.rs index 9969cf5..dbc98dd 100644 --- a/crates/shirabe/src/command/create_project_command.rs +++ b/crates/shirabe/src/command/create_project_command.rs @@ -17,11 +17,9 @@ use std::cell::RefCell; use std::path::PathBuf; use std::rc::Rc; -use crate::advisory::AuditConfig; use crate::advisory::Auditor; use crate::command::base_command::base_command_initialize; use crate::command::{BaseCommand, BaseCommandData}; -use crate::composer::PartialComposerHandle; use crate::config::Config; use crate::config::ConfigSourceInterface; use crate::config::JsonConfigSource; @@ -428,7 +426,7 @@ impl CreateProjectCommand { } } - let mut composer = crate::command::composer_full_mut(&composer_handle); + let composer = crate::command::composer_full_mut(&composer_handle); let process = composer .get_loop() @@ -741,37 +739,40 @@ impl CreateProjectCommand { if stability.is_none() { if package_version.is_none() { stability = Some("stable".to_string()); - } else if { - let mut matched: IndexMap = IndexMap::new(); - let ok = Preg::is_match3( - &format!( - "{{^[^,\\s]*?@({})$}}i", - implode( - "|", - &STABILITIES - .keys() - .map(|k| k.to_string()) - .collect::>() - ) - ), - package_version.as_deref().unwrap_or(""), - Some(&mut matched), - ); - if ok { - stability = Some( - matched - .get(&CaptureKey::ByIndex(1)) - .cloned() - .unwrap_or_default(), + } else { + let ok = { + let mut matched: IndexMap = IndexMap::new(); + let ok = Preg::is_match3( + &format!( + "{{^[^,\\s]*?@({})$}}i", + implode( + "|", + &STABILITIES + .keys() + .map(|k| k.to_string()) + .collect::>() + ) + ), + package_version.as_deref().unwrap_or(""), + Some(&mut matched), ); + if ok { + stability = Some( + matched + .get(&CaptureKey::ByIndex(1)) + .cloned() + .unwrap_or_default(), + ); + } + ok + }; + if ok { + // stability already set above + } else { + stability = Some(VersionParser::parse_stability( + package_version.as_deref().unwrap_or(""), + )); } - ok - } { - // stability already set above - } else { - stability = Some(VersionParser::parse_stability( - package_version.as_deref().unwrap_or(""), - )); } } @@ -1032,7 +1033,7 @@ impl CreateProjectCommand { // ensure that the env var being set does not interfere with create-project // as it is probably not meant to be used here, so we do not use it if a composer.json can be found // in the project - if file_exists(&format!("{}/composer.json", directory)) + if file_exists(format!("{}/composer.json", directory)) && Platform::get_env("COMPOSER").is_some() { Platform::clear_env("COMPOSER"); -- cgit v1.3.1