From 748e741f740ac46ec40e42679aba3b07927709c0 Mon Sep 17 00:00:00 2001 From: nsfisis Date: Sun, 17 May 2026 15:08:03 +0900 Subject: chore: cargo clippy --fix --- .../shirabe-class-map-generator/src/class_map.rs | 10 +++++++--- .../src/class_map_generator.rs | 16 ++++++++-------- .../shirabe-class-map-generator/src/file_list.rs | 6 ++++++ .../src/php_file_cleaner.rs | 2 +- .../src/php_file_parser.rs | 22 +++++++++++----------- 5 files changed, 33 insertions(+), 23 deletions(-) (limited to 'crates/shirabe-class-map-generator') diff --git a/crates/shirabe-class-map-generator/src/class_map.rs b/crates/shirabe-class-map-generator/src/class_map.rs index 311924b..c397c5c 100644 --- a/crates/shirabe-class-map-generator/src/class_map.rs +++ b/crates/shirabe-class-map-generator/src/class_map.rs @@ -2,9 +2,7 @@ use indexmap::IndexMap; use shirabe_external_packages::composer::pcre::preg::Preg; -use shirabe_php_shim::{ - Countable, InvalidArgumentException, OutOfBoundsException, rtrim, strpos, strtr, -}; +use shirabe_php_shim::{Countable, OutOfBoundsException, rtrim, strpos, strtr}; #[derive(Debug, Clone)] pub struct PsrViolationEntry { @@ -19,6 +17,12 @@ pub struct ClassMap { psr_violations: IndexMap>, } +impl Default for ClassMap { + fn default() -> Self { + Self::new() + } +} + impl ClassMap { pub fn new() -> Self { ClassMap { diff --git a/crates/shirabe-class-map-generator/src/class_map_generator.rs b/crates/shirabe-class-map-generator/src/class_map_generator.rs index 608dccb..733915e 100644 --- a/crates/shirabe-class-map-generator/src/class_map_generator.rs +++ b/crates/shirabe-class-map-generator/src/class_map_generator.rs @@ -200,10 +200,10 @@ impl ClassMapGenerator { // if a list of scanned files is given, avoid scanning twice the same file to save cycles and avoid generating warnings // in case a PSR-0/4 declaration follows another more specific one, or a classmap declaration, which covered this file already - if let Some(ref scanned_files) = self.scanned_files { - if scanned_files.contains(&real_path) { - continue; - } + if let Some(ref scanned_files) = self.scanned_files + && scanned_files.contains(&real_path) + { + continue; } // check the realpath of the file against the excluded paths as the path might be a symlink and the excluded path is realpath'd so symlink are resolved @@ -228,10 +228,10 @@ impl ClassMapGenerator { )?; // if no valid class was found in the file then we do not mark it as scanned as it might still be matched by another rule later - if !filtered.is_empty() { - if let Some(ref mut scanned_files) = self.scanned_files { - scanned_files.add(real_path); - } + if !filtered.is_empty() + && let Some(ref mut scanned_files) = self.scanned_files + { + scanned_files.add(real_path); } filtered diff --git a/crates/shirabe-class-map-generator/src/file_list.rs b/crates/shirabe-class-map-generator/src/file_list.rs index 0813f2c..8f0f00f 100644 --- a/crates/shirabe-class-map-generator/src/file_list.rs +++ b/crates/shirabe-class-map-generator/src/file_list.rs @@ -8,6 +8,12 @@ pub struct FileList { pub files: IndexMap, } +impl Default for FileList { + fn default() -> Self { + Self::new() + } +} + impl FileList { pub fn new() -> Self { FileList { diff --git a/crates/shirabe-class-map-generator/src/php_file_cleaner.rs b/crates/shirabe-class-map-generator/src/php_file_cleaner.rs index ec59414..98c8b1d 100644 --- a/crates/shirabe-class-map-generator/src/php_file_cleaner.rs +++ b/crates/shirabe-class-map-generator/src/php_file_cleaner.rs @@ -120,7 +120,7 @@ impl PhpFileCleaner { }; if let Some(entry) = type_entry { let end = self.index + entry.length; - if end <= self.len && &self.contents[self.index..end] == entry.name { + if end <= self.len && self.contents[self.index..end] == entry.name { let offset = if self.index > 0 { self.index - 1 } else { 0 }; let mut r#match: IndexMap = IndexMap::new(); if Preg::is_match5( diff --git a/crates/shirabe-class-map-generator/src/php_file_parser.rs b/crates/shirabe-class-map-generator/src/php_file_parser.rs index d87db82..95b2997 100644 --- a/crates/shirabe-class-map-generator/src/php_file_parser.rs +++ b/crates/shirabe-class-map-generator/src/php_file_parser.rs @@ -45,17 +45,17 @@ impl PhpFileParser { message, &[shirabe_php_shim::PhpMixed::String(path.to_string())], ); - if let Some(error) = error { - if let Some(err_msg) = error.get("message") { - message = format!( - "{}{}{}{}{}", - message, - PHP_EOL, - "The following message may be helpful:", - PHP_EOL, - err_msg.as_string().unwrap_or("") - ); - } + if let Some(error) = error + && let Some(err_msg) = error.get("message") + { + message = format!( + "{}{}{}{}{}", + message, + PHP_EOL, + "The following message may be helpful:", + PHP_EOL, + err_msg.as_string().unwrap_or("") + ); } return Err(anyhow!(RuntimeException { message, code: 0 })); -- cgit v1.3.1