chore: Fix clippy 1.84 warnings (#12328)

This commit is contained in:
Fabian-Lars 2025-01-10 13:47:37 +01:00 committed by GitHub
parent b0d7527250
commit cde0ff7798
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
17 changed files with 737 additions and 783 deletions

1458
Cargo.lock generated

File diff suppressed because it is too large Load Diff

View File

@ -68,7 +68,7 @@ fn copy_binaries(
.to_string_lossy()
.replace(&format!("-{target_triple}"), "");
if package_name.map_or(false, |n| n == &file_name) {
if package_name == Some(&file_name) {
return Err(anyhow::anyhow!(
"Cannot define a sidecar with the same name as the Cargo package name `{}`. Please change the sidecar name in the filesystem and the Tauri configuration.",
file_name
@ -675,7 +675,7 @@ pub fn try_build(attributes: Attributes) -> Result<()> {
}
}
"msvc" => {
if env::var("STATIC_VCRUNTIME").map_or(false, |v| v == "true") {
if env::var("STATIC_VCRUNTIME").is_ok_and(|v| v == "true") {
static_vcruntime::build();
}
}

View File

@ -70,8 +70,7 @@ pub fn bundle_project(settings: &Settings) -> crate::Result<Vec<Bundle>> {
// Sign the sidecar binaries
for bin in settings.external_binaries() {
let path = bin?;
let skip =
std::env::var("TAURI_SKIP_SIDECAR_SIGNATURE_CHECK").map_or(false, |v| v == "true");
let skip = std::env::var("TAURI_SKIP_SIDECAR_SIGNATURE_CHECK").is_ok_and(|v| v == "true");
if skip {
continue;
}

View File

@ -166,16 +166,15 @@ pub fn command(options: Options) -> Result<()> {
let capabilities = if let Some((expected_platforms, target_name)) = expected_capability_config {
let mut capabilities = capabilities_iter
.filter(|(capability, _path)| {
capability.platforms().map_or(
false, /* allows any target, so we should skip it since we're adding a target-specific plugin */
|platforms| {
// all platforms must be in the expected platforms list
platforms.iter().all(|p| expected_platforms.contains(&p.to_string()))
},
)
.filter(|(capability, _path)| {
capability.platforms().is_some_and(|platforms| {
// all platforms must be in the expected platforms list
platforms
.iter()
.all(|p| expected_platforms.contains(&p.to_string()))
})
.collect::<Vec<_>>();
})
.collect::<Vec<_>>();
if capabilities.is_empty() {
let identifier = format!("{target_name}-capability");

View File

@ -93,7 +93,7 @@ pub fn wix_settings(config: WixConfig) -> tauri_bundler::WixSettings {
enable_elevated_update_task: config.enable_elevated_update_task,
banner_path: config.banner_path,
dialog_image_path: config.dialog_image_path,
fips_compliant: var_os("TAURI_BUNDLER_WIX_FIPS_COMPLIANT").map_or(false, |v| v == "true"),
fips_compliant: var_os("TAURI_BUNDLER_WIX_FIPS_COMPLIANT").is_some_and(|v| v == "true"),
}
}

View File

@ -267,7 +267,7 @@ mod sys {
}
pub(super) fn error_contended(err: &Error) -> bool {
err.raw_os_error().map_or(false, |x| x == libc::EWOULDBLOCK)
err.raw_os_error() == Some(libc::EWOULDBLOCK)
}
pub(super) fn error_unsupported(err: &Error) -> bool {

View File

@ -52,7 +52,7 @@ pub fn parse<P: AsRef<Path>>(path: P) -> crate::Result<Pbxproj> {
State::XCBuildConfigurationObject { id } => {
if line.contains("buildSettings") {
state = State::XCBuildConfigurationObjectBuildSettings { id: id.clone() };
} else if split_at_identation(line).map_or(false, |(_ident, token)| token == "};") {
} else if split_at_identation(line).is_some_and(|(_ident, token)| token == "};") {
state = State::XCBuildConfiguration;
}
}
@ -122,7 +122,7 @@ pub fn parse<P: AsRef<Path>>(path: P) -> crate::Result<Pbxproj> {
State::XCConfigurationListObject { id } => {
if line.contains("buildConfigurations") {
state = State::XCConfigurationListObjectBuildConfigurations { id: id.clone() };
} else if split_at_identation(line).map_or(false, |(_ident, token)| token == "};") {
} else if split_at_identation(line).is_some_and(|(_ident, token)| token == "};") {
state = State::XCConfigurationList;
}
}

View File

@ -145,9 +145,9 @@ impl Interface for Rust {
manifest
};
let target_ios = target.as_ref().map_or(false, |target| {
target.ends_with("ios") || target.ends_with("ios-sim")
});
let target_ios = target
.as_ref()
.is_some_and(|target| target.ends_with("ios") || target.ends_with("ios-sim"));
if target_ios {
std::env::set_var(
"IPHONEOS_DEPLOYMENT_TARGET",

View File

@ -156,7 +156,7 @@ pub fn build(
let out_dir = app_settings.out_dir(&options)?;
let bin_path = app_settings.app_binary_path(&options)?;
if !std::env::var("STATIC_VCRUNTIME").map_or(false, |v| v == "false") {
if !std::env::var("STATIC_VCRUNTIME").is_ok_and(|v| v == "false") {
std::env::set_var("STATIC_VCRUNTIME", "true");
}

View File

@ -21,7 +21,7 @@ pub fn migrate(tauri_dir: &Path) -> Result<MigratedConfig> {
tauri_utils_v1::config::parse::parse_value(tauri_dir.join("tauri.conf.json"))
{
let migrated = migrate_config(&mut config)?;
if config_path.extension().map_or(false, |ext| ext == "toml") {
if config_path.extension().is_some_and(|ext| ext == "toml") {
fs::write(&config_path, toml::to_string_pretty(&config)?)?;
} else {
fs::write(&config_path, serde_json::to_string_pretty(&config)?)?;

View File

@ -143,7 +143,7 @@ fn migrate_imports<'a>(
let has_partial_js = path
.extension()
.map_or(false, |ext| ext == "vue" || ext == "svelte");
.is_some_and(|ext| ext == "vue" || ext == "svelte");
let sources = if !has_partial_js {
vec![(SourceType::from_path(path).unwrap(), js_source, 0i64)]

View File

@ -99,7 +99,7 @@ fn migrate_permissions(tauri_dir: &Path) -> Result<()> {
for entry in walkdir::WalkDir::new(tauri_dir.join("capabilities")) {
let entry = entry?;
let path = entry.path();
if path.extension().map_or(false, |ext| ext == "json") {
if path.extension().is_some_and(|ext| ext == "json") {
let mut capability = read_to_string(path).context("failed to read capability")?;
for plugin in core_plugins {
capability = capability.replace(&format!("\"{plugin}:"), &format!("\"core:{plugin}:"));

View File

@ -68,7 +68,7 @@ pub fn command(options: Options) -> Result<()> {
// `xcode-script` is ran from the `gen/apple` folder when not using NPM.
// so we must change working directory to the src-tauri folder to resolve the tauri dir
if (var_os("npm_lifecycle_event").is_none() && var_os("PNPM_PACKAGE_NAME").is_none())
|| var("npm_config_user_agent").map_or(false, |agent| agent.starts_with("bun"))
|| var("npm_config_user_agent").is_ok_and(|agent| agent.starts_with("bun"))
{
set_current_dir(current_dir()?.parent().unwrap().parent().unwrap()).unwrap();
}

View File

@ -16,3 +16,8 @@ tower-service = "0.3"
semver = { version = "1", features = ["serde"] }
serde = { version = "1", features = ["derive"] }
anyhow = "1"
[lints.rust]
unexpected_cfgs = { level = "warn", check-cfg = [
'cfg(wasm_bindgen_unstable_test_coverage)',
] }

View File

@ -237,10 +237,7 @@ impl ResourcePathsIter<'_> {
self.current_path = None;
let pattern = match &mut self.pattern_iter {
PatternIter::Slice(iter) => match iter.next() {
Some(pattern) => pattern,
None => return None,
},
PatternIter::Slice(iter) => iter.next()?,
PatternIter::Map(iter) => match iter.next() {
Some((pattern, dest)) => {
self.current_pattern = Some(pattern.clone());

View File

@ -259,7 +259,7 @@ fn main() {
// workaround needed to prevent `STATUS_ENTRYPOINT_NOT_FOUND` error in tests
// see https://github.com/tauri-apps/tauri/pull/4383#issuecomment-1212221864
let target_env = std::env::var("CARGO_CFG_TARGET_ENV");
let is_tauri_workspace = std::env::var("__TAURI_WORKSPACE__").map_or(false, |v| v == "true");
let is_tauri_workspace = std::env::var("__TAURI_WORKSPACE__").is_ok_and(|v| v == "true");
if is_tauri_workspace && target_os == "windows" && Ok("msvc") == target_env.as_deref() {
embed_manifest_for_tests();
}

View File

@ -26,7 +26,7 @@ fn main() {
// see https://github.com/tauri-apps/tauri/pull/4383#issuecomment-1212221864
let target_os = std::env::var("CARGO_CFG_TARGET_OS").unwrap();
let target_env = std::env::var("CARGO_CFG_TARGET_ENV");
let is_tauri_workspace = std::env::var("__TAURI_WORKSPACE__").map_or(false, |v| v == "true");
let is_tauri_workspace = std::env::var("__TAURI_WORKSPACE__").is_ok_and(|v| v == "true");
if is_tauri_workspace && target_os == "windows" && Ok("msvc") == target_env.as_deref() {
embed_manifest_for_tests();
}