fix: clippy
This commit is contained in:
parent
4ab8519af6
commit
2c8c601579
|
@ -50,7 +50,7 @@ pub fn build(config: &CrateConfig, quiet: bool) -> Result<BuildResult> {
|
|||
log::info!("🚅 Running build command...");
|
||||
let cmd = subprocess::Exec::cmd("cargo");
|
||||
let cmd = cmd
|
||||
.cwd(&crate_dir)
|
||||
.cwd(crate_dir)
|
||||
.arg("build")
|
||||
.arg("--target")
|
||||
.arg("wasm32-unknown-unknown")
|
||||
|
@ -152,7 +152,7 @@ pub fn build(config: &CrateConfig, quiet: bool) -> Result<BuildResult> {
|
|||
"-o",
|
||||
target_file.to_str().unwrap(),
|
||||
];
|
||||
if config.release == true {
|
||||
if config.release {
|
||||
args.push("-Oz");
|
||||
}
|
||||
binaryen.call("wasm-opt", args)?;
|
||||
|
@ -192,7 +192,7 @@ pub fn build(config: &CrateConfig, quiet: bool) -> Result<BuildResult> {
|
|||
config_path,
|
||||
];
|
||||
|
||||
if config.release == true {
|
||||
if config.release {
|
||||
args.push("--minify");
|
||||
}
|
||||
|
||||
|
@ -215,7 +215,7 @@ pub fn build(config: &CrateConfig, quiet: bool) -> Result<BuildResult> {
|
|||
depth: 0,
|
||||
};
|
||||
if asset_dir.is_dir() {
|
||||
for entry in std::fs::read_dir(&asset_dir)? {
|
||||
for entry in std::fs::read_dir(asset_dir)? {
|
||||
let path = entry?.path();
|
||||
if path.is_file() {
|
||||
std::fs::copy(&path, out_dir.join(path.file_name().unwrap()))?;
|
||||
|
|
|
@ -55,7 +55,7 @@ impl Metadata {
|
|||
/// TODO @Jon, find a different way that doesn't rely on the cargo metadata command (it's slow)
|
||||
pub fn get() -> Result<Self> {
|
||||
let output = Command::new("cargo")
|
||||
.args(&["metadata"])
|
||||
.args(["metadata"])
|
||||
.output()
|
||||
.map_err(|_| Error::CargoError("Manifset".to_string()))?;
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
use futures::{stream::FuturesUnordered, StreamExt};
|
||||
use std::{fs, process::exit};
|
||||
use std::{fs, process::exit, path::Path};
|
||||
|
||||
use super::*;
|
||||
|
||||
|
@ -135,7 +135,7 @@ async fn autoformat_project(check: bool) -> Result<()> {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
fn collect_rs_files(folder: &PathBuf, files: &mut Vec<PathBuf>) {
|
||||
fn collect_rs_files(folder: &Path, files: &mut Vec<PathBuf>) {
|
||||
let Ok(folder) = folder.read_dir() else { return };
|
||||
|
||||
// load the gitignore
|
||||
|
|
|
@ -11,9 +11,11 @@ pub struct Create {
|
|||
|
||||
impl Create {
|
||||
pub fn create(self) -> Result<()> {
|
||||
let mut args = GenerateArgs::default();
|
||||
args.template_path = TemplatePath {
|
||||
auto_path: Some(self.template),
|
||||
let args = GenerateArgs {
|
||||
template_path: TemplatePath {
|
||||
auto_path: Some(self.template),
|
||||
..Default::default()
|
||||
},
|
||||
..Default::default()
|
||||
};
|
||||
|
||||
|
@ -65,10 +67,8 @@ impl Create {
|
|||
fn remove_tripple_newlines(string: &str) -> String {
|
||||
let mut new_string = String::new();
|
||||
for char in string.chars() {
|
||||
if char == '\n' {
|
||||
if new_string.ends_with("\n\n") {
|
||||
continue;
|
||||
}
|
||||
if char == '\n' && new_string.ends_with("\n\n") {
|
||||
continue;
|
||||
}
|
||||
new_string.push(char);
|
||||
}
|
||||
|
|
|
@ -19,6 +19,7 @@ use clap::{Parser, Subcommand};
|
|||
use html_parser::Dom;
|
||||
use serde::Deserialize;
|
||||
use std::{
|
||||
fmt::Display,
|
||||
fs::{remove_dir_all, File},
|
||||
io::{Read, Write},
|
||||
path::PathBuf,
|
||||
|
@ -71,19 +72,18 @@ pub enum Commands {
|
|||
Plugin(plugin::Plugin),
|
||||
}
|
||||
|
||||
impl Commands {
|
||||
pub fn to_string(&self) -> String {
|
||||
impl Display for Commands {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
match self {
|
||||
Commands::Build(_) => "build",
|
||||
Commands::Translate(_) => "translate",
|
||||
Commands::Serve(_) => "serve",
|
||||
Commands::Create(_) => "create",
|
||||
Commands::Clean(_) => "clean",
|
||||
Commands::Config(_) => "config",
|
||||
Commands::Plugin(_) => "plugin",
|
||||
Commands::Version(_) => "version",
|
||||
Commands::Autoformat(_) => "fmt",
|
||||
Commands::Build(_) => write!(f, "build"),
|
||||
Commands::Translate(_) => write!(f, "translate"),
|
||||
Commands::Serve(_) => write!(f, "serve"),
|
||||
Commands::Create(_) => write!(f, "create"),
|
||||
Commands::Clean(_) => write!(f, "clean"),
|
||||
Commands::Config(_) => write!(f, "config"),
|
||||
Commands::Plugin(_) => write!(f, "plugin"),
|
||||
Commands::Version(_) => write!(f, "version"),
|
||||
Commands::Autoformat(_) => write!(f, "fmt"),
|
||||
}
|
||||
.to_string()
|
||||
}
|
||||
}
|
||||
}
|
|
@ -39,7 +39,7 @@ impl Translate {
|
|||
|
||||
// Write the output
|
||||
match self.output {
|
||||
Some(output) => std::fs::write(&output, out)?,
|
||||
Some(output) => std::fs::write(output, out)?,
|
||||
None => print!("{}", out),
|
||||
}
|
||||
|
||||
|
@ -48,7 +48,7 @@ impl Translate {
|
|||
}
|
||||
|
||||
pub fn convert_html_to_formatted_rsx(dom: &Dom, component: bool) -> String {
|
||||
let callbody = rsx_rosetta::rsx_from_html(&dom);
|
||||
let callbody = rsx_rosetta::rsx_from_html(dom);
|
||||
|
||||
match component {
|
||||
true => write_callbody_with_icon_section(callbody),
|
||||
|
@ -114,7 +114,7 @@ fn determine_input(file: Option<String>, raw: Option<String>) -> Result<String>
|
|||
}
|
||||
|
||||
if let Some(file) = file {
|
||||
return Ok(std::fs::read_to_string(&file)?);
|
||||
return Ok(std::fs::read_to_string(file)?);
|
||||
}
|
||||
|
||||
// If neither exist, we try to read from stdin
|
||||
|
|
|
@ -184,7 +184,7 @@ impl CrateConfig {
|
|||
None => crate_dir.join("public"),
|
||||
};
|
||||
|
||||
let manifest = cargo_toml::Manifest::from_path(&cargo_def).unwrap();
|
||||
let manifest = cargo_toml::Manifest::from_path(cargo_def).unwrap();
|
||||
|
||||
let output_filename = {
|
||||
match &manifest.package.as_ref().unwrap().default_run {
|
||||
|
|
|
@ -2,6 +2,7 @@ use std::process::{Command, Stdio};
|
|||
|
||||
use mlua::{FromLua, UserData};
|
||||
|
||||
#[derive(Debug, Clone, Copy)]
|
||||
enum StdioFromString {
|
||||
Inherit,
|
||||
Piped,
|
||||
|
@ -41,7 +42,7 @@ impl UserData for PluginCommander {
|
|||
let stdout = args.1;
|
||||
let stderr = args.2;
|
||||
|
||||
if cmd.len() == 0 {
|
||||
if cmd.is_empty() {
|
||||
return Ok(());
|
||||
}
|
||||
let cmd_name = cmd.get(0).unwrap();
|
||||
|
|
|
@ -58,7 +58,7 @@ impl UserData for PluginFileSystem {
|
|||
let file = PathBuf::from(args.0);
|
||||
let target = PathBuf::from(args.1);
|
||||
let res = extract_zip(&file, &target);
|
||||
if let Err(_) = res {
|
||||
if res.is_err() {
|
||||
return Ok(false);
|
||||
}
|
||||
Ok(true)
|
||||
|
|
|
@ -18,10 +18,11 @@ impl UserData for PluginPath {
|
|||
methods.add_function("parent", |_, path: String| {
|
||||
let current_path = PathBuf::from(&path);
|
||||
let parent = current_path.parent();
|
||||
if parent.is_none() {
|
||||
return Ok(path);
|
||||
|
||||
if let Some(parent) = parent {
|
||||
Ok(parent.to_str().unwrap().to_string())
|
||||
} else {
|
||||
return Ok(parent.unwrap().to_str().unwrap().to_string());
|
||||
Ok(path)
|
||||
}
|
||||
});
|
||||
methods.add_function("exists", |_, path: String| {
|
||||
|
|
|
@ -151,14 +151,12 @@ impl PluginManager {
|
|||
}
|
||||
}
|
||||
}
|
||||
} else if let Ok(index) = name_index.get::<_, u32>(info.name.clone()) {
|
||||
let _ = manager.set(index, info.clone());
|
||||
} else {
|
||||
if let Ok(index) = name_index.get::<_, u32>(info.name.clone()) {
|
||||
let _ = manager.set(index, info.clone());
|
||||
} else {
|
||||
let _ = manager.set(index, info.clone());
|
||||
index += 1;
|
||||
let _ = name_index.set(info.name, index);
|
||||
}
|
||||
let _ = manager.set(index, info.clone());
|
||||
index += 1;
|
||||
let _ = name_index.set(info.name, index);
|
||||
}
|
||||
}
|
||||
Err(_e) => {
|
||||
|
@ -172,7 +170,7 @@ impl PluginManager {
|
|||
|
||||
lua.globals().set("manager", manager).unwrap();
|
||||
|
||||
return Ok(());
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn on_build_start(crate_config: &CrateConfig, platform: &str) -> anyhow::Result<()> {
|
||||
|
|
|
@ -631,7 +631,7 @@ fn print_console_info(ip: &String, port: u16, config: &CrateConfig, options: Pre
|
|||
"\t> Network : {}",
|
||||
format!("http://{}:{}/", ip, port).blue()
|
||||
);
|
||||
println!("");
|
||||
println!();
|
||||
println!("\t> Profile : {}", profile.green());
|
||||
println!("\t> Hot Reload : {}", hot_reload.cyan());
|
||||
if let Some(proxies) = proxies {
|
||||
|
@ -644,14 +644,14 @@ fn print_console_info(ip: &String, port: u16, config: &CrateConfig, options: Pre
|
|||
}
|
||||
println!("\t> Index Template : {}", custom_html_file.green());
|
||||
println!("\t> URL Rewrite [index_on_404] : {}", url_rewrite.purple());
|
||||
println!("");
|
||||
println!();
|
||||
println!(
|
||||
"\t> Build Time Use : {} millis",
|
||||
options.elapsed_time.to_string().green().bold()
|
||||
);
|
||||
println!("");
|
||||
println!();
|
||||
|
||||
if options.warnings.len() == 0 {
|
||||
if options.warnings.is_empty() {
|
||||
log::info!("{}\n", "A perfect compilation!".green().bold());
|
||||
} else {
|
||||
log::warn!(
|
||||
|
@ -718,9 +718,9 @@ fn get_ip() -> Option<String> {
|
|||
};
|
||||
|
||||
match socket.local_addr() {
|
||||
Ok(addr) => return Some(addr.ip().to_string()),
|
||||
Err(_) => return None,
|
||||
};
|
||||
Ok(addr) => Some(addr.ip().to_string()),
|
||||
Err(_) => None,
|
||||
}
|
||||
}
|
||||
|
||||
async fn ws_handler(
|
||||
|
|
|
@ -320,11 +320,11 @@ impl Tool {
|
|||
}
|
||||
|
||||
pub fn extract_zip(file: &Path, target: &Path) -> anyhow::Result<()> {
|
||||
let zip_file = std::fs::File::open(&file)?;
|
||||
let zip_file = std::fs::File::open(file)?;
|
||||
let mut zip = zip::ZipArchive::new(zip_file)?;
|
||||
|
||||
if !target.exists() {
|
||||
let _ = std::fs::create_dir_all(target)?;
|
||||
std::fs::create_dir_all(target)?;
|
||||
}
|
||||
|
||||
for i in 0..zip.len() {
|
||||
|
@ -332,7 +332,7 @@ pub fn extract_zip(file: &Path, target: &Path) -> anyhow::Result<()> {
|
|||
if file.is_dir() {
|
||||
// dir
|
||||
let target = target.join(Path::new(&file.name().replace('\\', "")));
|
||||
let _ = std::fs::create_dir_all(target)?;
|
||||
std::fs::create_dir_all(target)?;
|
||||
} else {
|
||||
// file
|
||||
let file_path = target.join(Path::new(file.name()));
|
||||
|
|
Loading…
Reference in New Issue