8 个版本

0.0.25 2023年1月13日
0.0.24 2022年1月10日
0.0.23 2021年4月9日
0.0.19 2021年1月8日
0.0.17 2020年6月9日

#175开发工具 中排名

Download history 64/week @ 2024-03-13 36/week @ 2024-03-20 40/week @ 2024-03-27 289/week @ 2024-04-03 341/week @ 2024-04-10 31/week @ 2024-04-17 29/week @ 2024-04-24 16/week @ 2024-05-01 13/week @ 2024-05-08 32/week @ 2024-05-15 48/week @ 2024-05-22 94/week @ 2024-05-29 36/week @ 2024-06-05 11/week @ 2024-06-12 13/week @ 2024-06-19 7/week @ 2024-06-26

每月84次下载
4 个软件包 中使用

MPL-2.0 许可证

20MB
514K SLoC

C 493K SLoC // 0.0% comments Rust 19K SLoC // 0.0% comments JavaScript 550 SLoC // 0.0% comments C++ 284 SLoC // 0.0% comments Python 261 SLoC // 0.3% comments Shell 103 SLoC // 0.5% comments

rust-code-analysis

Task Status codecov

rust-code-analysis 是一个 Rust 库,用于分析并从多种不同编程语言编写的源代码中提取信息。它基于解析器生成工具和一个名为 Tree Sitter 的增量解析库。

提供了一个名为 rust-code-analysis-cli 的命令行工具,以便轻松与 API 交互。

此工具可用于

  • 调用 rust-code-analysis API
  • 打印节点和指标信息
  • 以不同格式导出指标

此外,我们还提供了一个 rust-code-analysis-web 工具,可以通过 REST API 使用库。

使用方法

rust-code-analysis 支持许多类型的编程语言,并计算大量指标。您可以在 文档 中找到最新文档。

命令 页面上,有一份可以运行的命令列表,用于获取此软件提供的指标、节点和其他一般数据的详细信息。

构建

要构建 rust-code-analysis 库,您需要运行以下命令

cargo build

如果您想构建 cli

cargo build -p rust-code-analysis-cli

如果您想构建 web 服务器

cargo build -p rust-code-analysis-web

如果您想一次性构建所有内容

cargo build --workspace

测试

要验证所有测试是否通过,请运行 cargo test 命令。

cargo test --workspace --all-features --verbose

更新即时测试

我们使用 insta,要更新快照测试,您应该安装 cargo insta

cargo insta test --review

将运行测试,生成新的快照引用,并让您审查它们。

贡献

如果您想为这款软件的开发做出贡献,请查看我们开发者指南中包含的指导方针。

如何引用rust-code-analysis

@article{ARDITO2020100635,
    title = {rust-code-analysis: A Rust library to analyze and extract maintainability information from source codes},
    journal = {SoftwareX},
    volume = {12},
    pages = {100635},
    year = {2020},
    issn = {2352-7110},
    doi = {https://doi.org/10.1016/j.softx.2020.100635},
    url = {https://www.sciencedirect.com/science/article/pii/S2352711020303484},
    author = {Luca Ardito and Luca Barbato and Marco Castelluccio and Riccardo Coppola and Calixte Denizet and Sylvestre Ledru and Michele Valsesia},
    keywords = {Algorithm, Software metrics, Software maintainability, Software quality},
    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.}
}

许可证

  • Mozilla定义的语法在MIT许可证下发布。

  • rust-code-analysisrust-code-analysis-clirust-code-analysis-webMozilla公共许可证v2.0下发布。

依赖

~52MB
~1.5M SLoC