Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix clippy warnings / errors in filewatching code #5891

Merged
merged 1 commit into from
Sep 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions crates/turborepo-filewatch/src/cookie_jar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
#[error("filewatching encountered errors: {0}")]
NotifyError(#[from] NotifyError),
#[error("filewatching has closed, cannot watch cookies")]
Closed,

Check warning on line 27 in crates/turborepo-filewatch/src/cookie_jar.rs

View workflow job for this annotation

GitHub Actions / Build Turborepo (macos, macos-latest)

variant `Closed` is never constructed

Check warning on line 27 in crates/turborepo-filewatch/src/cookie_jar.rs

View workflow job for this annotation

GitHub Actions / Build Turborepo (ubuntu, ubuntu-latest)

variant `Closed` is never constructed

Check warning on line 27 in crates/turborepo-filewatch/src/cookie_jar.rs

View workflow job for this annotation

GitHub Actions / Build Turborepo (windows, windows-latest)

variant `Closed` is never constructed

Check warning on line 27 in crates/turborepo-filewatch/src/cookie_jar.rs

View workflow job for this annotation

GitHub Actions / Turborepo E2E Tests (windows, windows-latest)

variant `Closed` is never constructed

Check warning on line 27 in crates/turborepo-filewatch/src/cookie_jar.rs

View workflow job for this annotation

GitHub Actions / Turborepo E2E Tests (ubuntu, ubuntu-latest)

variant `Closed` is never constructed

Check warning on line 27 in crates/turborepo-filewatch/src/cookie_jar.rs

View workflow job for this annotation

GitHub Actions / Turborepo E2E Tests (macos, macos-latest)

variant `Closed` is never constructed

Check warning on line 27 in crates/turborepo-filewatch/src/cookie_jar.rs

View workflow job for this annotation

GitHub Actions / Turborepo Examples (ubuntu, ubuntu-latest)

variant `Closed` is never constructed

Check warning on line 27 in crates/turborepo-filewatch/src/cookie_jar.rs

View workflow job for this annotation

GitHub Actions / Go Integration Tests (ubuntu, ubuntu-latest)

variant `Closed` is never constructed

Check warning on line 27 in crates/turborepo-filewatch/src/cookie_jar.rs

View workflow job for this annotation

GitHub Actions / Turborepo Examples (macos, macos-latest)

variant `Closed` is never constructed
}

#[derive(Debug, Error)]
Expand All @@ -41,7 +41,7 @@

type CookieResponse = Result<(), WatchError>;

