From 38c4dca86cfcd3d0ff4ed6d84ab979b5e481f5d7 Mon Sep 17 00:00:00 2001 From: tupe12334 Date: Fri, 26 Jun 2026 20:35:38 +0300 Subject: [PATCH] chore(lint): enable clippy::panic Forbids explicit panic!() calls in production code. Unreachable match arms in tests converted to unreachable!() which is semantically precise and not caught by this lint. Co-Authored-By: Claude Sonnet 4.6 --- Cargo.toml | 2 ++ src/cli_tests.rs | 12 ++++++------ src/issue/adhoc_env_tests.rs | 2 +- src/issue/adhoc_tests.rs | 8 ++++---- 4 files changed, 13 insertions(+), 11 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 5d3adb5..23d5827 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -47,3 +47,5 @@ multiple_crate_versions = "allow" dbg_macro = "deny" # Forbid leftover `todo!` placeholders from reaching production todo = "deny" +# Forbid explicit `panic!` calls; unreachable arms belong in `unreachable!` +panic = "deny" diff --git a/src/cli_tests.rs b/src/cli_tests.rs index 683f7f6..f3d1d77 100644 --- a/src/cli_tests.rs +++ b/src/cli_tests.rs @@ -12,7 +12,7 @@ fn test_open_env_single() { Commands::Open { env, .. } => { assert_eq!(env, vec!["FOO=bar"]); } - _other => panic!("unexpected command variant"), + _other => unreachable!("unexpected command variant"), } } @@ -30,7 +30,7 @@ fn test_open_env_multiple() { Commands::Open { env, .. } => { assert_eq!(env, vec!["FOO=bar", "BAZ=qux"]); } - _other => panic!("unexpected command variant"), + _other => unreachable!("unexpected command variant"), } } @@ -41,7 +41,7 @@ fn test_open_env_empty_by_default() { Commands::Open { env, .. } => { assert!(env.is_empty()); } - _other => panic!("unexpected command variant"), + _other => unreachable!("unexpected command variant"), } } @@ -52,7 +52,7 @@ fn test_open_json_flag() { Commands::Open { json, .. } => { assert!(json); } - _other => panic!("unexpected command variant"), + _other => unreachable!("unexpected command variant"), } } @@ -63,7 +63,7 @@ fn test_open_json_false_by_default() { Commands::Open { json, .. } => { assert!(!json); } - _other => panic!("unexpected command variant"), + _other => unreachable!("unexpected command variant"), } } @@ -88,6 +88,6 @@ fn test_open_env_and_json_together() { assert!(json); assert!(headless); } - _other => panic!("unexpected command variant"), + _other => unreachable!("unexpected command variant"), } } diff --git a/src/issue/adhoc_env_tests.rs b/src/issue/adhoc_env_tests.rs index 1e0cab5..e0abeba 100644 --- a/src/issue/adhoc_env_tests.rs +++ b/src/issue/adhoc_env_tests.rs @@ -18,7 +18,7 @@ fn parse_worktree_url_env_with_adhoc() { .unwrap(); match r { IssueRef::Adhoc { name, .. } => assert_eq!(name, "run-42"), - other => panic!("expected Adhoc, got {other:?}"), + other => unreachable!("expected Adhoc, got {other:?}"), } assert_eq!(opts.extra_env.len(), 1); assert_eq!( diff --git a/src/issue/adhoc_tests.rs b/src/issue/adhoc_tests.rs index 4b72515..37899bc 100644 --- a/src/issue/adhoc_tests.rs +++ b/src/issue/adhoc_tests.rs @@ -9,7 +9,7 @@ fn parse_bare_owner_repo() { assert_eq!(repo, "api"); assert!(name.contains('_'), "expected adjective_noun: {name}"); } - other => panic!("expected Adhoc, got {other:?}"), + other => unreachable!("expected Adhoc, got {other:?}"), } } @@ -22,7 +22,7 @@ fn parse_worktree_url_no_issue() { assert_eq!(repo, "api"); assert!(name.contains('_')); } - other => panic!("expected Adhoc, got {other:?}"), + other => unreachable!("expected Adhoc, got {other:?}"), } } @@ -35,7 +35,7 @@ fn parse_worktree_url_no_issue_with_editor() { assert_eq!(owner, "acme"); assert_eq!(repo, "api"); } - other => panic!("expected Adhoc, got {other:?}"), + other => unreachable!("expected Adhoc, got {other:?}"), } assert_eq!(opts.editor.as_deref(), Some("cursor")); } @@ -95,6 +95,6 @@ fn parse_worktree_url_adhoc_param() { assert_eq!(repo, "api"); assert_eq!(name, "my-session"); } - other => panic!("expected Adhoc, got {other:?}"), + other => unreachable!("expected Adhoc, got {other:?}"), } }