diff --git a/.vscode/settings.json b/.vscode/settings.json index 5a0cd53..1c09785 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -2,6 +2,7 @@ "luau-lsp.types.roblox": false, "luau-lsp.types.definitionFiles": ["luneTypes.d.luau"], "luau-lsp.sourcemap.enabled": false, + "rust-analyzer.check.command": "clippy", "editor.formatOnSave": true, "stylua.searchParentDirectories": true, "prettier.tabWidth": 2, diff --git a/src/lune/fs.rs b/src/lune/fs.rs index 608891f..98ac777 100644 --- a/src/lune/fs.rs +++ b/src/lune/fs.rs @@ -25,9 +25,9 @@ impl UserData for LuneFs { } async fn fs_read_file(_: &Lua, path: String) -> Result { - Ok(fs::read_to_string(&path) + fs::read_to_string(&path) .await - .map_err(mlua::Error::external)?) + .map_err(mlua::Error::external) } async fn fs_read_dir(_: &Lua, path: String) -> Result> { @@ -61,27 +61,25 @@ async fn fs_read_dir(_: &Lua, path: String) -> Result> { } async fn fs_write_file(_: &Lua, (path, contents): (String, String)) -> Result<()> { - Ok(fs::write(&path, &contents) + fs::write(&path, &contents) .await - .map_err(mlua::Error::external)?) + .map_err(mlua::Error::external) } async fn fs_write_dir(_: &Lua, path: String) -> Result<()> { - Ok(fs::create_dir_all(&path) + fs::create_dir_all(&path) .await - .map_err(mlua::Error::external)?) + .map_err(mlua::Error::external) } async fn fs_remove_file(_: &Lua, path: String) -> Result<()> { - Ok(fs::remove_file(&path) - .await - .map_err(mlua::Error::external)?) + fs::remove_file(&path).await.map_err(mlua::Error::external) } async fn fs_remove_dir(_: &Lua, path: String) -> Result<()> { - Ok(fs::remove_dir_all(&path) + fs::remove_dir_all(&path) .await - .map_err(mlua::Error::external)?) + .map_err(mlua::Error::external) } async fn fs_is_file(_: &Lua, path: String) -> Result { diff --git a/src/lune/json.rs b/src/lune/json.rs index 488475e..d24b527 100644 --- a/src/lune/json.rs +++ b/src/lune/json.rs @@ -24,5 +24,5 @@ fn json_encode(_: &Lua, (val, pretty): (Value, Option)) -> Result } fn json_decode(lua: &Lua, json: String) -> Result { - Ok(lua.to_value(&json)?) + lua.to_value(&json) } diff --git a/src/lune/process.rs b/src/lune/process.rs index 9b3c345..ff9ca51 100644 --- a/src/lune/process.rs +++ b/src/lune/process.rs @@ -44,7 +44,8 @@ fn process_get_env_var(lua: &Lua, key: String) -> Result { } fn process_set_env_var(_: &Lua, (key, value): (String, String)) -> Result<()> { - Ok(env::set_var(&key, &value)) + env::set_var(key, value); + Ok(()) } fn process_exit(_: &Lua, exit_code: Option) -> Result<()> { @@ -78,7 +79,7 @@ async fn process_spawn(lua: &Lua, (program, args): (String, Option>) let code = output .status .code() - .unwrap_or_else(|| match output.stderr.is_empty() { + .unwrap_or(match output.stderr.is_empty() { true => 0, false => 1, }); diff --git a/src/main.rs b/src/main.rs index cc8fd7e..148bf75 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,3 +1,5 @@ +#![deny(clippy::all, clippy::cargo)] + use clap::Parser; use mlua::Result; diff --git a/src/utils.rs b/src/utils.rs index 2e31705..b72fa99 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -28,6 +28,6 @@ pub fn pretty_print_luau_error(e: &mlua::Error) { from, to, msg ) } - e => eprintln!("{}", e.to_string()), + e => eprintln!("{e}"), } }