fix: v1.67 clippy lints (inline format strings)
This commit is contained in:
parent
15dad0c428
commit
331a13568a
33 changed files with 200 additions and 288 deletions
|
|
@ -53,14 +53,14 @@ pub async fn collect_large_numbers(project_root: &Path, concurrency: usize) {
|
|||
for (n, ch_id) in channels.iter().enumerate() {
|
||||
let channel = get_channel(ch_id, lang)
|
||||
.await
|
||||
.context(format!("{}-{}", lang, n))
|
||||
.context(format!("{lang}-{n}"))
|
||||
.unwrap();
|
||||
|
||||
channel.view_counts.iter().for_each(|(num, txt)| {
|
||||
entry.insert(txt.to_owned(), *num);
|
||||
});
|
||||
|
||||
println!("collected {}-{}", lang, n);
|
||||
println!("collected {lang}-{n}");
|
||||
}
|
||||
|
||||
(lang, entry)
|
||||
|
|
@ -232,7 +232,7 @@ pub fn write_samples_to_dict(project_root: &Path) {
|
|||
// Check for duplicates
|
||||
let mut uniq = HashSet::new();
|
||||
if !dict_entry.number_tokens.values().all(|x| uniq.insert(x)) {
|
||||
println!("Warning: collected duplicate tokens for {}", lang);
|
||||
println!("Warning: collected duplicate tokens for {lang}");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -222,9 +222,7 @@ pub fn write_samples_to_dict(project_root: &Path) {
|
|||
n: 3,
|
||||
unit: timeago::TimeUnit::Day
|
||||
}),
|
||||
"lang: {}, txt: {}",
|
||||
lang,
|
||||
datestr
|
||||
"lang: {lang}, txt: {datestr}"
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -246,7 +244,7 @@ pub fn write_samples_to_dict(project_root: &Path) {
|
|||
} else if n == &date.2 {
|
||||
"D"
|
||||
} else {
|
||||
panic!("invalid number {} in {}", n, datestr);
|
||||
panic!("invalid number {n} in {datestr}");
|
||||
}
|
||||
})
|
||||
.collect::<String>();
|
||||
|
|
@ -254,7 +252,7 @@ pub fn write_samples_to_dict(project_root: &Path) {
|
|||
if num_order.is_empty() {
|
||||
num_order = this_num_order;
|
||||
} else {
|
||||
assert_eq!(this_num_order, num_order, "lang: {}", lang);
|
||||
assert_eq!(this_num_order, num_order, "lang: {lang}");
|
||||
}
|
||||
|
||||
// Insert words into the map
|
||||
|
|
|
|||
|
|
@ -142,7 +142,7 @@ async fn player(testfiles: &Path) {
|
|||
for client_type in CLIENT_TYPES {
|
||||
let mut json_path = testfiles.to_path_buf();
|
||||
json_path.push("player");
|
||||
json_path.push(format!("{:?}_video.json", client_type).to_lowercase());
|
||||
json_path.push(format!("{client_type:?}_video.json").to_lowercase());
|
||||
|
||||
if json_path.exists() {
|
||||
continue;
|
||||
|
|
@ -162,7 +162,7 @@ async fn player_model(testfiles: &Path) {
|
|||
for (name, id) in [("multilanguage", "tVWWp1PqDus"), ("hdr", "LXb3EKWsInQ")] {
|
||||
let mut json_path = testfiles.to_path_buf();
|
||||
json_path.push("player_model");
|
||||
json_path.push(format!("{}.json", name).to_lowercase());
|
||||
json_path.push(format!("{name}.json").to_lowercase());
|
||||
|
||||
if json_path.exists() {
|
||||
continue;
|
||||
|
|
@ -188,7 +188,7 @@ async fn playlist(testfiles: &Path) {
|
|||
] {
|
||||
let mut json_path = testfiles.to_path_buf();
|
||||
json_path.push("playlist");
|
||||
json_path.push(format!("playlist_{}.json", name));
|
||||
json_path.push(format!("playlist_{name}.json"));
|
||||
if json_path.exists() {
|
||||
continue;
|
||||
}
|
||||
|
|
@ -228,7 +228,7 @@ async fn video_details(testfiles: &Path) {
|
|||
] {
|
||||
let mut json_path = testfiles.to_path_buf();
|
||||
json_path.push("video_details");
|
||||
json_path.push(format!("video_details_{}.json", name));
|
||||
json_path.push(format!("video_details_{name}.json"));
|
||||
if json_path.exists() {
|
||||
continue;
|
||||
}
|
||||
|
|
@ -304,7 +304,7 @@ async fn channel_videos(testfiles: &Path) {
|
|||
] {
|
||||
let mut json_path = testfiles.to_path_buf();
|
||||
json_path.push("channel");
|
||||
json_path.push(format!("channel_videos_{}.json", name));
|
||||
json_path.push(format!("channel_videos_{name}.json"));
|
||||
if json_path.exists() {
|
||||
continue;
|
||||
}
|
||||
|
|
@ -521,7 +521,7 @@ async fn music_playlist(testfiles: &Path) {
|
|||
] {
|
||||
let mut json_path = testfiles.to_path_buf();
|
||||
json_path.push("music_playlist");
|
||||
json_path.push(format!("playlist_{}.json", name));
|
||||
json_path.push(format!("playlist_{name}.json"));
|
||||
if json_path.exists() {
|
||||
continue;
|
||||
}
|
||||
|
|
@ -584,7 +584,7 @@ async fn music_album(testfiles: &Path) {
|
|||
] {
|
||||
let mut json_path = testfiles.to_path_buf();
|
||||
json_path.push("music_playlist");
|
||||
json_path.push(format!("album_{}.json", name));
|
||||
json_path.push(format!("album_{name}.json"));
|
||||
if json_path.exists() {
|
||||
continue;
|
||||
}
|
||||
|
|
@ -602,7 +602,7 @@ async fn music_search(testfiles: &Path) {
|
|||
] {
|
||||
let mut json_path = testfiles.to_path_buf();
|
||||
json_path.push("music_search");
|
||||
json_path.push(format!("main_{}.json", name));
|
||||
json_path.push(format!("main_{name}.json"));
|
||||
if json_path.exists() {
|
||||
continue;
|
||||
}
|
||||
|
|
@ -625,7 +625,7 @@ async fn music_search_tracks(testfiles: &Path) {
|
|||
] {
|
||||
let mut json_path = testfiles.to_path_buf();
|
||||
json_path.push("music_search");
|
||||
json_path.push(format!("tracks_{}.json", name));
|
||||
json_path.push(format!("tracks_{name}.json"));
|
||||
if json_path.exists() {
|
||||
continue;
|
||||
}
|
||||
|
|
@ -670,7 +670,7 @@ async fn music_search_playlists(testfiles: &Path) {
|
|||
for (name, community) in [("ytm", false), ("community", true)] {
|
||||
let mut json_path = testfiles.to_path_buf();
|
||||
json_path.push("music_search");
|
||||
json_path.push(format!("playlists_{}.json", name));
|
||||
json_path.push(format!("playlists_{name}.json"));
|
||||
if json_path.exists() {
|
||||
continue;
|
||||
}
|
||||
|
|
@ -702,7 +702,7 @@ async fn music_search_suggestion(testfiles: &Path) {
|
|||
for (name, query) in [("default", "t"), ("empty", "reujbhevmfndxnjrze")] {
|
||||
let mut json_path = testfiles.to_path_buf();
|
||||
json_path.push("music_search");
|
||||
json_path.push(format!("suggestion_{}.json", name));
|
||||
json_path.push(format!("suggestion_{name}.json"));
|
||||
if json_path.exists() {
|
||||
continue;
|
||||
}
|
||||
|
|
@ -723,7 +723,7 @@ async fn music_artist(testfiles: &Path) {
|
|||
] {
|
||||
let mut json_path = testfiles.to_path_buf();
|
||||
json_path.push("music_artist");
|
||||
json_path.push(format!("artist_{}.json", name));
|
||||
json_path.push(format!("artist_{name}.json"));
|
||||
if json_path.exists() {
|
||||
continue;
|
||||
}
|
||||
|
|
@ -737,7 +737,7 @@ async fn music_details(testfiles: &Path) {
|
|||
for (name, id) in [("mv", "ZeerrnuLi5E"), ("track", "7nigXQS1Xb0")] {
|
||||
let mut json_path = testfiles.to_path_buf();
|
||||
json_path.push("music_details");
|
||||
json_path.push(format!("details_{}.json", name));
|
||||
json_path.push(format!("details_{name}.json"));
|
||||
if json_path.exists() {
|
||||
continue;
|
||||
}
|
||||
|
|
@ -787,7 +787,7 @@ async fn music_radio(testfiles: &Path) {
|
|||
for (name, id) in [("mv", "RDAMVMZeerrnuLi5E"), ("track", "RDAMVM7nigXQS1Xb0")] {
|
||||
let mut json_path = testfiles.to_path_buf();
|
||||
json_path.push("music_details");
|
||||
json_path.push(format!("radio_{}.json", name));
|
||||
json_path.push(format!("radio_{name}.json"));
|
||||
if json_path.exists() {
|
||||
continue;
|
||||
}
|
||||
|
|
@ -840,7 +840,7 @@ async fn music_charts(testfiles: &Path) {
|
|||
for (name, country) in [("global", Some(Country::Zz)), ("US", Some(Country::Us))] {
|
||||
let mut json_path = testfiles.to_path_buf();
|
||||
json_path.push("music_charts");
|
||||
json_path.push(&format!("charts_{}.json", name));
|
||||
json_path.push(&format!("charts_{name}.json"));
|
||||
if json_path.exists() {
|
||||
continue;
|
||||
}
|
||||
|
|
@ -869,7 +869,7 @@ async fn music_genre(testfiles: &Path) {
|
|||
] {
|
||||
let mut json_path = testfiles.to_path_buf();
|
||||
json_path.push("music_genres");
|
||||
json_path.push(&format!("genre_{}.json", name));
|
||||
json_path.push(&format!("genre_{name}.json"));
|
||||
if json_path.exists() {
|
||||
continue;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,10 +23,10 @@ fn parse_tu(tu: &str) -> (u8, Option<TimeUnit>) {
|
|||
"M" => Some(TimeUnit::Month),
|
||||
"Y" => Some(TimeUnit::Year),
|
||||
"" => None,
|
||||
_ => panic!("invalid time unit: {}", tu),
|
||||
_ => panic!("invalid time unit: {tu}"),
|
||||
},
|
||||
),
|
||||
None => panic!("invalid time unit: {}", tu),
|
||||
None => panic!("invalid time unit: {tu}"),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -91,9 +91,9 @@ pub(crate) fn entry(lang: Language) -> Entry {
|
|||
|
||||
dict.iter().for_each(|(lang, entry)| {
|
||||
// Match selector
|
||||
let mut selector = format!("Language::{:?}", lang);
|
||||
let mut selector = format!("Language::{lang:?}");
|
||||
entry.equivalent.iter().for_each(|eq| {
|
||||
let _ = write!(selector, " | Language::{:?}", eq);
|
||||
let _ = write!(selector, " | Language::{eq:?}");
|
||||
});
|
||||
|
||||
// Timeago tokens
|
||||
|
|
@ -103,9 +103,9 @@ pub(crate) fn entry(lang: Language) -> Entry {
|
|||
match unit {
|
||||
Some(unit) => ta_tokens.entry(
|
||||
txt,
|
||||
&format!("TaToken {{ n: {}, unit: Some(TimeUnit::{:?}) }}", n, unit),
|
||||
&format!("TaToken {{ n: {n}, unit: Some(TimeUnit::{unit:?}) }}"),
|
||||
),
|
||||
None => ta_tokens.entry(txt, &format!("TaToken {{ n: {}, unit: None }}", n)),
|
||||
None => ta_tokens.entry(txt, &format!("TaToken {{ n: {n}, unit: None }}")),
|
||||
};
|
||||
});
|
||||
|
||||
|
|
@ -122,16 +122,16 @@ pub(crate) fn entry(lang: Language) -> Entry {
|
|||
match unit {
|
||||
Some(unit) => ta_nd_tokens.entry(
|
||||
txt,
|
||||
&format!("TaToken {{ n: {}, unit: Some(TimeUnit::{:?}) }}", n, unit),
|
||||
&format!("TaToken {{ n: {n}, unit: Some(TimeUnit::{unit:?}) }}"),
|
||||
),
|
||||
None => ta_nd_tokens.entry(txt, &format!("TaToken {{ n: {}, unit: None }}", n)),
|
||||
None => ta_nd_tokens.entry(txt, &format!("TaToken {{ n: {n}, unit: None }}")),
|
||||
};
|
||||
});
|
||||
|
||||
// Date order
|
||||
let mut date_order = "&[".to_owned();
|
||||
entry.date_order.chars().for_each(|c| {
|
||||
let _ = write!(date_order, "DateCmp::{}, ", c);
|
||||
let _ = write!(date_order, "DateCmp::{c}, ");
|
||||
});
|
||||
date_order = date_order.trim_end_matches([' ', ',']).to_owned() + "]";
|
||||
|
||||
|
|
@ -144,7 +144,7 @@ pub(crate) fn entry(lang: Language) -> Entry {
|
|||
// Album types
|
||||
let mut album_types = phf_codegen::Map::<&str>::new();
|
||||
entry.album_types.iter().for_each(|(txt, album_type)| {
|
||||
album_types.entry(txt, &format!("AlbumType::{:?}", album_type));
|
||||
album_types.entry(txt, &format!("AlbumType::{album_type:?}"));
|
||||
});
|
||||
|
||||
let code_ta_tokens = &ta_tokens.build().to_string().replace('\n', "\n ");
|
||||
|
|
@ -159,7 +159,7 @@ pub(crate) fn entry(lang: Language) -> Entry {
|
|||
|
||||
code_timeago_tokens = code_timeago_tokens.trim_end().to_owned() + "\n }\n}\n";
|
||||
|
||||
let code = format!("{}\n{}", code_head, code_timeago_tokens);
|
||||
let code = format!("{code_head}\n{code_timeago_tokens}");
|
||||
|
||||
let mut target_path = project_root.to_path_buf();
|
||||
target_path.push(TARGET_PATH);
|
||||
|
|
|
|||
|
|
@ -235,21 +235,20 @@ pub enum Country {
|
|||
.collect::<String>();
|
||||
|
||||
// Language enum
|
||||
write!(code_langs, " /// {}\n ", n).unwrap();
|
||||
write!(code_langs, " /// {n}\n ").unwrap();
|
||||
if c.contains('-') {
|
||||
write!(code_langs, "#[serde(rename = \"{}\")]\n ", c).unwrap();
|
||||
write!(code_langs, "#[serde(rename = \"{c}\")]\n ").unwrap();
|
||||
}
|
||||
code_langs += &enum_name;
|
||||
code_langs += ",\n";
|
||||
|
||||
// Language array
|
||||
writeln!(code_lang_array, " Language::{},", enum_name).unwrap();
|
||||
writeln!(code_lang_array, " Language::{enum_name},").unwrap();
|
||||
|
||||
// Language names
|
||||
writeln!(
|
||||
code_lang_names,
|
||||
" Language::{} => \"{}\",",
|
||||
enum_name, n
|
||||
" Language::{enum_name} => \"{n}\","
|
||||
)
|
||||
.unwrap();
|
||||
});
|
||||
|
|
@ -259,17 +258,16 @@ pub enum Country {
|
|||
let enum_name = c[0..1].to_owned().to_uppercase() + &c[1..].to_owned().to_lowercase();
|
||||
|
||||
// Country enum
|
||||
writeln!(code_countries, " /// {}", n).unwrap();
|
||||
writeln!(code_countries, " {},", enum_name).unwrap();
|
||||
writeln!(code_countries, " /// {n}").unwrap();
|
||||
writeln!(code_countries, " {enum_name},").unwrap();
|
||||
|
||||
// Country array
|
||||
writeln!(code_country_array, " Country::{},", enum_name).unwrap();
|
||||
writeln!(code_country_array, " Country::{enum_name},").unwrap();
|
||||
|
||||
// Country names
|
||||
writeln!(
|
||||
code_country_names,
|
||||
" Country::{} => \"{}\",",
|
||||
enum_name, n
|
||||
" Country::{enum_name} => \"{n}\","
|
||||
)
|
||||
.unwrap();
|
||||
});
|
||||
|
|
@ -287,15 +285,7 @@ pub enum Country {
|
|||
code_country_names += " }\n }\n}\n";
|
||||
|
||||
let code = format!(
|
||||
"{}\n{}\n{}\n{}\n{}\n{}\n{}\n{}",
|
||||
code_head,
|
||||
code_langs,
|
||||
code_countries,
|
||||
code_lang_array,
|
||||
code_country_array,
|
||||
code_lang_names,
|
||||
code_country_names,
|
||||
code_foot
|
||||
"{code_head}\n{code_langs}\n{code_countries}\n{code_lang_array}\n{code_country_array}\n{code_lang_names}\n{code_country_names}\n{code_foot}"
|
||||
);
|
||||
|
||||
let mut target_path = project_root.to_path_buf();
|
||||
|
|
|
|||
|
|
@ -81,8 +81,8 @@ async fn main() {
|
|||
n,
|
||||
occurrences as f32 / n as f32 * 100.0
|
||||
);
|
||||
eprintln!("visitor_data (present): {:?}", vd_present);
|
||||
eprintln!("visitor_data (absent): {:?}", vd_absent);
|
||||
eprintln!("visitor_data (present): {vd_present:?}");
|
||||
eprintln!("visitor_data (absent): {vd_absent:?}");
|
||||
}
|
||||
None => {
|
||||
let res = abtest::run_all_tests(n, cli.concurrency).await;
|
||||
|
|
|
|||
Reference in a new issue