Workspace with strict lint gates

A three-member workspace (core, app, xtask) with omatrack's lint policy:
clippy::all and clippy::pedantic are errors, nursery warns, and every
deliberate exception is listed with its reason. `cargo xtask lint` runs
rustfmt --check and clippy with -D warnings; it reports, never fixes.
This commit is contained in:
Tobi Lutke
2026-09-24 15:56:19 -05:00
commit 406dda52d2
7 changed files with 9227 additions and 0 deletions
+2
View File
@@ -0,0 +1,2 @@
[alias]
xtask = "run --package xtask --"
+1
View File
@@ -0,0 +1 @@
/target
Generated
+9026
View File
File diff suppressed because it is too large Load Diff
+86
View File
@@ -0,0 +1,86 @@
[workspace]
resolver = "3"
members = ["crates/disktree-app", "crates/disktree-core", "xtask"]
[workspace.package]
version = "0.1.0"
edition = "2024"
rust-version = "1.97"
license = "MIT"
repository = "https://github.com/tobi/disktree"
[workspace.dependencies]
disktree-core = { path = "crates/disktree-core" }
anyhow = "1"
rayon = "1"
rustc-hash = "2"
# Lint gates follow omatrack's policy: the checks that catch real defects are
# errors, and every deliberate omission is written down instead of silently
# tolerated. Run them through `cargo xtask lint`, which adds `-D warnings` on
# top so nothing is merely "warned about".
[workspace.lints.rust]
unsafe_code = "deny"
unused_lifetimes = "warn"
trivial_casts = "warn"
trivial_numeric_casts = "warn"
missing_debug_implementations = "warn"
rust_2018_idioms = { level = "deny", priority = -1 }
[workspace.lints.clippy]
all = { level = "deny", priority = -1 }
pedantic = { level = "deny", priority = -1 }
nursery = { level = "warn", priority = -1 }
# Deliberate omissions, mirroring the rationale comments in omatrack's
# .clang-tidy:
# module_name_repetitions - `treemap::TreemapLayout` reads better than
# inventing a second vocabulary for one concept.
# missing_errors_doc - this is an application; the error types are
# missing_panics_doc reachable from the caller in one screen.
# must_use_candidate - noise on small private helpers.
# struct_excessive_bools - scan options are bool flags by nature.
# cast_precision_loss - byte counts become f64 geometry, by design.
# cast_possible_truncation The layout pass is the only place that is
# cast_sign_loss true, and the ranges are bounded by the
# viewport.
# similar_names - (x, y), (w, h), (cols, rows).
# too_many_lines - render functions are linear on purpose.
# option_if_let_else - `if let` keeps ownership visible.
# multiple_crate_versions - the dependency graph is not ours to fix.
# cast_lossless - explicit `as` in layout math is clearer than
# From chains.
#
# `unreachable_pub` is left off the workspace set: the only library here is a
# workspace-internal one, so every `pub` is unreachable from outside by
# construction and the check would only produce noise.
module_name_repetitions = "allow"
missing_errors_doc = "allow"
missing_panics_doc = "allow"
must_use_candidate = "allow"
struct_excessive_bools = "allow"
cast_precision_loss = "allow"
cast_possible_truncation = "allow"
cast_sign_loss = "allow"
cast_lossless = "allow"
similar_names = "allow"
too_many_lines = "allow"
option_if_let_else = "allow"
multiple_crate_versions = "allow"
[profile.dev]
debug = "limited"
opt-level = 1
[profile.dev.package."*"]
opt-level = 2
[profile.release]
lto = "thin"
codegen-units = 1
overflow-checks = true
# gpui-pre-macros leaves a helper ungated in release builds while its module is
# gated on debug_assertions; enable it for the host proc-macro only.
[profile.release.package.gpui-pre-macros]
debug-assertions = true
+8
View File
@@ -0,0 +1,8 @@
# House style follows omatrack's .clang-format: 4-space indent, 80 columns.
# Only stable rustfmt options are set, because the lint gate must run on a
# stable toolchain: `wrap_comments` and friends are nightly-only and would
# silently not apply.
edition = "2024"
max_width = 80
use_field_init_shorthand = true
use_try_shorthand = true
+15
View File
@@ -0,0 +1,15 @@
[package]
name = "xtask"
version.workspace = true
edition.workspace = true
rust-version.workspace = true
license.workspace = true
publish = false
description = "Check entry points for disktree: one command per gate"
[lints]
workspace = true
[[bin]]
name = "xtask"
path = "src/main.rs"
+89
View File
@@ -0,0 +1,89 @@
//! Check entry points for disktree.
//!
//! Each gate is reachable on its own (`cargo xtask fmt`) and through the
//! aggregate CI runs (`cargo xtask lint`), mirroring how omatrack exposes every
//! linter both as a build target and as a labelled test. `lint` never fixes
//! anything: it reports the diff and fails, so a red local run is the same
//! signal CI gives.
use std::process::{Command, ExitCode, Stdio};
const USAGE: &str = "\
usage: cargo xtask <task>
tasks:
lint fmt --check, then clippy over the workspace with -D warnings
fmt rustfmt --check over the workspace
fmt-fix rustfmt in place
clippy clippy --workspace --all-targets -- -D warnings
test cargo test --workspace
ci lint, then test
";
fn main() -> ExitCode {
let args: Vec<String> = std::env::args().skip(1).collect();
let task = args.first().map_or("lint", String::as_str);
let outcome = match task {
"lint" => fmt(false).and_then(|()| clippy()),
"fmt" => fmt(false),
"fmt-fix" => fmt(true),
"clippy" => clippy(),
"test" => test(),
"ci" => fmt(false).and_then(|()| clippy()).and_then(|()| test()),
"help" | "-h" | "--help" => {
println!("{USAGE}");
return ExitCode::SUCCESS;
}
other => {
eprintln!("unknown task: {other}\n\n{USAGE}");
return ExitCode::FAILURE;
}
};
match outcome {
Ok(()) => ExitCode::SUCCESS,
Err(message) => {
eprintln!("xtask {task}: {message}");
ExitCode::FAILURE
}
}
}
fn fmt(fix: bool) -> Result<(), String> {
let mut args = vec!["fmt", "--all"];
args.push(if fix { "" } else { "--check" });
let args: Vec<&str> = args.into_iter().filter(|a| !a.is_empty()).collect();
run(&args)
}
fn clippy() -> Result<(), String> {
run(&[
"clippy",
"--workspace",
"--all-targets",
"--all-features",
"--",
"-D",
"warnings",
])
}
fn test() -> Result<(), String> {
run(&["test", "--workspace"])
}
fn run(args: &[&str]) -> Result<(), String> {
let cargo = option_env!("CARGO").unwrap_or("cargo");
let display = format!("{cargo} {}", args.join(" "));
let status = Command::new(cargo)
.args(args)
.stdin(Stdio::null())
.status()
.map_err(|err| format!("could not start `{display}`: {err}"))?;
if status.success() {
Ok(())
} else {
Err(format!("`{display}` failed"))
}
}