Skip to content

Library to analyze and collect metrics on source code

Notifications You must be signed in to change notification settings

skydancer0919/rust-code-analysis

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

163 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

rust-code-analysis

Task Status codecov

This project is a Rust crate (library) to analyse source code. This software is based on Tree Sitter.

Supported Languages

  • C++
  • C#
  • CSS
  • Go
  • HTML
  • Java
  • JavaScript
  • The JavaScript used in Firefox internal
  • Python
  • Rust
  • Typescript

Supported Metrics

  • CC: it calculates the code complexity examining the control flow of a program.
  • SLOC: it counts the number of lines in a source file.
  • LLOC: it counts the number of logical lines (instructions) contained in a source file.
  • HALSTEAD: it is a suite that provides a series of information, such as the effort required to maintain the analyzed code, the size in bits to store the program, the difficulty to understand the code, an estimate of the number of bugs present in the codebase, and an estimate of the time needed to implement the software.
  • MI: it is a suite that allows to evaluate the maintainability of a software.
  • NOM: it counts the number of functions and closures in a file/trait/class.
  • NEXITS: it counts the number of possible exit points from a method/function.
  • NARGS: it counts the number of arguments of a function/method.

How to get metrics

You can get metrics in your shell in this way

rust-code-analysis --metrics --paths /your/path/to/a/file

or as a json file

rust-code-analysis --metrics --output your/path/to/the/output/directory --paths /your/path/to/a/file

or you can run it as a HTTP service and use its REST API

rust-code-analysis --serve --port 9090

How to build the software

Clone the repository and its submodules through HTTPS

git clone --recurse-submodules -j8 https://github.com/mozilla/rust-code-analysis.git

or through SSH

git clone --recurse-submodules -j8 git@github.com:mozilla/rust-code-analysis.git

Build and run rust-code-analysis

# Build with cargo
cargo build

# Run through cargo
cargo run -- -h
cargo run -- --serve --port 8000

How to run tests

After the build step, run the following command in order to verify if all tests pass

cargo test --verbose

About

Library to analyze and collect metrics on source code

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • C 96.0%
  • Rust 3.9%
  • Other 0.1%