1
0
Fork 0
mirror of synced 2024-06-15 08:54:47 +12:00

Nightly Clippy

This commit is contained in:
Rafał Mikrut 2022-12-20 12:25:48 +01:00
parent 43ccd7ddf5
commit eedad38557
21 changed files with 68 additions and 68 deletions

View file

@ -36,7 +36,7 @@ fn main() {
set_default_number_of_threads();
println!("Set thread number to {}", get_number_of_threads());
#[cfg(debug_assertions)]
println!("{:?}", command);
println!("{command:?}");
match command {
Commands::Duplicates(duplicates_args) => duplicates(duplicates_args),

View file

@ -424,7 +424,7 @@ impl BadExtensions {
}
}
let mut guessed_multiple_extensions = format!("({}) - ", proper_extension);
let mut guessed_multiple_extensions = format!("({proper_extension}) - ");
for ext in &all_available_extensions {
guessed_multiple_extensions.push_str(ext);
guessed_multiple_extensions.push(',');
@ -523,7 +523,7 @@ impl SaveResults for BadExtensions {
let file_handler = match File::create(&file_name) {
Ok(t) => t,
Err(e) => {
self.text_messages.errors.push(format!("Failed to create file {}, reason {}", file_name, e));
self.text_messages.errors.push(format!("Failed to create file {file_name}, reason {e}"));
return false;
}
};
@ -534,7 +534,7 @@ impl SaveResults for BadExtensions {
"Results of searching {:?} with excluded directories {:?} and excluded items {:?}",
self.directories.included_directories, self.directories.excluded_directories, self.excluded_items.items
) {
self.text_messages.errors.push(format!("Failed to save results to file {}, reason {}", file_name, e));
self.text_messages.errors.push(format!("Failed to save results to file {file_name}, reason {e}"));
return false;
}

View file

@ -449,7 +449,7 @@ impl SaveResults for BigFile {
let file_handler = match File::create(&file_name) {
Ok(t) => t,
Err(e) => {
self.text_messages.errors.push(format!("Failed to create file {}, reason {}", file_name, e));
self.text_messages.errors.push(format!("Failed to create file {file_name}, reason {e}"));
return false;
}
};
@ -460,7 +460,7 @@ impl SaveResults for BigFile {
"Results of searching {:?} with excluded directories {:?} and excluded items {:?}",
self.directories.included_directories, self.directories.excluded_directories, self.excluded_items.items
) {
self.text_messages.errors.push(format!("Failed to save results to file {}, reason {}", file_name, e));
self.text_messages.errors.push(format!("Failed to save results to file {file_name}, reason {e}"));
return false;
}

View file

@ -663,7 +663,7 @@ impl SaveResults for BrokenFiles {
let file_handler = match File::create(&file_name) {
Ok(t) => t,
Err(e) => {
self.text_messages.errors.push(format!("Failed to create file {}, reason {}", file_name, e));
self.text_messages.errors.push(format!("Failed to create file {file_name}, reason {e}"));
return false;
}
};
@ -674,7 +674,7 @@ impl SaveResults for BrokenFiles {
"Results of searching {:?} with excluded directories {:?} and excluded items {:?}",
self.directories.included_directories, self.directories.excluded_directories, self.excluded_items.items
) {
self.text_messages.errors.push(format!("Failed to save results to file {}, reason {}", file_name, e));
self.text_messages.errors.push(format!("Failed to save results to file {file_name}, reason {e}"));
return false;
}

View file

@ -212,10 +212,10 @@ impl Common {
path = Path::new(entry);
if path.is_dir() {
if let Err(e) = fs::remove_dir_all(entry) {
warnings.push(format!("Failed to remove folder {}, reason {}", entry, e));
warnings.push(format!("Failed to remove folder {entry}, reason {e}"));
}
} else if let Err(e) = fs::remove_file(entry) {
warnings.push(format!("Failed to remove file {}, reason {}", entry, e));
warnings.push(format!("Failed to remove file {entry}, reason {e}"));
}
}
warnings
@ -225,10 +225,10 @@ impl Common {
let mut warning: String = String::from("");
if path.is_dir() {
if let Err(e) = fs::remove_dir_all(entry) {
warning = format!("Failed to remove folder {}, reason {}", entry, e)
warning = format!("Failed to remove folder {entry}, reason {e}")
}
} else if let Err(e) = fs::remove_file(entry) {
warning = format!("Failed to remove file {}, reason {}", entry, e)
warning = format!("Failed to remove file {entry}, reason {e}")
}
warning
}

View file

@ -31,18 +31,18 @@ impl Extensions {
}
if !extension.starts_with('.') {
extension = format!(".{}", extension);
extension = format!(".{extension}");
}
if extension[1..].contains('.') {
text_messages.warnings.push(format!("{} is not valid extension because contains dot inside", extension));
text_messages.warnings.push(format!("{extension} is not valid extension because contains dot inside"));
continue;
}
if extension[1..].contains(' ') {
text_messages
.warnings
.push(format!("{} is not valid extension because contains empty space inside", extension));
.push(format!("{extension} is not valid extension because contains empty space inside"));
continue;
}

View file

@ -1003,7 +1003,7 @@ impl SaveResults for DuplicateFinder {
let file_handler = match File::create(&file_name) {
Ok(t) => t,
Err(e) => {
self.text_messages.errors.push(format!("Failed to create file {}, reason {}", file_name, e));
self.text_messages.errors.push(format!("Failed to create file {file_name}, reason {e}"));
return false;
}
};
@ -1014,7 +1014,7 @@ impl SaveResults for DuplicateFinder {
"Results of searching {:?} with excluded directories {:?} and excluded items {:?}",
self.directories.included_directories, self.directories.excluded_directories, self.excluded_items.items
) {
self.text_messages.errors.push(format!("Failed to save results to file {}, reason {}", file_name, e));
self.text_messages.errors.push(format!("Failed to save results to file {file_name}, reason {e}"));
return false;
}
match self.check_method {
@ -1117,7 +1117,7 @@ impl PrintResults for DuplicateFinder {
number_of_files += i.1.len() as u64;
number_of_groups += 1;
}
println!("Found {} files in {} groups with same name(may have different content)", number_of_files, number_of_groups,);
println!("Found {number_of_files} files in {number_of_groups} groups with same name(may have different content)",);
for (name, vector) in &self.files_with_identical_names {
println!("Name - {} - {} files ", name, vector.len());
for j in vector {
@ -1282,7 +1282,7 @@ pub fn save_hashes_to_file(hashmap: &BTreeMap<String, FileEntry>, text_messages:
if file_entry.size >= minimal_cache_file_size {
let string: String = format!("{}//{}//{}//{}", file_entry.path.display(), file_entry.size, file_entry.modified_date, file_entry.hash);
if let Err(e) = writeln!(writer, "{}", string) {
if let Err(e) = writeln!(writer, "{string}") {
text_messages
.warnings
.push(format!("Failed to save some data to cache file {}, reason {}", cache_file.display(), e));
@ -1411,7 +1411,7 @@ fn hash_calculation(buffer: &mut [u8], file_entry: &FileEntry, hash_type: &HashT
fn get_file_hash_name(type_of_hash: &HashType, is_prehash: bool) -> String {
let prehash_str = if is_prehash { "_prehash" } else { "" };
format!("cache_duplicates_{:?}{}.txt", type_of_hash, prehash_str)
format!("cache_duplicates_{type_of_hash:?}{prehash_str}.txt")
}
impl MyHasher for blake3::Hasher {

View file

@ -222,7 +222,7 @@ impl SaveResults for EmptyFiles {
let file_handler = match File::create(&file_name) {
Ok(t) => t,
Err(e) => {
self.text_messages.errors.push(format!("Failed to create file {}, reason {}", file_name, e));
self.text_messages.errors.push(format!("Failed to create file {file_name}, reason {e}"));
return false;
}
};
@ -233,7 +233,7 @@ impl SaveResults for EmptyFiles {
"Results of searching {:?} with excluded directories {:?} and excluded items {:?}",
self.directories.included_directories, self.directories.excluded_directories, self.excluded_items.items
) {
self.text_messages.errors.push(format!("Failed to save results to file {}, reason {}", file_name, e));
self.text_messages.errors.push(format!("Failed to save results to file {file_name}, reason {e}"));
return false;
}

View file

@ -213,7 +213,7 @@ impl SaveResults for EmptyFolder {
let file_handler = match File::create(&file_name) {
Ok(t) => t,
Err(e) => {
self.text_messages.errors.push(format!("Failed to create file {}, reason {}", file_name, e));
self.text_messages.errors.push(format!("Failed to create file {file_name}, reason {e}"));
return false;
}
};
@ -224,7 +224,7 @@ impl SaveResults for EmptyFolder {
"Results of searching {:?} with excluded directories {:?}",
self.directories.included_directories, self.directories.excluded_directories
) {
self.text_messages.errors.push(format!("Failed to save results to file {}, reason {}", file_name, e));
self.text_messages.errors.push(format!("Failed to save results to file {file_name}, reason {e}"));
return false;
}

View file

@ -218,7 +218,7 @@ impl SaveResults for InvalidSymlinks {
let file_handler = match File::create(&file_name) {
Ok(t) => t,
Err(e) => {
self.text_messages.errors.push(format!("Failed to create file {}, reason {}", file_name, e));
self.text_messages.errors.push(format!("Failed to create file {file_name}, reason {e}"));
return false;
}
};
@ -229,7 +229,7 @@ impl SaveResults for InvalidSymlinks {
"Results of searching {:?} with excluded directories {:?} and excluded items {:?}",
self.directories.included_directories, self.directories.excluded_directories, self.excluded_items.items
) {
self.text_messages.errors.push(format!("Failed to save results to file {}, reason {}", file_name, e));
self.text_messages.errors.push(format!("Failed to save results to file {file_name}, reason {e}"));
return false;
}

View file

@ -445,7 +445,7 @@ impl SameMusic {
let minutes = length_number / 1000;
let seconds = (length_number % 1000) * 6 / 100;
if minutes != 0 || seconds != 0 {
length = format!("{}:{:02}", minutes, seconds);
length = format!("{minutes}:{seconds:02}");
} else if old_length_number > 0 {
// That means, that audio have length smaller that second, but length is properly read
length = "0:01".to_string();
@ -897,7 +897,7 @@ impl SaveResults for SameMusic {
let file_handler = match File::create(&file_name) {
Ok(t) => t,
Err(e) => {
self.text_messages.errors.push(format!("Failed to create file {}, reason {}", file_name, e));
self.text_messages.errors.push(format!("Failed to create file {file_name}, reason {e}"));
return false;
}
};
@ -908,7 +908,7 @@ impl SaveResults for SameMusic {
"Results of searching {:?} with excluded directories {:?} and excluded items {:?}",
self.directories.included_directories, self.directories.excluded_directories, self.excluded_items.items
) {
self.text_messages.errors.push(format!("Failed to save results to file {}, reason {}", file_name, e));
self.text_messages.errors.push(format!("Failed to save results to file {file_name}, reason {e}"));
return false;
}

View file

@ -159,7 +159,7 @@ impl SimilarImages {
self.hash_size = match hash_size {
8 | 16 | 32 | 64 => hash_size,
e => {
panic!("Invalid value of hash size {}", e);
panic!("Invalid value of hash size {e}");
}
}
}
@ -961,12 +961,12 @@ impl SimilarImages {
let mut found = false;
for (_hash, vec_file_entry) in collected_similar_images.iter() {
if vec_file_entry.is_empty() {
println!("Empty Element {:?}", vec_file_entry);
println!("Empty Element {vec_file_entry:?}");
found = true;
continue;
}
if vec_file_entry.len() == 1 {
println!("Single Element {:?}", vec_file_entry);
println!("Single Element {vec_file_entry:?}");
found = true;
continue;
}
@ -974,7 +974,7 @@ impl SimilarImages {
let st = file_entry.path.to_string_lossy().to_string();
if result_hashset.contains(&st) {
found = true;
println!("Duplicated Element {}", st);
println!("Duplicated Element {st}");
} else {
result_hashset.insert(st);
}
@ -1161,7 +1161,7 @@ impl SaveResults for SimilarImages {
let file_handler = match File::create(&file_name) {
Ok(t) => t,
Err(e) => {
self.text_messages.errors.push(format!("Failed to create file {}, reason {}", file_name, e));
self.text_messages.errors.push(format!("Failed to create file {file_name}, reason {e}"));
return false;
}
};
@ -1172,7 +1172,7 @@ impl SaveResults for SimilarImages {
"Results of searching {:?} with excluded directories {:?} and excluded items {:?}",
self.directories.included_directories, self.directories.excluded_directories, self.excluded_items.items
) {
self.text_messages.errors.push(format!("Failed to save results to file {}, reason {}", file_name, e));
self.text_messages.errors.push(format!("Failed to save results to file {file_name}, reason {e}"));
return false;
}
@ -1471,7 +1471,7 @@ fn debug_check_for_duplicated_things(
for i in all_hashed_images.get(*hash).unwrap() {
let name = i.path.to_string_lossy().to_string();
if hashmap_names.contains(&name) {
println!("------1--NAME--{} {:?}", numm, name);
println!("------1--NAME--{numm} {name:?}");
found_broken_thing = true;
}
hashmap_names.insert(name);
@ -1488,7 +1488,7 @@ fn debug_check_for_duplicated_things(
for i in all_hashed_images.get(*hash).unwrap() {
let name = i.path.to_string_lossy().to_string();
if hashmap_names.contains(&name) {
println!("------2--NAME--{} {:?}", numm, name);
println!("------2--NAME--{numm} {name:?}");
found_broken_thing = true;
}
hashmap_names.insert(name);

View file

@ -519,7 +519,7 @@ impl SimilarVideos {
Ok(t) => t,
Err(e) => {
return {
file_entry.error = format!("Failed to hash file, reason {}", e);
file_entry.error = format!("Failed to hash file, reason {e}");
Some(file_entry)
};
}
@ -694,7 +694,7 @@ impl SaveResults for SimilarVideos {
let file_handler = match File::create(&file_name) {
Ok(t) => t,
Err(e) => {
self.text_messages.errors.push(format!("Failed to create file {}, reason {}", file_name, e));
self.text_messages.errors.push(format!("Failed to create file {file_name}, reason {e}"));
return false;
}
};
@ -705,7 +705,7 @@ impl SaveResults for SimilarVideos {
"Results of searching {:?} with excluded directories {:?} and excluded items {:?}",
self.directories.included_directories, self.directories.excluded_directories, self.excluded_items.items
) {
self.text_messages.errors.push(format!("Failed to save results to file {}, reason {}", file_name, e));
self.text_messages.errors.push(format!("Failed to save results to file {file_name}, reason {e}"));
return false;
}

View file

@ -396,7 +396,7 @@ impl SaveResults for Temporary {
let file_handler = match File::create(&file_name) {
Ok(t) => t,
Err(e) => {
self.text_messages.errors.push(format!("Failed to create file {}, reason {}", file_name, e));
self.text_messages.errors.push(format!("Failed to create file {file_name}, reason {e}"));
return false;
}
};
@ -407,7 +407,7 @@ impl SaveResults for Temporary {
"Results of searching {:?} with excluded directories {:?} and excluded items {:?}",
self.directories.included_directories, self.directories.excluded_directories, self.excluded_items.items
) {
self.text_messages.errors.push(format!("Failed to save results to file {}, reason {}", file_name, e));
self.text_messages.errors.push(format!("Failed to save results to file {file_name}, reason {e}"));
return false;
}

View file

@ -11,28 +11,28 @@ pub fn connect_about_buttons(gui_data: &GuiData) {
let button_donation = gui_data.about.button_donation.clone();
button_donation.connect_clicked(move |_| {
if let Err(e) = open::that(SPONSOR_SITE) {
println!("Failed to open sponsor site: {}, reason {}", SPONSOR_SITE, e)
println!("Failed to open sponsor site: {SPONSOR_SITE}, reason {e}")
};
});
let button_instruction = gui_data.about.button_instruction.clone();
button_instruction.connect_clicked(move |_| {
if let Err(e) = open::that(INSTRUCTION_SITE) {
println!("Failed to open instruction site: {}, reason {}", INSTRUCTION_SITE, e)
println!("Failed to open instruction site: {INSTRUCTION_SITE}, reason {e}")
};
});
let button_repository = gui_data.about.button_repository.clone();
button_repository.connect_clicked(move |_| {
if let Err(e) = open::that(REPOSITORY_SITE) {
println!("Failed to open repository site: {}, reason {}", REPOSITORY_SITE, e)
println!("Failed to open repository site: {REPOSITORY_SITE}, reason {e}")
};
});
let button_translation = gui_data.about.button_translation.clone();
button_translation.connect_clicked(move |_| {
if let Err(e) = open::that(TRANSLATION_SITE) {
println!("Failed to open repository site: {}, reason {}", TRANSLATION_SITE, e)
println!("Failed to open repository site: {TRANSLATION_SITE}, reason {e}")
};
});
}

View file

@ -389,12 +389,12 @@ fn generate_cache_for_results(vector_with_path: Vec<(String, String, TreePath)>)
pixbuf = t;
}
Err(e) => {
println!("Failed to open image {}, reason {}", full_path, e);
println!("Failed to open image {full_path}, reason {e}");
}
};
}
Err(e) => {
println!("Failed to open image {}, reason {}", full_path, e);
println!("Failed to open image {full_path}, reason {e}");
}
};
break 'czystka;
@ -407,7 +407,7 @@ fn generate_cache_for_results(vector_with_path: Vec<(String, String, TreePath)>)
pixbuf = t;
}
Err(e) => {
println!("Failed to open image {}, reason {}", full_path, e);
println!("Failed to open image {full_path}, reason {e}");
}
};
}
@ -416,14 +416,14 @@ fn generate_cache_for_results(vector_with_path: Vec<(String, String, TreePath)>)
loop {
let pixbuf_big = match resize_pixbuf_dimension(pixbuf, (BIG_PREVIEW_SIZE, BIG_PREVIEW_SIZE), InterpType::Nearest) {
None => {
println!("Failed to resize image {}.", full_path);
println!("Failed to resize image {full_path}.");
break;
}
Some(pixbuf) => pixbuf,
};
let pixbuf_small = match resize_pixbuf_dimension(pixbuf_big.clone(), (SMALL_PREVIEW_SIZE, SMALL_PREVIEW_SIZE), InterpType::Nearest) {
None => {
println!("Failed to resize image {}.", full_path);
println!("Failed to resize image {full_path}.");
break;
}
Some(pixbuf) => pixbuf,

View file

@ -28,7 +28,7 @@ fn change_language(gui_data: &GuiData) {
let lang_identifier = vec![LanguageIdentifier::from_bytes(lang_short.as_bytes()).unwrap()];
for (lib, localizer) in localizers {
if let Err(error) = localizer.select(&lang_identifier) {
eprintln!("Error while loadings languages for {} {:?}", lib, error);
eprintln!("Error while loadings languages for {lib} {error:?}");
}
}
gui_data.update_language();

View file

@ -84,7 +84,7 @@ pub fn connect_settings(gui_data: &GuiData) {
let cache_dir = proj_dirs.cache_dir();
if let Err(e) = open::that(cache_dir) {
println!("Failed to open config folder {:?}, reason {}", cache_dir, e);
println!("Failed to open config folder {cache_dir:?}, reason {e}");
};
}
});
@ -97,7 +97,7 @@ pub fn connect_settings(gui_data: &GuiData) {
let config_dir = proj_dirs.config_dir();
if let Err(e) = open::that(config_dir) {
println!("Failed to open config folder {:?}, reason {}", config_dir, e);
println!("Failed to open config folder {config_dir:?}, reason {e}");
};
}
});

View file

@ -303,7 +303,7 @@ pub fn add_text_to_text_view(text_view: &TextView, string_to_append: &str) {
if current_text.is_empty() {
buffer.set_text(string_to_append);
} else {
buffer.set_text(format!("{}\n{}", current_text, string_to_append).as_str());
buffer.set_text(format!("{current_text}\n{string_to_append}").as_str());
}
}
@ -669,7 +669,7 @@ pub fn debug_print_widget<P: IsA<Widget>>(item: &P) {
widgets_to_check.push((next_free_number, current_number, widget));
next_free_number += 1;
}
println!("{}, {}, {:?} ", current_number, parent_number, widget);
println!("{current_number}, {parent_number}, {widget:?} ");
}
}

View file

@ -12,7 +12,7 @@ pub fn opening_enter_function_ported_upper_directories(event_controller: &gtk4::
let tree_view = event_controller.widget().downcast::<gtk4::TreeView>().unwrap();
#[cfg(debug_assertions)]
{
println!("key_code {}", key_code);
println!("key_code {key_code}");
}
match get_notebook_upper_enum_from_tree_view(&tree_view) {
@ -68,7 +68,7 @@ pub fn opening_enter_function_ported(event_controller: &gtk4::EventControllerKey
let tree_view = event_controller.widget().downcast::<gtk4::TreeView>().unwrap();
#[cfg(debug_assertions)]
{
println!("key_code {}", key_code);
println!("key_code {key_code}");
}
let nt_object = get_notebook_object_from_tree_view(&tree_view);
@ -132,7 +132,7 @@ fn common_open_function(tree_view: &gtk4::TreeView, column_name: i32, column_pat
};
if let Err(e) = open::that(&end_path) {
println!("Failed to open file {}, reason {}", end_path, e);
println!("Failed to open file {end_path}, reason {e}");
};
}
}
@ -190,7 +190,7 @@ fn common_open_function_upper_directories(tree_view: &gtk4::TreeView, column_ful
let full_path = tree_model.get::<String>(&tree_model.iter(tree_path).unwrap(), column_full_path);
if let Err(e) = open::that(&full_path) {
println!("Failed to open file {}, reason {}", full_path, e);
println!("Failed to open file {full_path}, reason {e}");
};
}
}

View file

@ -98,7 +98,7 @@ impl LoadSaveStruct {
}
pub fn get_integer_string(&self, key: String, default_value: String) -> String {
if default_value.parse::<i64>().is_err() {
println!("Default value {} can't be convert to integer value", default_value);
println!("Default value {default_value} can't be convert to integer value");
panic!();
}
let mut returned_value = self.get_string(key, default_value.clone());
@ -119,7 +119,7 @@ impl LoadSaveStruct {
&self.text_view,
&flg!(
"saving_loading_invalid_string",
generate_translation_hashmap(vec![("key", key), ("result", format!("{:?}", item))])
generate_translation_hashmap(vec![("key", key), ("result", format!("{item:?}"))])
),
);
default_value
@ -145,7 +145,7 @@ impl LoadSaveStruct {
&self.text_view,
&flg!(
"saving_loading_invalid_int",
generate_translation_hashmap(vec![("key", key), ("result", format!("{:?}", item))])
generate_translation_hashmap(vec![("key", key), ("result", format!("{item:?}"))])
),
);
default_value
@ -178,7 +178,7 @@ impl LoadSaveStruct {
&self.text_view,
&flg!(
"saving_loading_invalid_bool",
generate_translation_hashmap(vec![("key", key), ("result", format!("{:?}", item))])
generate_translation_hashmap(vec![("key", key), ("result", format!("{item:?}"))])
),
);
default_value
@ -351,7 +351,7 @@ impl LoadSaveStruct {
if let Some((mut config_file_handler, config_file)) = self.open_save_file(text_view_errors, true, false) {
let mut data_saved: bool = false;
for (key, vec_string) in &self.loaded_items {
match writeln!(config_file_handler, "{}", key) {
match writeln!(config_file_handler, "{key}") {
Ok(_inspected) => {
data_saved = true;
}
@ -361,7 +361,7 @@ impl LoadSaveStruct {
}
}
for data in vec_string {
match writeln!(config_file_handler, "{}", data) {
match writeln!(config_file_handler, "{data}") {
Ok(_inspected) => {
data_saved = true;
}
@ -492,8 +492,8 @@ fn create_hash_map() -> (HashMap<LoadText, String>, HashMap<String, LoadText>) {
let mut hashmap_sl: HashMap<String, LoadText> = Default::default();
for (load_text, string) in values {
hashmap_ls.insert(load_text, format!("--{}", string));
hashmap_sl.insert(format!("--{}", string), load_text);
hashmap_ls.insert(load_text, format!("--{string}"));
hashmap_sl.insert(format!("--{string}"), load_text);
}
(hashmap_ls, hashmap_sl)