Skip to content

Commit

Permalink
Update README
Browse files Browse the repository at this point in the history
  • Loading branch information
Luni-4 committed May 14, 2020
1 parent f6cd981 commit d84427e
Showing 1 changed file with 45 additions and 96 deletions.
141 changes: 45 additions & 96 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,99 +3,48 @@
[![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)

**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

* 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.
- PLOC: it counts the number of physical lines (instructions) contained in a source file.
- LLOC: it counts the number of logical lines (statements) contained in a source file.
- CLOC: it counts the number of comments in a source file.
- BLANK: it counts the number of blank lines 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.

# 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-cli --metrics --paths /your/path/to/a/file
```

or as a `json` 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`


```
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 the software

```console
# 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 to verify if all tests pass

```
cargo test --verbose
```
**rust-code-analysis** is a Rust library to analyze and extract information
from source codes written in many different programming languages.
It is based on a parser generator tool and an incremental parsing library
called
<a href="https://tree-sitter.github.io/tree-sitter/" target="_blank">
Tree Sitter
</a>.


In addition, we provide a command line tool called **rust-code-analysis-cli**
to interact with the API of the library in an easy way.

This tool can be used to:

- Call **rust-code-analysis** API
- Print nodes and metrics information
- Export metrics in different formats

# Software Usability

**rust-code-analysis** supports many types of programming languages and
computes a great variety of metrics. If you want to discover more on this
software, read our
<a href="https://mozilla.github.io/rust-code-analysis/index.html" target="_blank">
Documentation
</a>.

On the
<a href="https://mozilla.github.io/rust-code-analysis/commands/index.html" target="_blank">
Commands
</a> page, you will learn which commands need to be run to get information
about metrics, nodes, and other general data provided by this software.

If you want to contribute to the development of this software
or you are just interested in building **rust-code-analysis**, have a look at the
<a href="https://mozilla.github.io/rust-code-analysis/developers/index.html" target="_blank">
Developers Guide
</a>.

# License

All the source code of **rust-code-analysis** is released under the
<a href="https://www.mozilla.org/MPL/2.0/" target="_blank">
Mozilla Public License v2.0
</a>.

0 comments on commit d84427e

Please sign in to comment.