Skip to content

Commit edb8007

Browse files
committed
Add a readme and some logos.
Signed-off-by: Rahul Krishna <i.m.ralk@gmail.com>
1 parent 6d3dccc commit edb8007

File tree

4 files changed

+128
-1
lines changed

4 files changed

+128
-1
lines changed

README.md

Lines changed: 128 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,129 @@
1-
# codeanalyzer-python
1+
![logo](./docs/assets/logo.png)
2+
23
Python Static Analysis Backend for CLDK
4+
5+
A comprehensive static analysis tool for Python source code that provides symbol table generation, call graph analysis, and semantic analysis using Jedi, CodeQL, and Tree-sitter.
6+
7+
## Installation
8+
9+
This project uses [uv](https://docs.astral.sh/uv/) for dependency management.
10+
11+
### Prerequisites
12+
13+
- Python 3.12 or higher
14+
- [uv](https://docs.astral.sh/uv/getting-started/installation/) installed
15+
16+
### Setup
17+
18+
1. Clone the repository:
19+
```bash
20+
git clone <repository-url>
21+
cd codeanalyzer-python
22+
```
23+
24+
2. Install dependencies using uv:
25+
```bash
26+
uv sync --all-groups
27+
```
28+
29+
This will install all dependencies including development and test dependencies.
30+
31+
3. Install the package in development mode:
32+
```bash
33+
uv pip install -e .
34+
```
35+
36+
## Usage
37+
38+
The codeanalyzer provides a command-line interface for performing static analysis on Python projects.
39+
40+
### Basic Usage
41+
42+
```bash
43+
codeanalyzer --input /path/to/python/project
44+
```
45+
46+
### Command Line Options
47+
48+
- `-i, --input PATH`: **Required.** Path to the project root directory to analyze.
49+
- `-o, --output PATH`: Output directory for analysis artifacts. If specified, results will be saved to `analysis.json` in this directory.
50+
- `-a, --analysis-level INTEGER`: Analysis depth level (default: 1)
51+
- `1`: Symbol table generation
52+
- `2`: Call graph analysis
53+
- `--codeql/--no-codeql`: Enable or disable CodeQL-based analysis (default: disabled)
54+
- `--eager/--lazy`: Analysis mode (default: lazy)
55+
- `--eager`: Rebuild analysis cache at every run
56+
- `--lazy`: Use existing cache if available
57+
- `-c, --cache-dir PATH`: Directory to store analysis cache. Defaults to `.cache/codeanalyzer` in current working directory.
58+
- `--clear-cache/--keep-cache`: Clear cache after analysis (default: clear)
59+
- `-v/-q, --verbose/--quiet`: Enable or disable verbose output (default: verbose)
60+
61+
### Examples
62+
63+
1. **Basic analysis with symbol table:**
64+
```bash
65+
codeanalyzer --input ./my-python-project
66+
```
67+
68+
This will print the symbol table to stdout in JSON format to the standard output. If you want to save the output, you can use the `--output` option.
69+
70+
```bash
71+
codeanalyzer --input ./my-python-project --output /path/to/analysis-results
72+
```
73+
74+
Now, you can find the analysis results in `analysis.json` in the specified directory.
75+
76+
2. **Toggle analysis levels with `--analysis-level`:**
77+
```bash
78+
codeanalyzer --input ./my-python-project --analysis-level 1 # Symbol table only
79+
```
80+
Call graph analysis can be enabled by setting the level to `2`:
81+
```bash
82+
codeanalyzer --input ./my-python-project --analysis-level 2 # Symbol table + Call graph
83+
```
84+
***Note: The `--analysis-level=2` is not yet implemented in this version.***
85+
86+
3. **Analysis with CodeQL enabled:**
87+
```bash
88+
codeanalyzer --input ./my-python-project --codeql
89+
```
90+
This will perform CodeQL-based analysis in addition to the standard symbol table generation.
91+
92+
***Note: Not yet fully implemented. Please refrain from using this option until further notice.***
93+
94+
4. **Eager analysis with custom cache directory:**
95+
```bash
96+
codeanalyzer --input ./my-python-project --eager --cache-dir /path/to/custom-cache
97+
```
98+
This will rebuild the analysis cache at every run and store it in `/path/to/custom-cache/.codeanalyzer`. The cache will be cleared by default after analysis unless you specify `--keep-cache`.
99+
100+
If you provide --cache-dir, the cache will be stored in that directory. If not specified, it defaults to `.codeanalyzer` in the current working directory (`$PWD`).
101+
102+
5. **Quiet mode (minimal output):**
103+
```bash
104+
codeanalyzer --input /path/to/my-python-project --quiet
105+
```
106+
107+
### Output
108+
109+
By default, analysis results are printed to stdout in JSON format. When using the `--output` option, results are saved to `analysis.json` in the specified directory.
110+
111+
## Development
112+
113+
### Running Tests
114+
115+
```bash
116+
uv run pytest --pspec -s
117+
```
118+
119+
### Development Dependencies
120+
121+
The project includes additional dependency groups for development:
122+
123+
- **test**: pytest and related testing tools
124+
- **dev**: development tools like ipdb
125+
126+
Install all groups with:
127+
```bash
128+
uv sync --all-groups
129+
```

assets/Artboard 1.png

43.4 KB
Loading

assets/logo.png

32.3 KB
Loading

assets/ns.png

46.2 KB
Loading

0 commit comments

Comments
 (0)