Skip to content

Commit 8379550

Browse files
committed
fix collapsible_if
1 parent 5b54e08 commit 8379550

2 files changed

Lines changed: 38 additions & 42 deletions

File tree

Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -720,7 +720,6 @@ unexpected_cfgs = { level = "warn", check-cfg = [
720720
unused_qualifications = "warn"
721721

722722
[workspace.lints.clippy]
723-
collapsible_if = { level = "allow", priority = 127 } # remove me
724723
# The counts were generated with this command:
725724
# cargo clippy --all-targets --workspace --message-format=json --quiet \
726725
# | jq -r '.message.code.code | select(. != null and startswith("clippy::"))' \

src/uucore/build.rs

Lines changed: 38 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -84,18 +84,18 @@ fn detect_target_utility() -> Option<String> {
8484
println!("cargo:rerun-if-env-changed=UUCORE_TARGET_UTIL");
8585

8686
// First check if an explicit environment variable was set
87-
if let Ok(target_util) = env::var("UUCORE_TARGET_UTIL") {
88-
if !target_util.is_empty() {
89-
return Some(target_util);
90-
}
87+
if let Ok(target_util) = env::var("UUCORE_TARGET_UTIL")
88+
&& !target_util.is_empty()
89+
{
90+
return Some(target_util);
9191
}
9292

9393
// Auto-detect utility name from CARGO_PKG_NAME if it's a uu_* package
94-
if let Ok(pkg_name) = env::var("CARGO_PKG_NAME") {
95-
if let Some(util_name) = pkg_name.strip_prefix("uu_") {
96-
println!("cargo:warning=Auto-detected utility name: {util_name}");
97-
return Some(util_name.to_string());
98-
}
94+
if let Ok(pkg_name) = env::var("CARGO_PKG_NAME")
95+
&& let Some(util_name) = pkg_name.strip_prefix("uu_")
96+
{
97+
println!("cargo:warning=Auto-detected utility name: {util_name}");
98+
return Some(util_name.to_string());
9999
}
100100

101101
// Check for a build configuration file in the target directory
@@ -186,10 +186,10 @@ fn embed_all_utility_locales(
186186
let mut util_dirs = Vec::new();
187187
for entry in fs::read_dir(&src_uu_dir)? {
188188
let entry = entry?;
189-
if entry.file_type()?.is_dir() {
190-
if let Some(dir_name) = entry.file_name().to_str() {
191-
util_dirs.push(dir_name.to_string());
192-
}
189+
if entry.file_type()?.is_dir()
190+
&& let Some(dir_name) = entry.file_name().to_str()
191+
{
192+
util_dirs.push(dir_name.to_string());
193193
}
194194
}
195195
util_dirs.sort();
@@ -247,18 +247,14 @@ fn embed_static_utility_locales(
247247

248248
for entry in entries {
249249
let file_name = entry.file_name();
250-
if let Some(dir_name) = file_name.to_str() {
251-
// Match uu_<util>-<version>
252-
if let Some((util_part, _)) = dir_name.split_once('-') {
253-
if let Some(util_name) = util_part.strip_prefix("uu_") {
254-
embed_component_locales(
255-
embedded_file,
256-
locales_to_embed,
257-
util_name,
258-
|locale| entry.path().join(format!("locales/{locale}.ftl")),
259-
)?;
260-
}
261-
}
250+
// Match uu_<util>-<version>
251+
if let Some(dir_name) = file_name.to_str()
252+
&& let Some((util_part, _)) = dir_name.split_once('-')
253+
&& let Some(util_name) = util_part.strip_prefix("uu_")
254+
{
255+
embed_component_locales(embedded_file, locales_to_embed, util_name, |locale| {
256+
entry.path().join(format!("locales/{locale}.ftl"))
257+
})?;
262258
}
263259
}
264260

@@ -366,25 +362,26 @@ where
366362
F: Fn(&str) -> PathBuf,
367363
{
368364
let en_path = path_builder("en-US");
369-
if let Some(locale_dir) = en_path.parent() {
370-
if locale_dir.exists() {
371-
for entry in std::fs::read_dir(locale_dir)? {
372-
let entry = entry?;
373-
let path = entry.path();
374-
if path.extension().is_some_and(|e| e == "ftl") {
375-
if let Some(locale) = path.file_stem().and_then(|s| s.to_str()) {
376-
embed_locale_file(
377-
embedded_file,
378-
&path,
379-
&format!("{component_name}/{locale}.ftl"),
380-
locale,
381-
component_name,
382-
)?;
383-
}
384-
}
365+
if let Some(locale_dir) = en_path.parent()
366+
&& locale_dir.exists()
367+
{
368+
for entry in std::fs::read_dir(locale_dir)? {
369+
let entry = entry?;
370+
let path = entry.path();
371+
if path.extension().is_some_and(|e| e == "ftl")
372+
&& let Some(locale) = path.file_stem().and_then(|s| s.to_str())
373+
{
374+
embed_locale_file(
375+
embedded_file,
376+
&path,
377+
&format!("{component_name}/{locale}.ftl"),
378+
locale,
379+
component_name,
380+
)?;
385381
}
386382
}
387383
}
384+
388385
Ok(())
389386
}
390387

0 commit comments

Comments
 (0)