{"id":18044602,"url":"https://github.com/mozilla/rust-code-analysis","last_synced_at":"2025-05-14T20:06:11.933Z","repository":{"id":35652750,"uuid":"197205914","full_name":"mozilla/rust-code-analysis","owner":"mozilla","description":"Library to analyze and collect metrics on source code","archived":false,"fork":false,"pushed_at":"2025-04-08T00:12:32.000Z","size":20983,"stargazers_count":312,"open_issues_count":63,"forks_count":51,"subscribers_count":11,"default_branch":"master","last_synced_at":"2025-04-11T18:23:11.542Z","etag":null,"topics":["rust","source-code-analysis"],"latest_commit_sha":null,"homepage":"https://mozilla.github.io/rust-code-analysis/","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mozilla.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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}},"created_at":"2019-07-16T14:05:37.000Z","updated_at":"2025-04-08T09:08:54.000Z","dependencies_parsed_at":"2023-02-16T12:00:37.510Z","dependency_job_id":"603f6ddf-e662-4cfb-b040-432963555d72","html_url":"https://github.com/mozilla/rust-code-analysis","commit_stats":{"total_commits":756,"total_committers":20,"mean_commits":37.8,"dds":0.5079365079365079,"last_synced_commit":"9b7ead60efb153020133deaa9e6a32b40d40a676"},"previous_names":[],"tags_count":21,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mozilla%2Frust-code-analysis","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mozilla%2Frust-code-analysis/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mozilla%2Frust-code-analysis/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mozilla%2Frust-code-analysis/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mozilla","download_url":"https://codeload.github.com/mozilla/rust-code-analysis/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248564735,"owners_count":21125409,"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","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":["rust","source-code-analysis"],"created_at":"2024-10-30T18:09:34.137Z","updated_at":"2025-04-12T11:48:50.031Z","avatar_url":"https://github.com/mozilla.png","language":"C","funding_links":[],"categories":["Rust"],"sub_categories":[],"readme":"# rust-code-analysis\n\n[![Crates.io](https://img.shields.io/crates/v/rust-code-analysis.svg)](https://crates.io/crates/rust-code-analysis)\n[![Task Status](https://community-tc.services.mozilla.com/api/github/v1/repository/mozilla/rust-code-analysis/master/badge.svg)](https://community-tc.services.mozilla.com/api/github/v1/repository/mozilla/rust-code-analysis/master/latest)\n[![codecov](https://codecov.io/gh/mozilla/rust-code-analysis/branch/master/graph/badge.svg)](https://codecov.io/gh/mozilla/rust-code-analysis)\n\u003ca href=\"https://chat.mozilla.org/#/room/#rust-code-analysis:mozilla.org\" target=\"_blank\"\u003e\n   \u003cimg src=\"https://img.shields.io/badge/chat%20on%20[m]-%23rust--code--analysis%3Amozilla.org-blue\"\u003e\n\u003c/a\u003e\n\n**rust-code-analysis** is a Rust library to analyze and extract information\nfrom source code written in many different programming languages.\nIt is based on a parser generator tool and an incremental parsing library\ncalled\n\u003ca href=\"https://tree-sitter.github.io/tree-sitter/\" target=\"_blank\"\u003eTree Sitter\u003c/a\u003e.\n\n\nA command line tool called **rust-code-analysis-cli** is provided to interact with the API of the library in an easy way.\n\nThis tool can be used to:\n\n- Call **rust-code-analysis** API\n- Print nodes and metrics information\n- Export metrics in different formats\n\nIn addition, we provide a **rust-code-analysis-web** tool to use the library through a REST API.\n\n\n# Usage\n\n**rust-code-analysis** supports many types of programming languages and\ncomputes a great variety of metrics. You can find up to date documentation at\n\u003ca href=\"https://mozilla.github.io/rust-code-analysis/index.html\" target=\"_blank\"\u003eDocumentation\u003c/a\u003e.\n\nOn the\n\u003ca href=\"https://mozilla.github.io/rust-code-analysis/commands/index.html\" target=\"_blank\"\u003e\n    Commands\n\u003c/a\u003e page, there is a list of commands that can be run to get information\nabout metrics, nodes, and other general data provided by this software.\n\n## Building\n\nTo build the `rust-code-analysis` library, you need to run the following\ncommand:\n\n```console\ncargo build\n```\n\nIf you want to build the `cli`:\n\n```console\ncargo build -p rust-code-analysis-cli\n```\n\nIf you want to build the `web` server:\n\n```console\ncargo build -p rust-code-analysis-web\n```\n\nIf you want to build everything in one fell swoop:\n\n```console\ncargo build --workspace\n```\n\n## Testing\n\nTo verify whether all tests pass, run the `cargo test` command.\n\n```console\ncargo test --workspace --all-features --verbose\n```\n\n### Updating insta tests\nWe use [insta](https://insta.rs), to update the snapshot tests you should install [cargo insta](https://crates.io/crates/cargo-insta)\n\n``` console\ncargo insta test --review\n```\n\nWill run the tests, generate the new snapshot references and let you review them.\n\n### Updating grammars\nHave a look at\n\u003ca href=\"https://mozilla.github.io/rust-code-analysis/developers/update-grammars.html\" target=\"_blank\"\u003eUpdate grammars guide\u003c/a\u003e\nto learn how to update languages grammars.\n\n# Contributing\n\nIf you want to contribute to the development of this software, have a look at the\nguidelines contained in our\n\u003ca href=\"https://mozilla.github.io/rust-code-analysis/developers/index.html\" target=\"_blank\"\u003eDevelopers Guide\u003c/a\u003e.\n\n\n# How to cite rust-code-analysis\n\n```\n@article{ARDITO2020100635,\n    title = {rust-code-analysis: A Rust library to analyze and extract maintainability information from source codes},\n    journal = {SoftwareX},\n    volume = {12},\n    pages = {100635},\n    year = {2020},\n    issn = {2352-7110},\n    doi = {https://doi.org/10.1016/j.softx.2020.100635},\n    url = {https://www.sciencedirect.com/science/article/pii/S2352711020303484},\n    author = {Luca Ardito and Luca Barbato and Marco Castelluccio and Riccardo Coppola and Calixte Denizet and Sylvestre Ledru and Michele Valsesia},\n    keywords = {Algorithm, Software metrics, Software maintainability, Software quality},\n    abstract = {The literature proposes many software metrics for evaluating the source code non-functional properties, such as its complexity and maintainability. The literature also proposes several tools to compute those properties on source codes developed with many different software languages. However, the Rust language emergence has not been paired by the community’s effort in developing parsers and tools able to compute metrics for the Rust source code. Also, metrics tools often fall short in providing immediate means of comparing maintainability metrics between different algorithms or coding languages. We hence introduce rust-code-analysis, a Rust library that allows the extraction of a set of eleven maintainability metrics for ten different languages, including Rust. rust-code-analysis, through the Abstract Syntax Tree (AST) of a source file, allows the inspection of the code structure, analyzing source code metrics at different levels of granularity, and finding code syntax errors before compiling time. The tool also offers a command-line interface that allows exporting the results in different formats. The possibility of analyzing source codes written in different programming languages enables simple and systematic comparisons between the metrics produced from different empirical and large-scale analysis sources.}\n}\n```\n\n\n# Licenses\n\n- Mozilla-defined grammars are released under the MIT license.\n\n- **rust-code-analysis**, **rust-code-analysis-cli** and **rust-code-analysis-web**\nare released under the\n\u003ca href=\"https://www.mozilla.org/MPL/2.0/\" target=\"_blank\"\u003eMozilla Public License v2.0\u003c/a\u003e.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmozilla%2Frust-code-analysis","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmozilla%2Frust-code-analysis","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmozilla%2Frust-code-analysis/lists"}