|
| 1 | +# rust-code-analysis-cli |
| 2 | + |
| 3 | +`rust-code-analysis-cli` is a tool designed to compute and export code metrics, analyze source code, and perform various operations such as removing comments, counting nodes, retrieving functions, and computing code metrics in different formats. |
| 4 | + |
| 5 | +## Features |
| 6 | + |
| 7 | +- Analyze source code for different programming languages. |
| 8 | +- Export results in different formats (CBOR, JSON, TOML, YAML). |
| 9 | +- Perform various operations on source code (e.g., dumping abstract syntax tree to stdout, counting nodes, computing code metrics). |
| 10 | + |
| 11 | +## Installation |
| 12 | + |
| 13 | +Clone the repository and build the project: |
| 14 | + |
| 15 | +```sh |
| 16 | +cd rust-code-analysis-cli/ |
| 17 | +cargo build |
| 18 | +``` |
| 19 | + |
| 20 | +## Usage |
| 21 | + |
| 22 | +Run the tool by specifying the input file and the desired operation: |
| 23 | + |
| 24 | +```sh |
| 25 | +rust-code-analysis-cli [OPTIONS] |
| 26 | +``` |
| 27 | + |
| 28 | +## Available Options |
| 29 | + |
| 30 | +- `-p, --paths <FILE>...`: Input files to analyze. |
| 31 | +- `-d, --dump`: Dump the abstract syntax tree to stdout. |
| 32 | +- `-c, --comments`: Remove comments from specified files. |
| 33 | +- `-f, --find <NODE_TYPE>`: Find nodes of the given type. |
| 34 | +- `-F, --function`: Get functions and their spans. |
| 35 | +- `-C, --count <NODE_TYPE>`: Count nodes of the given type. |
| 36 | +- `-m, --metrics`: Compute code metrics. |
| 37 | +- `--ops`: Retrieve all operands and operators in the code. |
| 38 | +- `-i, --in-place`: Perform actions in place. |
| 39 | +- `-I, --include [<INCLUDE>...]`: Include files matching the given pattern. |
| 40 | +- `-X, --exclude [<EXCLUDE>...]`: Exclude files matching the given pattern. |
| 41 | +- `-j, --num-jobs <NUM_JOBS>`: Number of threads to use. |
| 42 | +- `-l, --language-type <LANGUAGE>`: Language of the input files. |
| 43 | +- `-O, --output-format <FORMAT>`: Output format for the results (CBOR, JSON, TOML, YAML). |
| 44 | +- `--pr`: Dump a pretty JSON output file. |
| 45 | +- `-o, --output <OUTPUT>`: Output directory for the results. |
| 46 | +- `--preproc <PREPROCESSOR>`: Get preprocessor directives for C/C++ files. |
| 47 | +- `--ls <LINE_START>`: Start line for the analysis. |
| 48 | +- `--le <LINE_END>`: End line for the analysis. |
| 49 | +- `-w, --warning`: Show warnings. |
| 50 | +- `-v, --version`: Show version information. |
| 51 | +- `-h, --help`: Show help information. |
| 52 | + |
| 53 | +## Examples |
| 54 | + |
| 55 | +To analyze the code in a file and export the metrics in JSON format: |
| 56 | + |
| 57 | +```sh |
| 58 | +rust-code-analysis-cli --metrics --output-format json --output . --paths path/to/file.rs |
| 59 | +``` |
0 commit comments