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

Cleanup usage of unwrap() in re_dev_tools #6337

Merged
merged 4 commits into from
May 17, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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
7 changes: 3 additions & 4 deletions crates/re_dev_tools/src/build_examples/example.rs
Original file line number Diff line number Diff line change
Expand Up @@ -379,10 +379,9 @@ impl Frontmatter {

let frontmatter: Frontmatter =
toml::from_str(content[start..end].trim()).map_err(|err| {
anyhow::anyhow!(
"Failed to parse TOML metadata of {:?}: {err}",
path.parent().unwrap().file_name().unwrap()
)
#[allow(clippy::unwrap_used)]
let p = path.parent().unwrap().file_name().unwrap();
anyhow::anyhow!("Failed to parse TOML metadata of {p:?}: {err}")
})?;

Ok(Some((
Expand Down
1 change: 1 addition & 0 deletions crates/re_dev_tools/src/build_examples/snippets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ fn collect_snippets_recursively(
) -> anyhow::Result<Vec<Snippet>> {
let mut snippets = vec![];

#[allow(clippy::unwrap_used)] // we just use unwrap for string <-> path conversion here
for snippet in dir.read_dir()? {
let snippet = snippet?;
let meta = snippet.metadata()?;
Expand Down
2 changes: 2 additions & 0 deletions crates/re_dev_tools/src/build_search_index/ingest.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#![allow(clippy::unwrap_used)] // build tool, so okay here

/// Docs read from `/docs`
mod docs;

Expand Down
2 changes: 2 additions & 0 deletions crates/re_dev_tools/src/build_search_index/ingest/cpp.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#![allow(clippy::unwrap_used)] // build tool, so okay here

use super::Context;
use super::DocumentData;
use super::DocumentKind;
Expand Down
2 changes: 2 additions & 0 deletions crates/re_dev_tools/src/build_search_index/ingest/docs.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#![allow(clippy::unwrap_used)] // build tool, so okay here

use super::{Context, DocumentData, DocumentKind};
use crate::build_search_index::util::ProgressBarExt as _;
use std::path::Path;
Expand Down
2 changes: 2 additions & 0 deletions crates/re_dev_tools/src/build_search_index/ingest/rust.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#![allow(clippy::unwrap_used)] // build tool, so okay here

use super::{Context, DocumentData, DocumentKind};
use crate::build_search_index::util::ProgressBarExt as _;
use anyhow::Context as _;
Expand Down
4 changes: 3 additions & 1 deletion crates/re_dev_tools/src/build_search_index/meili.rs
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,9 @@ impl Task {
TaskStatus::Succeeded => Ok(ControlFlow::Break(())),

TaskStatus::Failed => {
anyhow::bail!("task failed: {}", self.error.as_ref().unwrap().message)
#[allow(clippy::unwrap_used)] // unwrap really shouldn't panic here
Wumpf marked this conversation as resolved.
Show resolved Hide resolved
let msg = self.error.as_ref().unwrap().message.as_str();
anyhow::bail!("task failed: {}", msg)
}
TaskStatus::Canceled => anyhow::bail!("task was canceled"),
}
Expand Down
4 changes: 2 additions & 2 deletions crates/re_dev_tools/src/build_search_index/repl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ impl Repl {

let mut lines = stdin().lines();
loop {
stdout().write_all(b"\n> ").unwrap();
stdout().flush().unwrap();
stdout().write_all(b"\n> ")?;
stdout().flush()?;

match lines.next().transpose()? {
Some(line) => match self.handle_line(&client, &line)? {
Expand Down
4 changes: 0 additions & 4 deletions crates/re_dev_tools/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
//! Crate that combines several development utilities.
//!
//! To get an overview over all tools run `pixi run dev-tools --help`.

// TODO(#3408): remove unwrap()
#![allow(clippy::unwrap_used)]

use argh::FromArgs;

mod build_examples;
Expand Down
Loading