بنقرة واحدة
rust-lint-config
Rust clippy, rustfmt, cargo-deny configuration, new lints, and lint failure triage.
التثبيت باستخدام Codex أو Claude انسخ هذا Prompt والصقه في Codex أو Claude أو مساعد آخر ليراجع صفحة Skill ويثبّتها لك.
القائمة
Rust clippy, rustfmt, cargo-deny configuration, new lints, and lint failure triage.
التثبيت باستخدام Codex أو Claude انسخ هذا Prompt والصقه في Codex أو Claude أو مساعد آخر ليراجع صفحة Skill ويثبّتها لك.
استنادا إلى تصنيف SOC المهني
Use this skill to generate well-branded interfaces and assets for RIPDPI (an Android-native, Compose-first VPN and DPI-bypass app), either for production or throwaway prototypes/mocks/etc. Contains essential design guidelines, colors, type, fonts, brand-ship icons, and an interactive UI kit of every public composable from the live ui/components tree.
Use when managing the Rust workspace, adding/removing crates, editing workspace dependencies, running cargo nextest/audit/deny, configuring Cargo profiles for Android cross-compilation, debugging Cargo.lock churn, migrating crate edition, or wiring Gradle to cargo via the ripdpi.android.rust-native plugin.
Use when modifying the diagnostics scan pipeline, ScanRequest/ScanReport types, ProbeTask families, ripdpi-monitor-engine / ripdpi-diagnostics-* crates, strategy-probe candidates, the diagnostics catalog (packs/profiles), wire-schema contracts between Rust and Kotlin, DIAGNOSTICS_ENGINE_SCHEMA_VERSION, golden contract tests, or adding a new probe type / profile. Triggers on diagnostics scans, strategy probes, automatic audit, dpi-detector profiles, or anything in core/diagnostics or native/rust/crates/ripdpi-monitor-*.
Android-specific Rust build, verification, and packaging — per-target 16 KiB page alignment, size-optimized release profile, ELF symbol allowlist, .so size budgets, NDK 29 specifics. Use when modifying .cargo/config.toml for Android targets, the workspace [profile.release] / [profile.android-jni] block, or when verifying a built .so before release.
Telemetry and observability discipline for the RIPDPI Android Rust stack — control-plane vs data-plane logging, bounded flume event queues, atomic counters, snapshot polling, readiness callbacks, and deterministic JSON contracts. Use when authoring or modifying telemetry emission code, the bounded event ring, the Kotlin-side telemetry consumer, or any per-packet logging.
Custom detekt rules, DI/privacy/suppression guardrails, detekt.yml configuration, and false-positive triage.
| name | rust-lint-config |
| description | Rust clippy, rustfmt, cargo-deny configuration, new lints, and lint failure triage. |
All lint configuration is centralized at the workspace level. Individual crates inherit via [lints] workspace = true -- never add per-crate lint overrides.
| File | Purpose |
|---|---|
native/rust/Cargo.toml | [workspace.lints.clippy] and [workspace.lints.rust] -- lint levels |
native/rust/clippy.toml | Clippy thresholds and disallowed methods |
native/rust/rustfmt.toml | Formatting rules |
native/rust/deny.toml | License, advisory, and dependency checks |
[workspace.lints.clippy]Denied (errors):
correctness -- logic errors that are almost certainly bugssuspicious -- code that is likely wrongWarned:
style, complexity, perf -- broad lint groupscloned_instead_of_copied, explicit_iter_loop, explicit_into_iter_loop, implicit_clone, inefficient_to_string, map_unwrap_or, redundant_closure_for_method_calls, semicolon_if_nothing_returned, uninlined_format_args, unnested_or_patterns, manual_let_else, trivially_copy_pass_by_ref, unused_self, default_trait_access, match_wildcard_for_single_variantsAllowed (JNI/FFI exceptions):
missing_safety_doc -- JNI crates have many trivially-safe extern fnsnot_unsafe_ptr_arg_deref -- required by JNI function signatures[workspace.lints.rust]unsafe_op_in_unsafe_fn = "warn" -- require explicit unsafe blocks inside unsafe fntoo-many-arguments-threshold = 8
type-complexity-threshold = 300
disallowed-methods = [
{ path = "std::iter::Iterator::for_each", reason = "Use a `for` loop for side effects (F-COMBINATOR)" },
]
edition = "2021"
max_width = 120
use_small_heuristics = "Max"
RUSTSEC-2024-0436 — paste proc-macro, no runtime risk)multiple-versions = "warn", wildcards = "warn"The current configuration is intentionally permissive — it prioritizes shipping velocity over strict enforcement. Three escalations are ready to land once the cleanup work they gate has happened:
multiple-versions = "warn" → "deny"Current state allows duplicate dep versions to silently accumulate. This masks transitive-dep drift and complicates supply-chain audits. Precondition for escalation: run cargo tree --locked --duplicates inside native/rust, resolve all existing duplicates (typically by patching workspace dep versions or adding [patch.crates-io] entries), then flip the level. Do not flip the level before the duplicates are clean — the first CI run will explode.
clippy::expect_used and clippy::unwrap_used at "warn"Production .rs files contain ~1,727 .unwrap() / .expect() call sites as of 2026-04-17 (see rust-panic-safety skill for the full policy). Landing these lints at warn forces new code to justify each .unwrap() while leaving the existing sites compiling. Precondition: confirm every new usage in a PR gets a #[allow(clippy::unwrap_used)] // Infallible: … comment, not a workspace-wide allow.
Suggested addition to [workspace.lints.clippy]:
# Force new .unwrap()/.expect() to justify their safety via a //-comment.
# Existing sites are grandfathered via per-site #[allow] until they're migrated.
unwrap_used = "warn"
expect_used = "warn"
Exempt test code via #[cfg_attr(test, allow(clippy::unwrap_used, clippy::expect_used))] on the test module.
type-complexity-threshold300 is far above Clippy's default (250) and masks genuinely unreadable types — nested HashMap<_, Arc<Mutex<HashMap<_, _>>>> style. Target 250 as a first step; lower to the default 100 only after the workspace compiles cleanly at 200. Each step reveals a different tier of type-complexity smells.
cd native/rust
# Clippy -- all targets, treat warnings as errors
cargo clippy --locked --workspace --all-targets -- -D warnings
# Format check
cargo fmt --all -- --check
# Supply chain / license / advisory
cargo deny --locked check
# All three in sequence
cargo clippy --locked --workspace --all-targets -- -D warnings && cargo fmt --all -- --check && cargo deny --locked check
The .github/workflows/ci.yml pipeline runs these as separate steps. Clippy and fmt run on every push/PR to main.
cargo clippy --locked -p ripdpi-monitor-engine --all-targets -- -D warnings
[workspace.lints.clippy] in native/rust/Cargo.tomlcargo clippy --locked --workspace --all-targets to find all violations#[allow(clippy::lint_name)] with a // TODO(po4yka): fix comment on individual sitescargo nextest run --locked --workspace to verify fixes did not break behaviorAdd to the disallowed-methods list in native/rust/clippy.toml:
disallowed-methods = [
{ path = "std::iter::Iterator::for_each", reason = "Use a `for` loop for side effects" },
{ path = "your::new::method", reason = "Explanation of why it is banned" },
]
#[allow(clippy::too_many_arguments)]
fn complex_jni_bridge(a: i32, b: i32, c: i32, ...) { ... }
Always add a comment explaining why the suppression is necessary.
The workspace already allows missing_safety_doc and not_unsafe_ptr_arg_deref for JNI crates. Adding new per-crate allows requires justification in the commit message.
If a lint produces too many false positives across the entire workspace, reconsider whether it belongs in the config at all rather than setting it to "allow".
| Mistake | Fix |
|---|---|
| Adding lint config to a specific crate's Cargo.toml | All lints are workspace-level; crates use [lints] workspace = true |
| Suppressing lint workspace-wide to avoid fixing code | Fix the violations or add per-site #[allow] with TODO |
Running cargo clippy --locked without --all-targets | Tests and examples need linting too |
Forgetting -- -D warnings in CI | Warnings must be treated as errors in CI |
Adding a dependency without running cargo deny --locked check | New deps may violate license or advisory policy |
| Using unstable rustfmt options | rustfmt.toml uses only stable options (edition, max_width, use_small_heuristics) |
| Raising thresholds in clippy.toml to avoid refactoring | Fix the code; thresholds are already generous (8 args, 300 type complexity) |