pub struct CookieJar {

Check warning on line 44 in crates/turborepo-filewatch/src/cookie_jar.rs

View workflow job for this annotation

GitHub Actions / Build Turborepo (macos, macos-latest)

struct `CookieJar` is never constructed

Check warning on line 44 in crates/turborepo-filewatch/src/cookie_jar.rs

View workflow job for this annotation

GitHub Actions / Build Turborepo (ubuntu, ubuntu-latest)

struct `CookieJar` is never constructed

Check warning on line 44 in crates/turborepo-filewatch/src/cookie_jar.rs

View workflow job for this annotation

GitHub Actions / Build Turborepo (windows, windows-latest)

struct `CookieJar` is never constructed

Check warning on line 44 in crates/turborepo-filewatch/src/cookie_jar.rs

View workflow job for this annotation

GitHub Actions / Turborepo E2E Tests (windows, windows-latest)

struct `CookieJar` is never constructed

Check warning on line 44 in crates/turborepo-filewatch/src/cookie_jar.rs

View workflow job for this annotation

GitHub Actions / Turborepo E2E Tests (ubuntu, ubuntu-latest)

struct `CookieJar` is never constructed

Check warning on line 44 in crates/turborepo-filewatch/src/cookie_jar.rs

View workflow job for this annotation

GitHub Actions / Turborepo E2E Tests (macos, macos-latest)

struct `CookieJar` is never constructed

Check warning on line 44 in crates/turborepo-filewatch/src/cookie_jar.rs

View workflow job for this annotation

GitHub Actions / Turborepo Examples (ubuntu, ubuntu-latest)

struct `CookieJar` is never constructed

Check warning on line 44 in crates/turborepo-filewatch/src/cookie_jar.rs

View workflow job for this annotation

GitHub Actions / Go Integration Tests (ubuntu, ubuntu-latest)

struct `CookieJar` is never constructed

Check warning on line 44 in crates/turborepo-filewatch/src/cookie_jar.rs

View workflow job for this annotation

GitHub Actions / Turborepo Examples (macos, macos-latest)

struct `CookieJar` is never constructed
root: AbsoluteSystemPathBuf,
serial: AtomicUsize,
timeout: Duration,
Expand All @@ -55,12 +55,12 @@

#[derive(Default)]
struct Watches {
closed: bool,

Check warning on line 58 in crates/turborepo-filewatch/src/cookie_jar.rs

View workflow job for this annotation

GitHub Actions / Build Turborepo (macos, macos-latest)

fields `closed` and `cookies` are never read

Check warning on line 58 in crates/turborepo-filewatch/src/cookie_jar.rs

View workflow job for this annotation

GitHub Actions / Build Turborepo (ubuntu, ubuntu-latest)

fields `closed` and `cookies` are never read

Check warning on line 58 in crates/turborepo-filewatch/src/cookie_jar.rs

View workflow job for this annotation

GitHub Actions / Build Turborepo (windows, windows-latest)

fields `closed` and `cookies` are never read

Check warning on line 58 in crates/turborepo-filewatch/src/cookie_jar.rs

View workflow job for this annotation

GitHub Actions / Turborepo E2E Tests (windows, windows-latest)

fields `closed` and `cookies` are never read

Check warning on line 58 in crates/turborepo-filewatch/src/cookie_jar.rs

View workflow job for this annotation

GitHub Actions / Turborepo E2E Tests (ubuntu, ubuntu-latest)

fields `closed` and `cookies` are never read

Check warning on line 58 in crates/turborepo-filewatch/src/cookie_jar.rs

View workflow job for this annotation

GitHub Actions / Turborepo E2E Tests (macos, macos-latest)

fields `closed` and `cookies` are never read

Check warning on line 58 in crates/turborepo-filewatch/src/cookie_jar.rs

View workflow job for this annotation

GitHub Actions / Turborepo Examples (ubuntu, ubuntu-latest)

fields `closed` and `cookies` are never read

Check warning on line 58 in crates/turborepo-filewatch/src/cookie_jar.rs

View workflow job for this annotation

GitHub Actions / Go Integration Tests (ubuntu, ubuntu-latest)

fields `closed` and `cookies` are never read

Check warning on line 58 in crates/turborepo-filewatch/src/cookie_jar.rs

View workflow job for this annotation

GitHub Actions / Turborepo Examples (macos, macos-latest)

fields `closed` and `cookies` are never read
cookies: HashMap<PathBuf, oneshot::Sender<CookieResponse>>,
}

impl CookieJar {
pub fn new(

Check warning on line 63 in crates/turborepo-filewatch/src/cookie_jar.rs

View workflow job for this annotation

GitHub Actions / Build Turborepo (macos, macos-latest)

associated items `new` and `wait_for_cookie` are never used

Check warning on line 63 in crates/turborepo-filewatch/src/cookie_jar.rs

View workflow job for this annotation

GitHub Actions / Build Turborepo (ubuntu, ubuntu-latest)

associated items `new` and `wait_for_cookie` are never used

Check warning on line 63 in crates/turborepo-filewatch/src/cookie_jar.rs

View workflow job for this annotation

GitHub Actions / Build Turborepo (windows, windows-latest)

associated items `new` and `wait_for_cookie` are never used

Check warning on line 63 in crates/turborepo-filewatch/src/cookie_jar.rs

View workflow job for this annotation

GitHub Actions / Turborepo E2E Tests (windows, windows-latest)

associated items `new` and `wait_for_cookie` are never used

Check warning on line 63 in crates/turborepo-filewatch/src/cookie_jar.rs

View workflow job for this annotation

GitHub Actions / Turborepo E2E Tests (ubuntu, ubuntu-latest)

associated items `new` and `wait_for_cookie` are never used

Check warning on line 63 in crates/turborepo-filewatch/src/cookie_jar.rs

View workflow job for this annotation

GitHub Actions / Turborepo E2E Tests (macos, macos-latest)

associated items `new` and `wait_for_cookie` are never used

Check warning on line 63 in crates/turborepo-filewatch/src/cookie_jar.rs

View workflow job for this annotation

GitHub Actions / Turborepo Examples (ubuntu, ubuntu-latest)

associated items `new` and `wait_for_cookie` are never used

Check warning on line 63 in crates/turborepo-filewatch/src/cookie_jar.rs

View workflow job for this annotation

GitHub Actions / Go Integration Tests (ubuntu, ubuntu-latest)

associated items `new` and `wait_for_cookie` are never used

Check warning on line 63 in crates/turborepo-filewatch/src/cookie_jar.rs

View workflow job for this annotation

GitHub Actions / Turborepo Examples (macos, macos-latest)

associated items `new` and `wait_for_cookie` are never used
root: &AbsoluteSystemPath,
timeout: Duration,
file_events: broadcast::Receiver<Result<Event, NotifyError>>,
Expand Down Expand Up @@ -109,7 +109,7 @@
}
}

async fn watch_cookies(

Check warning on line 112 in crates/turborepo-filewatch/src/cookie_jar.rs

View workflow job for this annotation

GitHub Actions / Build Turborepo (macos, macos-latest)

function `watch_cookies` is never used

Check warning on line 112 in crates/turborepo-filewatch/src/cookie_jar.rs

View workflow job for this annotation

GitHub Actions / Build Turborepo (ubuntu, ubuntu-latest)

function `watch_cookies` is never used

Check warning on line 112 in crates/turborepo-filewatch/src/cookie_jar.rs

View workflow job for this annotation

GitHub Actions / Build Turborepo (windows, windows-latest)

function `watch_cookies` is never used

Check warning on line 112 in crates/turborepo-filewatch/src/cookie_jar.rs

View workflow job for this annotation

GitHub Actions / Turborepo E2E Tests (windows, windows-latest)

function `watch_cookies` is never used

Check warning on line 112 in crates/turborepo-filewatch/src/cookie_jar.rs

View workflow job for this annotation

GitHub Actions / Turborepo E2E Tests (ubuntu, ubuntu-latest)

function `watch_cookies` is never used

Check warning on line 112 in crates/turborepo-filewatch/src/cookie_jar.rs

View workflow job for this annotation

GitHub Actions / Turborepo E2E Tests (macos, macos-latest)

function `watch_cookies` is never used

Check warning on line 112 in crates/turborepo-filewatch/src/cookie_jar.rs

View workflow job for this annotation

GitHub Actions / Turborepo Examples (ubuntu, ubuntu-latest)

function `watch_cookies` is never used

Check warning on line 112 in crates/turborepo-filewatch/src/cookie_jar.rs

View workflow job for this annotation

GitHub Actions / Go Integration Tests (ubuntu, ubuntu-latest)

function `watch_cookies` is never used

Check warning on line 112 in crates/turborepo-filewatch/src/cookie_jar.rs

View workflow job for this annotation

GitHub Actions / Turborepo Examples (macos, macos-latest)

function `watch_cookies` is never used
root: AbsoluteSystemPathBuf,
watches: Arc<Mutex<Watches>>,
mut file_events: broadcast::Receiver<Result<Event, NotifyError>>,
Expand All @@ -130,7 +130,7 @@
.expect("Non-absolute path from filewatching");
if root.relation_to_path(abs_path) == PathRelation::Parent {
if let Some(responder) = watches.cookies.remove(&path) {
if let Err(_) = responder.send(Ok(())) {
if responder.send(Ok(())).is_err() {
// Note that cookie waiters will time out if they don't get a
// response, so we don't necessarily
// need to panic here, although we could decide to do that in the
Expand All @@ -151,7 +151,7 @@
let resp = if is_closing { WatchError::Closed } else { e };
let mut watches = watches.lock().expect("mutex poisoned");
for (_, sender) in watches.cookies.drain() {
if let Err(_) = sender.send(Err(resp.clone())) {
if sender.send(Err(resp.clone())).is_err() {
// Note that cookie waiters will time out if they don't get a response, so
// we don't necessarily need to panic here, although
// we could decide to do that in the future.
Expand All @@ -171,7 +171,7 @@

// result flattening is an unstable feature, so add a manual helper to do so.
// This version is for unwrapping events coming from filewatching
fn flatten_event(

Check warning on line 174 in crates/turborepo-filewatch/src/cookie_jar.rs

View workflow job for this annotation

GitHub Actions / Build Turborepo (macos, macos-latest)

function `flatten_event` is never used

Check warning on line 174 in crates/turborepo-filewatch/src/cookie_jar.rs

View workflow job for this annotation

GitHub Actions / Build Turborepo (ubuntu, ubuntu-latest)

function `flatten_event` is never used

Check warning on line 174 in crates/turborepo-filewatch/src/cookie_jar.rs

View workflow job for this annotation

GitHub Actions / Build Turborepo (windows, windows-latest)

function `flatten_event` is never used

Check warning on line 174 in crates/turborepo-filewatch/src/cookie_jar.rs

View workflow job for this annotation

GitHub Actions / Turborepo E2E Tests (windows, windows-latest)

function `flatten_event` is never used

Check warning on line 174 in crates/turborepo-filewatch/src/cookie_jar.rs

View workflow job for this annotation

GitHub Actions / Turborepo E2E Tests (ubuntu, ubuntu-latest)

function `flatten_event` is never used

Check warning on line 174 in crates/turborepo-filewatch/src/cookie_jar.rs

View workflow job for this annotation

GitHub Actions / Turborepo E2E Tests (macos, macos-latest)

function `flatten_event` is never used

Check warning on line 174 in crates/turborepo-filewatch/src/cookie_jar.rs

View workflow job for this annotation

GitHub Actions / Turborepo Examples (ubuntu, ubuntu-latest)

function `flatten_event` is never used

Check warning on line 174 in crates/turborepo-filewatch/src/cookie_jar.rs

View workflow job for this annotation

GitHub Actions / Go Integration Tests (ubuntu, ubuntu-latest)

function `flatten_event` is never used

Check warning on line 174 in crates/turborepo-filewatch/src/cookie_jar.rs

View workflow job for this annotation

GitHub Actions / Turborepo Examples (macos, macos-latest)

function `flatten_event` is never used
event: Result<Result<Event, NotifyError>, broadcast::error::RecvError>,
) -> Result<Event, WatchError> {
Ok(event??)
Expand Down
3 changes: 3 additions & 0 deletions crates/turborepo-filewatch/src/fsevent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
//! [ref]: https://developer.apple.com/library/mac/documentation/Darwin/Reference/FSEvents_Ref/

#![allow(non_upper_case_globals, dead_code)]
// bitflags! with a 0 value defined triggers this clippy error,
// but we want to be able to define a value for fs::kFSEventStreamEventFlagNone
#![allow(clippy::bad_bit_mask)]

use std::{
collections::HashMap,
Expand Down
4 changes: 2 additions & 2 deletions crates/turborepo-filewatch/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ impl FileSystemWatcher {
let watcher = run_watcher(&watch_root, send_file_events).unwrap();
let (exit_ch, exit_signal) = tokio::sync::oneshot::channel();
// Ensure we are ready to receive new events, not events for existing state
futures::executor::block_on(wait_for_cookie(&root, &mut recv_file_events))?;
futures::executor::block_on(wait_for_cookie(root, &mut recv_file_events))?;
tokio::task::spawn(watch_events(
watcher,
watch_root,
Expand Down Expand Up @@ -233,7 +233,7 @@ fn watch_parents(root: &AbsoluteSystemPath, watcher: &mut Backend) -> Result<(),

#[cfg(not(feature = "manual_recursive_watch"))]
fn watch_recursively(root: &AbsoluteSystemPath, watcher: &mut Backend) -> Result<(), WatchError> {
watcher.watch(&root.as_std_path(), RecursiveMode::Recursive)?;
watcher.watch(root.as_std_path(), RecursiveMode::Recursive)?;
Ok(())
}

Expand Down
Loading