rustimal 0.7.0

A minimal, GPU-rendered terminal for Windows that runs Git Bash, with animated split panes and a glass look
//! Every rule's code with a longer explanation, for `rustimal --review --explain CODE`.

pub struct Rule {
    pub code: &'static str,
    pub name: &'static str,
    pub explain: &'static str,
}

macro_rules! rules {
    ($($code:literal, $name:literal, $explain:literal;)*) => {
        pub const RULES: &[Rule] = &[$(Rule { code: $code, name: $name, explain: $explain }),*];
    };
}

rules! {
    "GEN001", "debugging call left in",
    "Calls such as dd(), dump(), console.log(), debugger, dbg!() or todo!() are usually left over from working on the change. Some only add noise; dd() and todo!() stop the program. Comment lines are ignored, and at most three are listed per file.";
    "GEN002", "possible secret",
    "An added line looks like a private key, a known token format (AWS, GitHub, Slack, Stripe, Google) or a literal assigned to something named like a password or token. Rotate a real one: removing it in a later commit leaves it in history. Placeholders are ignored, as are literal assignments in tests, factories and seeders.";
    "GEN003", "merge conflict marker",
    "A line starting with <<<<<<< or >>>>>>> was added. The file almost certainly still holds both sides of a merge and will not behave as either one.";
    "GEN004", "source changed without tests",
    "Twenty or more lines of source were added and no test file or inline test changed. This is not a rule that everything needs a test; it asks which new behaviour would go unnoticed if it broke.";
    "GEN005", "manifest and lock file out of step",
    "Dependencies in composer.json, package.json or Cargo.toml changed but the lock file did not. CI and production install from the lock file, so they may run something else than what you tried. Ignore this if the repository does not commit lock files.";
    "GEN006", "env file in the change",
    "A .env file other than a template (.env.example and the like) is added or modified. These hold credentials and machine-specific settings.";
    "GEN007", "tests changed",
    "Lists the commands that run the tests this change adds or modifies. A test that also passes without the change does not test it: run it once with the fix removed.";
    "TAU001", "Content-Security-Policy weakened",
    "The CSP limits what the webview may load and run. Without it, or with unsafe-inline or unsafe-eval, an injection bug in the page can run script that calls any Tauri command the window is allowed to call.";
    "TAU002", "permissions granted to the webview",
    "Capability files (Tauri 2) and the allowlist (Tauri 1) decide what the frontend may do on the user's machine. Grant the narrowest permission with a scope. The removal test (delete it, see the call rejected) shows which file really grants an ability.";
    "TAU003", "command not registered",
    "A function marked #[tauri::command] is missing from generate_handler![]. It compiles, and invoke() fails at runtime. Skipped when the list is built by a tool such as tauri-specta, or when the Rust sources cannot be read.";
    "TAU004", "command added or changed",
    "Commands are the contract between Rust and the webview, and nothing type-checks it across the boundary. Parameter names become camelCase keys in JavaScript, errors must serialize, and synchronous commands run on the main thread.";
    "TAU005", "invoke of an unknown command",
    "The frontend calls a command name that no #[tauri::command] function in the Rust sources has. Plugin commands (plugin:...) and names built at runtime are not checked.";
    "TAU006", "application identifier or name changed",
    "The app's data, config and cache folders are derived from its identifier. Changing it makes existing installs look empty, and installers or the updater may treat the new build as a different application.";
    "TAU007", "Tauri crate and package versions",
    "The tauri crates and the @tauri-apps packages are released together and talk over IPC. Update them together; `tauri info` shows both and flags a mismatch.";
    "TAU008", "bundle or updater settings",
    "These only take effect in a built installer, so running the dev server proves nothing about them. Build, install on a clean machine, and for the updater, update from an older version.";
    "LAR001", "destructive or risky migration",
    "Dropping, renaming or altering schema can lose data, and during a deploy old code often runs against the new schema. Prefer expand and contract: add first, move the code, remove later. Lines inside down() are not reported.";
    "LAR002", "existing migration edited",
    "Laravel records which migrations have run and never runs one again. Editing a shipped migration changes fresh databases only, so environments drift apart. Add a new migration instead.";
    "LAR003", "new migration",
    "How to try a schema change: read the SQL with --pretend, run it, roll it back, run it again, and build a fresh database. An empty down() makes rollback lie about what it did.";
    "LAR004", "routes",
    "Lists new routes and warns about ones that change data with no auth middleware near them. Only the lines around the change are visible to this rule, so a guard on a far-away group or in bootstrap/app.php is not seen: confirm with route:list -v.";
    "LAR005", "mass assignment and serialization",
    "$fillable and $guarded decide which columns a request can set through create() and update(). $hidden, $visible and $appends decide what JSON, Inertia props and API responses reveal.";
    "LAR006", "SQL built from variables",
    "A variable is interpolated or concatenated into the SQL of a raw query, so its contents are read as SQL. Bind values with ?. Column names and sort directions cannot be bound: check them against a fixed list.";
    "LAR007", "unescaped Blade output",
    "{!! !!} prints HTML as it is. If any part comes from a user, it is a cross-site scripting hole. Common framework helpers that produce safe HTML are not reported.";
    "LAR008", "validation changed",
    "Validation is easiest to test at its edges: missing, empty, wrong type, just past each limit. unique rules need ignore() on update, or saving a record unchanged fails.";
    "LAR009", "environment and configuration",
    "env() only reads .env while the config is not cached, and most deploys cache it, so call env() in config/ files only. New variables must be documented and set on every server.";
    "LAR010", "queues, schedule and mail",
    "Queued jobs outlive deploys and are retried, so they must tolerate old payloads and running twice. The sync queue driver hides both problems: test with a real one.";
    "LAR011", "authorization",
    "A change removes more permission checks than it adds in a file, or changes a policy. Authorization bugs rarely show when you test as yourself: use another user's record ids and a logged-out client.";
    "LAR012", "views and forms",
    "UI changes need a look in a browser: empty, crowded and error states. A POST form without @csrf is rejected with 419 Page Expired.";
    "LAR013", "composer dependencies",
    "Dependency and platform changes affect every environment. Install from a clean checkout, audit for known vulnerabilities, and check the PHP version everywhere it runs.";
    "PR001", "unchecked checklist item",
    "The description has a checklist item that is not ticked. Items inside HTML comments and code blocks are ignored.";
    "PR002", "no test plan",
    "The description has no section about testing and no ticked item about it, so a reviewer cannot repeat what was tried.";
    "PR003", "description leaves out something to act on",
    "The diff adds a migration or environment variable, or renames the app, and the description does not say so. These need action from whoever deploys or reviews.";
    "PR004", "claimed tests are missing",
    "The description says tests were added, but no test file or inline test is in the diff. Often they were never committed.";
    "PR005", "no screenshot",
    "UI files changed and the description has no image or video.";
    "PR006", "linked issues",
    "The description says the change closes an issue. The review cannot read the issue, so its acceptance criteria are yours to check.";
}

pub fn lookup(code: &str) -> Option<&'static Rule> {
    RULES.iter().find(|r| r.code.eq_ignore_ascii_case(code))
}