Add clippy CI, fix or ignore warnings where appropriate

This commit is contained in:
PThorpe92 2024-12-27 18:17:06 -05:00
parent f87dc7cacc
commit f6cd707544
No known key found for this signature in database
GPG key ID: 66DB3FBACBDD05CC
27 changed files with 596 additions and 585 deletions

View file

@ -160,7 +160,7 @@ impl From<&Opts> for Settings {
null_value: String::new(),
output_mode: opts.output_mode,
echo: false,
is_stdout: opts.output == "",
is_stdout: opts.output.is_empty(),
output_filename: opts.output.clone(),
db_file: opts
.database
@ -192,7 +192,6 @@ impl std::fmt::Display for Settings {
}
impl Limbo {
#[allow(clippy::arc_with_non_send_sync)]
pub fn new() -> anyhow::Result<Self> {
let opts = Opts::parse();
let db_file = opts
@ -229,13 +228,13 @@ impl Limbo {
app.writeln("Enter \".help\" for usage hints.")?;
app.display_in_memory()?;
}
return Ok(app);
Ok(app)
}
fn handle_first_input(&mut self, cmd: &str) {
if cmd.trim().starts_with('.') {
self.handle_dot_command(&cmd);
} else if let Err(e) = self.query(&cmd) {
self.handle_dot_command(cmd);
} else if let Err(e) = self.query(cmd) {
eprintln!("{}", e);
}
std::process::exit(0);
@ -293,7 +292,7 @@ impl Limbo {
let db = Database::open_file(self.io.clone(), path)?;
self.conn = db.connect();
self.opts.db_file = ":memory:".to_string();
return Ok(());
Ok(())
}
path => {
let io: Arc<dyn limbo_core::IO> = Arc::new(limbo_core::PlatformIO::new()?);
@ -301,7 +300,7 @@ impl Limbo {
let db = Database::open_file(self.io.clone(), path)?;
self.conn = db.connect();
self.opts.db_file = path.to_string();
return Ok(());
Ok(())
}
}
}
@ -317,11 +316,9 @@ impl Limbo {
self.opts.is_stdout = false;
self.opts.output_mode = OutputMode::Raw;
self.opts.output_filename = path.to_string();
return Ok(());
}
Err(e) => {
return Err(e.to_string());
Ok(())
}
Err(e) => Err(e.to_string()),
}
}
@ -333,7 +330,7 @@ impl Limbo {
fn set_mode(&mut self, mode: OutputMode) -> Result<(), String> {
if mode == OutputMode::Pretty && !self.opts.is_stdout {
return Err("pretty output can only be written to a tty".to_string());
Err("pretty output can only be written to a tty".to_string())
} else {
self.opts.output_mode = mode;
Ok(())
@ -682,17 +679,15 @@ impl Limbo {
}
}
if tables.len() > 0 {
if !tables.is_empty() {
let _ = self.writeln(tables.trim_end());
} else if let Some(pattern) = pattern {
let _ = self.write_fmt(format_args!(
"Error: Tables with pattern '{}' not found.",
pattern
));
} else {
if let Some(pattern) = pattern {
let _ = self.write_fmt(format_args!(
"Error: Tables with pattern '{}' not found.",
pattern
));
} else {
let _ = self.writeln("No tables found in the database.");
}
let _ = self.writeln("No tables found in the database.");
}
}
Ok(None) => {