Files
2026-07-13 13:05:14 +08:00

137 lines
8.2 KiB
TOML

# There is also a scripts/clippy_wasm/clippy.toml which forbids some methods that are not available in wasm.
# -----------------------------------------------------------------------------
# Section identical to the main scripts/clippy_wasm/clippy.toml:
msrv = "1.92"
allow-unwrap-in-tests = true
# https://doc.rust-lang.org/nightly/clippy/lint_configuration.html#avoid-breaking-exported-api
# We want suggestions, even if it changes public API.
avoid-breaking-exported-api = false
excessive-nesting-threshold = 16 # TODO(emilk): lower this
max-fn-params-bools = 1
# https://rust-lang.github.io/rust-clippy/master/index.html#/large_include_file
max-include-file-size = 1000000
# https://rust-lang.github.io/rust-clippy/master/index.html#/large_stack_frames
stack-size-threshold = 512000
too-many-lines-threshold = 600 # TODO(emilk): decrease this
# -----------------------------------------------------------------------------
# https://rust-lang.github.io/rust-clippy/master/index.html#disallowed_macros
disallowed-macros = [
'std::dbg',
{ path = "egui::hex_color", reason = "Do not hard-code colors - declare them design_tokens.rs instead, and define in light/dark_theme.json" },
{ path = "std::debug_assert", reason = "Use `re_log::debug_assert` instead" },
{ path = "std::debug_assert_eq", reason = "Use `re_log::debug_assert_eq` instead" },
# TODO(emilk): consider forbidding these to encourage the use of proper log stream, and then explicitly allow legitimate uses
# 'std::eprint',
# 'std::eprintln',
# 'std::print',
# 'std::println',
# 'std::unimplemented', # generated by ArrowDeserialize derive-macro :(
]
# https://rust-lang.github.io/rust-clippy/master/index.html#disallowed_methods
disallowed-methods = [
{ path = "arrow_array::record_batch::RecordBatch::try_new", reason = "Use `arrow_array::record_batch::RecordBatch::try_new_with_options` instead. There is a corner case for empty batches that require the length specified." },
{ path = "arrow::compute::concat", reason = "Use `re_arrow_util::arrow_util::concat_arrays` instead, which has better memory management" },
{ path = "arrow::compute::filter", reason = "Use `re_arrow_util::arrow_util::filter_array` instead" },
{ path = "arrow::compute::take", reason = "Use `re_arrow_util::arrow_util::take_array` instead" },
{ path = "arrow::datatypes::Schema::new", reason = "Use `arrow::datatypes::Schema::new_with_metadata` instead. There is usually some metadata you want to preserve." },
{ path = "crossbeam::channel::Sender::send", reason = "Use `re_quota_channel::send_crossbeam` instead, which warns if the channel is full." },
{ path = "crossbeam::channel::unbounded", reason = "Consider using bounded channels (like re_quota_channel) to apply backpressure. Only use unbounded channels when the sender and receiver are on the same thread." },
{ path = "ecolor::Color32::from_additive_luminance", reason = "Do not hard-code colors - declare them design_tokens.rs instead, and define in light/dark_theme.json" },
{ path = "ecolor::Color32::from_black_alpha", reason = "Do not hard-code colors - declare them design_tokens.rs instead, and define in light/dark_theme.json" },
{ path = "ecolor::Color32::from_gray", reason = "Do not hard-code colors - declare them design_tokens.rs instead, and define in light/dark_theme.json" },
{ path = "ecolor::Color32::from_rgb", reason = "Do not hard-code colors - declare them design_tokens.rs instead, and define in light/dark_theme.json" },
{ path = "ecolor::Color32::from_rgba_premultiplied", reason = "Do not hard-code colors - declare them design_tokens.rs instead, and define in light/dark_theme.json" },
{ path = "ecolor::Color32::from_rgba_unmultiplied", reason = "Do not hard-code colors - declare them design_tokens.rs instead, and define in light/dark_theme.json" },
{ path = "ecolor::Color32::from_white_alpha", reason = "Do not hard-code colors - declare them design_tokens.rs instead, and define in light/dark_theme.json" },
{ path = "ecolor::Rgba::from_black_alpha", reason = "Do not hard-code colors - declare them design_tokens.rs instead, and define in light/dark_theme.json" },
{ path = "ecolor::Rgba::from_gray", reason = "Do not hard-code colors - declare them design_tokens.rs instead, and define in light/dark_theme.json" },
{ path = "ecolor::Rgba::from_luminance_alpha", reason = "Do not hard-code colors - declare them design_tokens.rs instead, and define in light/dark_theme.json" },
{ path = "ecolor::Rgba::from_rgb", reason = "Do not hard-code colors - declare them design_tokens.rs instead, and define in light/dark_theme.json" },
{ path = "ecolor::Rgba::from_rgba_premultiplied", reason = "Do not hard-code colors - declare them design_tokens.rs instead, and define in light/dark_theme.json" },
{ path = "ecolor::Rgba::from_rgba_unmultiplied", reason = "Do not hard-code colors - declare them design_tokens.rs instead, and define in light/dark_theme.json" },
{ path = "ecolor::Rgba::from_white_alpha", reason = "Do not hard-code colors - declare them design_tokens.rs instead, and define in light/dark_theme.json" },
{ path = "egui_extras::TableBody::row", reason = "`row` doesn't scale. Use `rows` instead." },
{ path = "egui::Ui::checkbox", reason = "Use `re_checkbox` from `re_ui::UiEx" },
{ path = "egui::Ui::radio_value", reason = "Use `re_radio_value` from `re_ui::UiEx" },
{ path = "egui::Ui::spinner", reason = "Use `ui.loading_indicator` from `re_ui::UiEx" },
{ path = "glam::Vec2::normalize", reason = "normalize() can create NaNs. Use try_normalize or normalize_or_zero" },
{ path = "glam::Vec3::normalize", reason = "normalize() can create NaNs. Use try_normalize or normalize_or_zero" },
{ path = "macaw::BoundingBox::from_points", reason = "from_points propagates NaN/inf. Use re_renderer::util::bounding_box_from_points instead" },
{ path = "opentelemetry::metrics::HistogramBuilder::with_boundaries", reason = "We have automatic bucketing - with_boundaries has no effect" },
{ path = "sha1::Digest::new", reason = "SHA1 is cryptographically broken" },
{ path = "std::env::temp_dir", reason = "Use the tempdir crate instead" },
{ path = "std::panic::catch_unwind", reason = "We compile with `panic = 'abort'`" },
{ path = "std::sync::mpsc::channel", reason = "Use bounded channels (like re_quota_channel) to apply backpressure." },
{ path = "std::thread::spawn", reason = "Use `std::thread::Builder` and name the thread" },
{ path = "std::time::Duration::from_secs_f32", reason = "Use try_from_secs_f32 instead to avoid panics" },
{ path = "std::time::Duration::from_secs_f64", reason = "Use try_from_secs_f64 instead to avoid panics" },
{ path = "tokio::sync::mpsc::unbounded_channel", reason = "Use bounded channels to apply backpressure." },
# There are many things that aren't allowed on wasm,
# but we cannot disable them all here (because of e.g. https://github.com/rust-lang/rust-clippy/issues/10406)
# so we do that in `clippy_wasm.toml` instead.
]
# https://rust-lang.github.io/rust-clippy/master/index.html#disallowed_names
disallowed-names = []
# https://rust-lang.github.io/rust-clippy/master/index.html#disallowed_types
disallowed-types = [
{ path = "egui::Checkbox", reason = "Use `re_checkbox` from `re_ui::UiEx" },
{ path = "egui::Spinner", reason = "Use re_ui::loading_indicator" },
{ path = "once_cell::sync::OnceCell", reason = "Use `std::sync::OnceLock` instead" },
{ path = "std::sync::Condvar", reason = "Use parking_lot instead" },
{ path = "std::sync::Mutex", reason = "Use parking_lot instead" },
{ path = "std::sync::RwLock", reason = "Use parking_lot instead" },
# "std::sync::Once", # enabled for now as the `log_once` macro uses it internally
]
# Allow-list of words for markdown in docstrings https://rust-lang.github.io/rust-clippy/master/index.html#doc_markdown
doc-valid-idents = [
# You must also update the same list in `scripts/clippy_wasm/clippy.toml`!
"AOMedia",
"DataFusion",
"GiB",
"GitHub",
"GLB",
"GLTF",
"GoP", # Group of Pictures - common video term
"GoPs", # Group of Pictures - common video term
"iOS",
"IPv4",
"IPv6",
"macOS",
"MessagePack",
"MiB",
"MiMalloc",
"NaN",
"OBJ",
"OpenGL",
"OpenID",
"PyPI",
"sRGB",
"sRGBA",
"WebCodec",
"WebGL",
"WebGPU",
"WebSocket",
"WebSockets",
]