Skip to content

Commit

Permalink
fix 1.67 clippy warnings (compatible with MSRV) (#6179)
Browse files Browse the repository at this point in the history
  • Loading branch information
chippers committed Feb 1, 2023
1 parent 314f0e2 commit 50576a5
Show file tree
Hide file tree
Showing 14 changed files with 82 additions and 298 deletions.
159 changes: 28 additions & 131 deletions core/config-schema/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -720,47 +720,19 @@
},
"Theme": {
"description": "System theme.",
"oneOf": [
{
"description": "Light theme.",
"type": "string",
"enum": [
"Light"
]
},
{
"description": "Dark theme.",
"type": "string",
"enum": [
"Dark"
]
}
"type": "string",
"enum": [
"Light",
"Dark"
]
},
"TitleBarStyle": {
"description": "How the window title bar should be displayed on macOS.",
"oneOf": [
{
"description": "A normal title bar.",
"type": "string",
"enum": [
"Visible"
]
},
{
"description": "Makes the title bar transparent, so the window background color is shown instead.\n\nUseful if you don't need to have actual HTML under the title bar. This lets you avoid the caveats of using `TitleBarStyle::Overlay`. Will be more useful when Tauri lets you set a custom window background color.",
"type": "string",
"enum": [
"Transparent"
]
},
{
"description": "Shows the title bar as a transparent overlay over the window's content.\n\nKeep in mind: - The height of the title bar is different on different OS versions, which can lead to window the controls and title not being where you don't expect. - You need to define a custom drag region to make your window draggable, however due to a limitation you can't drag the window when it's not in focus <https://github.com/tauri-apps/tauri/issues/4316>. - The color of the window title depends on the system theme.",
"type": "string",
"enum": [
"Overlay"
]
}
"type": "string",
"enum": [
"Visible",
"Transparent",
"Overlay"
]
},
"CliConfig": {
Expand Down Expand Up @@ -1183,56 +1155,15 @@
},
"BundleType": {
"description": "A bundle referenced by tauri-bundler.",
"oneOf": [
{
"description": "The debian bundle (.deb).",
"type": "string",
"enum": [
"deb"
]
},
{
"description": "The AppImage bundle (.appimage).",
"type": "string",
"enum": [
"appimage"
]
},
{
"description": "The Microsoft Installer bundle (.msi).",
"type": "string",
"enum": [
"msi"
]
},
{
"description": "The NSIS bundle (.exe).",
"type": "string",
"enum": [
"nsis"
]
},
{
"description": "The macOS application bundle (.app).",
"type": "string",
"enum": [
"app"
]
},
{
"description": "The Apple Disk Image bundle (.dmg).",
"type": "string",
"enum": [
"dmg"
]
},
{
"description": "The Tauri updater bundle.",
"type": "string",
"enum": [
"updater"
]
}
"type": "string",
"enum": [
"deb",
"appimage",
"msi",
"nsis",
"app",
"dmg",
"updater"
]
},
"AppImageConfig": {
Expand Down Expand Up @@ -1716,28 +1647,11 @@
},
"NSISInstallerMode": {
"description": "Install Modes for the NSIS installer.",
"oneOf": [
{
"description": "Default mode for the installer.\n\nInstall the app by default in a directory that doesn't require Administrator access.\n\nInstaller metadata will be saved under the `HKCU` registry path.",
"type": "string",
"enum": [
"currentUser"
]
},
{
"description": "Install the app by default in the `Program Files` folder directory requires Administrator access for the installation.\n\nInstaller metadata will be saved under the `HKLM` registry path.",
"type": "string",
"enum": [
"perMachine"
]
},
{
"description": "Combines both modes and allows the user to choose at install time whether to install for the current user or per machine. Note that this mode will require Administrator access even if the user wants to install it for the current user only.\n\nInstaller metadata will be saved under the `HKLM` or `HKCU` registry path based on the user's choice.",
"type": "string",
"enum": [
"both"
]
}
"type": "string",
"enum": [
"currentUser",
"perMachine",
"both"
]
},
"AllowlistConfig": {
Expand Down Expand Up @@ -2730,28 +2644,11 @@
},
"WindowsUpdateInstallMode": {
"description": "Install modes for the Windows update.",
"oneOf": [
{
"description": "Specifies there's a basic UI during the installation process, including a final dialog box at the end.",
"type": "string",
"enum": [
"basicUi"
]
},
{
"description": "The quiet mode means there's no user interaction required. Requires admin privileges if the installer does (WiX).",
"type": "string",
"enum": [
"quiet"
]
},
{
"description": "Specifies unattended mode, which means the installation only shows a progress bar.",
"type": "string",
"enum": [
"passive"
]
}
"type": "string",
"enum": [
"basicUi",
"quiet",
"passive"
]
},
"SystemTrayConfig": {
Expand Down
3 changes: 1 addition & 2 deletions core/tauri/src/api/file/extract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -279,9 +279,8 @@ fn set_perms(
) -> crate::api::Result<()> {
_set_perms(dst, f, mode, preserve).map_err(|_| {
crate::api::Error::Extract(format!(
"failed to set permissions to {:o} \
"failed to set permissions to {mode:o} \
for `{}`",
mode,
dst.display()
))
})
Expand Down
5 changes: 2 additions & 3 deletions core/tauri/src/api/ipc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ const MIN_JSON_PARSE_LEN: usize = 10_240;
/// bar: String,
/// }
/// let foo = Foo { bar: "x".repeat(20_000).into() };
/// let value = serialize_js_with(&foo, SerializeOptions::default(), |v| format!("console.log({})", v)).unwrap();
/// let value = serialize_js_with(&foo, SerializeOptions::default(), |v| format!("console.log({v})")).unwrap();
/// assert_eq!(value, format!("console.log(JSON.parse('{{\"bar\":\"{}\"}}'))", foo.bar));
/// ```
pub fn serialize_js_with<T: Serialize, F: FnOnce(&str) -> String>(
Expand Down Expand Up @@ -179,8 +179,7 @@ pub fn format_callback<T: Serialize>(
}} else {{
console.warn("[TAURI] Couldn't find callback id {fn} in window. This happens when the app is reloaded while Rust is running an asynchronous operation.")
}}"#,
fn = function_name.0,
arg = arg
fn = function_name.0
)
})
}
Expand Down
6 changes: 3 additions & 3 deletions core/tauri/src/api/notification.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
//! Types and functions related to desktop notifications.

#[cfg(windows)]
use std::path::MAIN_SEPARATOR;
use std::path::MAIN_SEPARATOR as SEP;

/// The desktop notification definition.
///
Expand Down Expand Up @@ -114,8 +114,8 @@ impl Notification {
let exe_dir = exe.parent().expect("failed to get exe directory");
let curr_dir = exe_dir.display().to_string();
// set the notification's System.AppUserModel.ID only when running the installed app
if !(curr_dir.ends_with(format!("{S}target{S}debug", S = MAIN_SEPARATOR).as_str())
|| curr_dir.ends_with(format!("{S}target{S}release", S = MAIN_SEPARATOR).as_str()))
if !(curr_dir.ends_with(format!("{SEP}target{SEP}debug").as_str())
|| curr_dir.ends_with(format!("{SEP}target{SEP}release").as_str()))
{
notification.app_id(&self.identifier);
}
Expand Down
4 changes: 2 additions & 2 deletions core/tauri/src/api/process/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,9 +137,9 @@ pub struct Output {
fn relative_command_path(command: String) -> crate::Result<String> {
match platform::current_exe()?.parent() {
#[cfg(windows)]
Some(exe_dir) => Ok(format!("{}\\{}.exe", exe_dir.display(), command)),
Some(exe_dir) => Ok(format!("{}\\{command}.exe", exe_dir.display())),
#[cfg(not(windows))]
Some(exe_dir) => Ok(format!("{}/{}", exe_dir.display(), command)),
Some(exe_dir) => Ok(format!("{}/{command}", exe_dir.display())),
None => Err(crate::api::Error::Command("Could not evaluate executable dir".to_string()).into()),
}
}
Expand Down
2 changes: 1 addition & 1 deletion core/tauri/src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1503,7 +1503,7 @@ impl<R: Runtime> Builder<R> {
/// ```
/// let kind = if cfg!(debug_assertions) { "debug" } else { "release" };
/// tauri::Builder::default()
/// .updater_target(format!("{}-{}", tauri::updater::target().unwrap(), kind));
/// .updater_target(format!("{}-{kind}", tauri::updater::target().unwrap()));
/// ```
///
/// - Use the platform's target triple:
Expand Down
2 changes: 1 addition & 1 deletion core/tauri/src/endpoints/file_system.rs
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@ fn resolve_path<R: Runtime>(
}
}
Err(e) => super::Result::<SafePathBuf>::Err(e.into())
.with_context(|| format!("path: {}, base dir: {:?}", path.display(), dir)),
.with_context(|| format!("path: {}, base dir: {dir:?}", path.display())),
}
}

Expand Down
3 changes: 0 additions & 3 deletions core/tauri/src/event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -342,14 +342,11 @@ pub fn listen_js(
}})()
",
listeners = listeners_object_name,
event = event,
event_id = event_id,
window_label = if let Some(l) = window_label {
crate::runtime::window::assert_label_is_valid(&l);
format!("'{l}'")
} else {
"null".to_owned()
},
handler = handler
)
}
2 changes: 1 addition & 1 deletion core/tauri/src/manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -621,7 +621,7 @@ impl<R: Runtime> WindowManager<R> {
.insert("Content-Length", real_length.to_string());
data.headers.insert(
"Content-Range",
format!("bytes {}-{}/{}", range.start, last_byte, file_size),
format!("bytes {}-{last_byte}/{file_size}", range.start),
);

if let Err(e) = file.seek(std::io::SeekFrom::Start(range.start)).await {
Expand Down
5 changes: 2 additions & 3 deletions core/tauri/src/scope/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -256,10 +256,9 @@ fn escaped_pattern(p: &str) -> Result<Pattern, glob::PatternError> {

fn escaped_pattern_with(p: &str, append: &str) -> Result<Pattern, glob::PatternError> {
Pattern::new(&format!(
"{}{}{}",
"{}{}{append}",
glob::Pattern::escape(p),
MAIN_SEPARATOR,
append
MAIN_SEPARATOR
))
}

Expand Down
11 changes: 5 additions & 6 deletions core/tauri/src/updater/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -758,7 +758,7 @@ fn copy_files_and_run<R: Read + Seek>(
let product_name = bin_name.replace(".exe", "");

// Check if there is a task that enables the updater to skip the UAC prompt
let update_task_name = format!("Update {} - Skip UAC", product_name);
let update_task_name = format!("Update {product_name} - Skip UAC");
if let Ok(output) = Command::new("schtasks")
.arg("/QUERY")
.arg("/TN")
Expand Down Expand Up @@ -1575,11 +1575,10 @@ mod test {
#[cfg(target_os = "windows")]
let archive_file = "archive.windows.zip";

let good_archive_url = format!("{}/{}", mockito::server_url(), archive_file);
let good_archive_url = format!("{}/{archive_file}", mockito::server_url());

let mut signature_file = File::open(format!(
"./test/updater/fixture/archives/{}.sig",
archive_file
"./test/updater/fixture/archives/{archive_file}.sig"
))
.expect("Unable to open signature");
let mut signature = String::new();
Expand All @@ -1595,10 +1594,10 @@ mod test {
.expect("Unable to read signature as string");

// add sample file
let _m = mockito::mock("GET", format!("/{}", archive_file).as_str())
let _m = mockito::mock("GET", format!("/{archive_file}").as_str())
.with_status(200)
.with_header("content-type", "application/octet-stream")
.with_body_from_file(format!("./test/updater/fixture/archives/{}", archive_file))
.with_body_from_file(format!("./test/updater/fixture/archives/{archive_file}"))
.create();

// sample mock for update file
Expand Down
8 changes: 4 additions & 4 deletions core/tauri/src/updater/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ impl<R: Runtime> UpdateBuilder<R> {
/// let handle = app.handle();
/// tauri::async_runtime::spawn(async move {
/// let kind = if cfg!(debug_assertions) { "debug" } else { "release" };
/// let builder = tauri::updater::builder(handle).target(format!("{}-{}", tauri::updater::target().unwrap(), kind));
/// let builder = tauri::updater::builder(handle).target(format!("{}-{kind}", tauri::updater::target().unwrap()));
/// match builder.check().await {
/// Ok(update) => {}
/// Err(error) => {}
Expand Down Expand Up @@ -567,13 +567,13 @@ async fn prompt_for_install<R: Runtime>(
parent_window,
format!(r#"A new version of {app_name} is available! "#),
format!(
r#"{} {} is now available -- you have {}.
r#"{app_name} {} is now available -- you have {}.
Would you like to install it now?
Release Notes:
{}"#,
app_name, update.version, update.current_version, body,
{body}"#,
update.version, update.current_version
),
);

Expand Down
Loading

0 comments on commit 50576a5

Please sign in to comment.