Skip to content

Commit 000e140

Browse files
committed
chore: clean up clippy errors
- Fixed clippy warnings: nested ifs, explicit deref, and len() > 0 checks.
1 parent d0cf6ed commit 000e140

4 files changed

Lines changed: 26 additions & 27 deletions

File tree

crates/sqlx-sqlite-conn-mgr/src/database.rs

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -288,12 +288,12 @@ impl SqliteDatabase {
288288

289289
// Checkpoint WAL before closing the write connection to flush changes and truncate WAL file
290290
// Only attempt if WAL was initialized (write connection was used)
291-
if self.wal_initialized.load(Ordering::SeqCst) {
292-
if let Ok(mut conn) = self.write_conn.acquire().await {
293-
let _ = sqlx::query("PRAGMA wal_checkpoint(TRUNCATE)")
294-
.execute(&mut *conn)
295-
.await;
296-
}
291+
if self.wal_initialized.load(Ordering::SeqCst)
292+
&& let Ok(mut conn) = self.write_conn.acquire().await
293+
{
294+
let _ = sqlx::query("PRAGMA wal_checkpoint(TRUNCATE)")
295+
.execute(&mut *conn)
296+
.await;
297297
}
298298

299299
self.write_conn.close().await;
@@ -334,17 +334,17 @@ impl SqliteDatabase {
334334
// Remove WAL and SHM files - ignore "not found" but propagate other errors
335335
// (these files may not exist if WAL was never initialized)
336336
let wal_path = path.with_extension("db-wal");
337-
if let Err(e) = std::fs::remove_file(&wal_path) {
338-
if e.kind() != std::io::ErrorKind::NotFound {
339-
return Err(Error::Io(e));
340-
}
337+
if let Err(e) = std::fs::remove_file(&wal_path)
338+
&& e.kind() != std::io::ErrorKind::NotFound
339+
{
340+
return Err(Error::Io(e));
341341
}
342342

343343
let shm_path = path.with_extension("db-shm");
344-
if let Err(e) = std::fs::remove_file(&shm_path) {
345-
if e.kind() != std::io::ErrorKind::NotFound {
346-
return Err(Error::Io(e));
347-
}
344+
if let Err(e) = std::fs::remove_file(&shm_path)
345+
&& e.kind() != std::io::ErrorKind::NotFound
346+
{
347+
return Err(Error::Io(e));
348348
}
349349

350350
Ok(())
@@ -692,7 +692,7 @@ mod tests {
692692
.await
693693
.unwrap();
694694

695-
assert!(rows.len() > 0);
695+
assert!(!rows.is_empty());
696696
}));
697697
}
698698

crates/sqlx-sqlite-conn-mgr/src/registry.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -50,22 +50,22 @@ where
5050
{
5151
let registry = registry().read().await;
5252

53-
if let Some(weak) = registry.get(&canonical_path) {
54-
if let Some(db) = weak.upgrade() {
55-
return Ok(db);
56-
}
57-
// Weak reference exists but dead - will be cleaned up in write phase
53+
if let Some(weak) = registry.get(&canonical_path)
54+
&& let Some(db) = weak.upgrade()
55+
{
56+
return Ok(db);
5857
}
58+
// Weak reference exists but dead - will be cleaned up in write phase
5959
}
6060

6161
// Phase 2: Database not found, acquire write lock
6262
let mut registry = registry().write().await;
6363

6464
// Double-check: another thread might have created it while we waited for write lock
65-
if let Some(weak) = registry.get(&canonical_path) {
66-
if let Some(db) = weak.upgrade() {
67-
return Ok(db);
68-
}
65+
if let Some(weak) = registry.get(&canonical_path)
66+
&& let Some(db) = weak.upgrade()
67+
{
68+
return Ok(db);
6969
}
7070

7171
// Clean up dead weak references while we have the write lock

crates/sqlx-sqlite-conn-mgr/src/write_guard.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,13 @@ impl Deref for WriteGuard {
4747
type Target = SqliteConnection;
4848

4949
fn deref(&self) -> &Self::Target {
50-
&*self.conn
50+
&self.conn
5151
}
5252
}
5353

5454
impl DerefMut for WriteGuard {
5555
fn deref_mut(&mut self) -> &mut Self::Target {
56-
&mut *self.conn
56+
&mut self.conn
5757
}
5858
}
5959

src/commands.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
11
//! SQLite plugin commands
2-

0 commit comments

Comments
 (0)