6个版本

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

#1100 in 开发工具

MPL-2.0 许可证

775KB
20K SLoC

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测试

我们使用 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 发布。

依赖项

~92MB
~2.5M SLoC