Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 6 additions & 8 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,32 +10,30 @@ cc = "^1.0"
phf_codegen = "^0.8"

[dependencies]
actix-web = "^2.0"
actix-rt = "^1.0"
actix-web = "^2.0"
aho-corasick = "^0.7"
bytes = "^0.5"
clap = "^2.33"
enum-iterator = "^0.6"
futures = "^0.3"
fxhash = "0.2"
globset = "^0.4"
json = "^0.12"
tree-sitter = "^0.6"
termcolor = "^1.0"
crossbeam = "^0.7"
lazy_static = "^1.3"
num_cpus = "^1.12"
num-format = "^0.4"
petgraph = "^0.5"
phf = { version = "^0.8", features = ["macros"] }
regex = "^1.1"
serde = "^1.0"
serde_json = "^1.0"
walkdir = "^2.2"
termcolor = "^1.0"
tree-sitter = "^0.6"

[dev-dependencies]
pretty_assertions = "^0.6"

[workspace]
members = ["rust-code-analysis-cli"]

[profile.release]
opt-level = 3
debug = false
Expand Down
25 changes: 18 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
[![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)
[![codecov](https://codecov.io/gh/mozilla/rust-code-analysis/branch/master/graph/badge.svg)](https://codecov.io/gh/mozilla/rust-code-analysis)

This project is a Rust crate (library) to analyse source code. This software is based on [Tree Sitter](https://github.com/tree-sitter/tree-sitter).
**rust-code-analysis** is a Rust library to analyze the source code of many different programming languages. It is based on a parser generator tool and an incremental parsing library called [Tree Sitter](https://github.com/tree-sitter/tree-sitter).

## Supported Languages

Expand Down Expand Up @@ -33,18 +33,26 @@ control flow of a program.
- 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
# rust-code-analysis-cli

**rust-code-analysis-cli** is a command line tool thought to interact with
the functions available in the library.
It can print a series of information on your shell such as nodes and metrics.
It can also export metrics as a json file.
Below you can find a series of commands to use the software at best.

### How to get metrics

You can get metrics in your shell in this way

```
rust-code-analysis --metrics --paths /your/path/to/a/file
rust-code-analysis-cli --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
rust-code-analysis-cli --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`
Expand All @@ -69,20 +77,23 @@ or through SSH
git clone --recurse-submodules -j8 git@github.com:mozilla/rust-code-analysis.git
```

Build and run `rust-code-analysis`
Build and run the software

```console
# Build with cargo
# Build rust-code-analysis with cargo
cargo build

# Build rust-code-analysis-cli with cargo
cargo build --all

# 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
After the build step, run the following command to verify if all tests pass

```
cargo test --verbose
Expand Down
14 changes: 14 additions & 0 deletions rust-code-analysis-cli/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[package]
name = "rust-code-analysis-cli"
version = "0.0.1"
authors = ["Calixte Denizet <cdenizet@mozilla.com>"]
edition = "2018"

[dependencies]
clap = "^2.33"
crossbeam = "^0.7"
globset = "^0.4"
num_cpus = "^1.12"
rust-code-analysis = { path = ".." }
serde_json = "^1.0"
walkdir = "^2.2"
File renamed without changes.