8 个版本
0.0.25 | 2023 年 1 月 13 日 |
---|---|
0.0.24 | 2022 年 10 月 14 日 |
0.0.23 | 2021 年 4 月 9 日 |
0.0.19 | 2021 年 1 月 8 日 |
0.0.1 | 2020 年 6 月 9 日 |
#42 in #parser-generator
91 个月下载量
745KB
20K SLoC
rust-code-analysis
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 测试
我们使用 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-analysis、rust-code-analysis-cli 和 rust-code-analysis-web 以 Mozilla公共许可证v2.0 发布。
依赖项
~80MB
~2M SLoC