|
6 | 6 | <img src="https://img.shields.io/badge/chat%20on%20[m]-%23rust--code--analysis%3Amozilla.org-blue"> |
7 | 7 | </a> |
8 | 8 |
|
9 | | -**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). |
10 | | - |
11 | | -## Supported Languages |
12 | | - |
13 | | -* C++ |
14 | | -* C# |
15 | | -* CSS |
16 | | -* Go |
17 | | -* HTML |
18 | | -* Java |
19 | | -* JavaScript |
20 | | -* The JavaScript used in Firefox internal |
21 | | -* Python |
22 | | -* Rust |
23 | | -* Typescript |
24 | | - |
25 | | -## Supported Metrics |
26 | | - |
27 | | -- CC: it calculates the code complexity examining the |
28 | | -control flow of a program. |
29 | | -- SLOC: it counts the number of lines in a source file. |
30 | | -- PLOC: it counts the number of physical lines (instructions) contained in a source file. |
31 | | -- LLOC: it counts the number of logical lines (statements) contained in a source file. |
32 | | -- CLOC: it counts the number of comments in a source file. |
33 | | -- BLANK: it counts the number of blank lines in a source file. |
34 | | -- 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. |
35 | | -- MI: it is a suite that allows to evaluate the maintainability of a software. |
36 | | -- NOM: it counts the number of functions and closures in a file/trait/class. |
37 | | -- NEXITS: it counts the number of possible exit points from a method/function. |
38 | | -- NARGS: it counts the number of arguments of a function/method. |
39 | | - |
40 | | -# rust-code-analysis-cli |
41 | | - |
42 | | -**rust-code-analysis-cli** is a command line tool thought to interact with |
43 | | -the functions available in the library. |
44 | | -It can print a series of information on your shell such as nodes and metrics. |
45 | | -It can also export metrics as a json file. |
46 | | -Below you can find a series of commands to use the software at best. |
47 | | - |
48 | | -### How to get metrics |
49 | | - |
50 | | -You can get metrics in your shell in this way |
51 | | - |
52 | | -``` |
53 | | -rust-code-analysis-cli --metrics --paths /your/path/to/a/file |
54 | | -``` |
55 | | - |
56 | | -or as a `json` file |
57 | | - |
58 | | -``` |
59 | | -rust-code-analysis-cli --metrics --output your/path/to/the/output/directory --paths /your/path/to/a/file |
60 | | -``` |
61 | | - |
62 | | -or you can run it as a `HTTP` service and use its `REST API` |
63 | | - |
64 | | - |
65 | | -``` |
66 | | -rust-code-analysis --serve --port 9090 |
67 | | -``` |
68 | | - |
69 | | - |
70 | | -## How to build the software |
71 | | - |
72 | | -Clone the repository and its submodules through HTTPS |
73 | | - |
74 | | -``` |
75 | | -git clone --recurse-submodules -j8 https://github.com/mozilla/rust-code-analysis.git |
76 | | -``` |
77 | | - |
78 | | -or through SSH |
79 | | - |
80 | | -``` |
81 | | -git clone --recurse-submodules -j8 git@github.com:mozilla/rust-code-analysis.git |
82 | | -``` |
83 | | - |
84 | | -Build and run the software |
85 | | - |
86 | | -```console |
87 | | -# Build rust-code-analysis with cargo |
88 | | -cargo build |
89 | | - |
90 | | -# Build rust-code-analysis-cli with cargo |
91 | | -cargo build --all |
92 | | - |
93 | | -# Run through cargo |
94 | | -cargo run -- -h |
95 | | -cargo run -- --serve --port 8000 |
96 | | -``` |
97 | | - |
98 | | -## How to run tests |
99 | | - |
100 | | -After the build step, run the following command to verify if all tests pass |
101 | | - |
102 | | -``` |
103 | | -cargo test --verbose |
104 | | -``` |
| 9 | +**rust-code-analysis** is a Rust library to analyze and extract information |
| 10 | +from source codes written in many different programming languages. |
| 11 | +It is based on a parser generator tool and an incremental parsing library |
| 12 | +called |
| 13 | +<a href="https://tree-sitter.github.io/tree-sitter/" target="_blank"> |
| 14 | + Tree Sitter |
| 15 | +</a>. |
| 16 | + |
| 17 | + |
| 18 | +In addition, we provide a command line tool called **rust-code-analysis-cli** |
| 19 | +to interact with the API of the library in an easy way. |
| 20 | + |
| 21 | +This tool can be used to: |
| 22 | + |
| 23 | +- Call **rust-code-analysis** API |
| 24 | +- Print nodes and metrics information |
| 25 | +- Export metrics in different formats |
| 26 | + |
| 27 | +# Software Usability |
| 28 | + |
| 29 | +**rust-code-analysis** supports many types of programming languages and |
| 30 | +computes a great variety of metrics. If you want to discover more on this |
| 31 | +software, read our |
| 32 | +<a href="https://mozilla.github.io/rust-code-analysis/index.html" target="_blank"> |
| 33 | + Documentation |
| 34 | +</a>. |
| 35 | + |
| 36 | +On the |
| 37 | +<a href="https://mozilla.github.io/rust-code-analysis/commands/index.html" target="_blank"> |
| 38 | + Commands |
| 39 | +</a> page, you will learn which commands need to be run to get information |
| 40 | +about metrics, nodes, and other general data provided by this software. |
| 41 | + |
| 42 | +If you want to contribute to the development of this software |
| 43 | +or you are just interested in building **rust-code-analysis**, have a look at the |
| 44 | +<a href="https://mozilla.github.io/rust-code-analysis/developers/index.html" target="_blank"> |
| 45 | + Developers Guide |
| 46 | +</a>. |
| 47 | + |
| 48 | +# License |
| 49 | + |
| 50 | +All the source code of **rust-code-analysis** is released under the |
| 51 | +<a href="https://www.mozilla.org/MPL/2.0/" target="_blank"> |
| 52 | + Mozilla Public License v2.0 |
| 53 | +</a>. |
0 commit comments