{"id":15457721,"url":"https://github.com/yassineldeeb/rust-panic-analyzer","last_synced_at":"2025-07-28T18:06:51.096Z","repository":{"id":216406140,"uuid":"741251658","full_name":"YassinEldeeb/rust-panic-analyzer","owner":"YassinEldeeb","description":"an audit tool to scan your crate or workspace searching for potential panic points in your codebase","archived":false,"fork":false,"pushed_at":"2024-05-16T08:18:48.000Z","size":35,"stargazers_count":5,"open_issues_count":4,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-06-28T05:48:14.980Z","etag":null,"topics":["analyzer","audit","ci","panic","rust","safety"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/YassinEldeeb.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-01-10T02:20:28.000Z","updated_at":"2024-11-21T23:30:38.000Z","dependencies_parsed_at":"2024-10-01T22:50:26.367Z","dependency_job_id":"f3dc0afd-5e8d-4bd7-8d4f-d910819a7174","html_url":"https://github.com/YassinEldeeb/rust-panic-analyzer","commit_stats":null,"previous_names":["yassineldeeb/rust-panic-analyzer"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/YassinEldeeb/rust-panic-analyzer","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/YassinEldeeb%2Frust-panic-analyzer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/YassinEldeeb%2Frust-panic-analyzer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/YassinEldeeb%2Frust-panic-analyzer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/YassinEldeeb%2Frust-panic-analyzer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/YassinEldeeb","download_url":"https://codeload.github.com/YassinEldeeb/rust-panic-analyzer/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/YassinEldeeb%2Frust-panic-analyzer/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":267560512,"owners_count":24107500,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-07-28T02:00:09.689Z","response_time":68,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["analyzer","audit","ci","panic","rust","safety"],"created_at":"2024-10-01T22:50:22.069Z","updated_at":"2025-07-28T18:06:51.032Z","avatar_url":"https://github.com/YassinEldeeb.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# 🦀 Rust Panic Analyzer 🔎\n\n## Overview\n\nRust Panic Analyzer is an audit tool designed to scan your Rust crate or workspace. Its primary function is to identify potential panic points in your codebase, leading you in developing binaries and libraries that are as close to \"Panic Free\" as possible.\n\n## How does it work?\n\n### Key Identification Patterns\n\nThe tool searches for usage of several key patterns in Rust code that are often associated with panic points. These include:\n\n- `panic!`: Direct calls to the `panic!` macro, which causes the program to terminate immediately and provide an error message.\n- `unwrap`: Calls to the `.unwrap()` method, often used on `Option` or `Result` types, which will cause a panic if the value is `None` or `Err`.\n- `expect`: Similar to `unwrap`, but allows specifying a custom error message.\n- `Array Indexing`: Direct indexing into arrays (e.g., arr[index]) without bounds checking, which can panic if the index is out of bounds. (A safer indexing method is `.get()`)\n- `unreachable!`: Indicates code that should never be reached; panics if executed.\n- `todo!` and `unimplemented!`: Macros indicating incomplete or unimplemented code, which will panic if reached.\n\n\n## Installation\n\nTo start using it, you need to install it first.\n\n```sh\ncargo install panic-analyzer\n```\n\n\n## Usage Locally:\n\nAfter installation, you can run the analyzer on your crate or entire workspace. Use the following command:\n\n```sh\ncargo panic-analyzer \u003e audit.md\n```\n\nLogging audit result to the terminal\n```sh\ncargo panic-analyzer\n```\n\nIf you wish to exclude specific crates from your workspace during the analysis, set the `IGNORED_CRATES`` environment variable. Pass the names of the crates you want to exclude, separated by commas:\n\n```sh\nIGNORED_CRATES=tests,benches cargo panic-analyzer \u003e audit.md\n```\n\nYou can also do the same with files as the following:\n\n```sh\nIGNORED_FILES=./src/tests/something.rs,./src/tests/else.rs cargo panic-analyzer \u003e audit.md\n```\n\nA potential panic is not necessarily bad, sometimes errors are unrecoverable, and we have to panic.\nIf your panic is intentional, you can add a comment before the line that has the potential panicing code like this:\n\n```rs\npub fn shutdown_server() {\n  // @expected: we need this\n  panic!(\"Exited process!\")\n}\n```\n\nThe syntax is as the following: `// @expected: description/reason`.\n\nThis won't be counted as a potential panic point, but rather an expected panic in a section at the end.\n\n\n## Pull Requests Audit results via GitHub Actions\n\nYou can also hook it up with your CI to post the results on your PRs as a comment which can be very helpful!\n\n```yaml\nname: ci\n\non:\n  push:\n    branches:\n      - main\n  pull_request:\njobs:\n  panic-free-audit:\n    runs-on: ubuntu-latest\n    steps:\n      - uses: actions/checkout@v4\n      - uses: actions-rust-lang/setup-rust-toolchain@v1\n\n      - name: install panic free analyzer\n        run: |\n            cargo install panic-analyzer\n\n      - name: run panic free analyzer\n        run: |\n            cargo panic-analyzer \u003e ./audit.md\n        env:\n          IGNORED_CRATES: e2e_tests,benches\n\n      - name: comment on pull request\n        uses: thollander/actions-comment-pull-request@v2\n        with:\n          filePath: ./audit.md\n          comment_tag: rust-code-audit\n\n```\n\n## ⚠️ Limitations:\n\n- As of now, it only currently searches the crates that you develop, and not the dependencies of your crates.\n- The analysis is done using regex rather than an AST for simplicity, so you may encounter unidentified potential panic points if the lines were wrapped in certain ways that the regex patterns can't catch.\n\n\n# Audit Results Example 👇\n\nBelow is an example of an audit result generated by the Rust Panic Free Analyzer:\n\n\n# 🚨 Rust Panic Audit: 82 Potential Panic Points Detected 🚨\n\n## Crate: `vrl`\n\n📊 Total Usages: 37\n\n- 🔎 `expect` usages: 1\n- 🎁 `unwrap` usages: 32\n- 🚨 `panic` usages: 1\n- 🔢 `array_index` usages: 3\n\n## Crate: `jwt_auth`\n\n📊 Total Usages: 31\n\n- 🎁 `unwrap` usages: 29\n- 🔢 `array_index` usages: 2\n\n## Crate: `config`\n\n📊 Total Usages: 14\n\n- 🚨 `panic` usages: 3\n- 🔎 `expect` usages: 3\n- 🎁 `unwrap` usages: 8\n\n## 📌 Expected Annotations\n\n### Crate: `common`\n\n📊 Total Expected Usages: 1\n\n- Reason: \"we need this\"\n- Code: `panic!(\"Exited process!\")`\n- Location: `./libs/common/src/lib.rs:18`\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyassineldeeb%2Frust-panic-analyzer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyassineldeeb%2Frust-panic-analyzer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyassineldeeb%2Frust-panic-analyzer/lists"}